From 497a785157ceeb583214d0237533ddc6317508e0 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 25 Apr 2002 07:55:00 +0000 Subject: [PATCH] For PR automake/307: * lib/depcomp: Never compute dependencies in the background, this can cause races with libtool. Compute the dependencies after the actual compilation. Don't make libtool silent now that it's run in the foreground. * tests/pr307.test: New file. * tests/Makefile.am (TESTS): Add pr307.test. Reported by Laurent Morichetti. --- ChangeLog | 11 ++++ THANKS | 1 + lib/depcomp | 147 ++++++++++++---------------------------------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/pr307.test | 49 ++++++++++++++++ 6 files changed, 100 insertions(+), 110 deletions(-) create mode 100755 tests/pr307.test diff --git a/ChangeLog b/ChangeLog index 13fe9596..132be99d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-04-25 Alexandre Duret-Lutz + + For PR automake/307: + * lib/depcomp: Never compute dependencies in the background, this + can cause races with libtool. Compute the dependencies after + the actual compilation. Don't make libtool silent now that + it's run in the foreground. + * tests/pr307.test: New file. + * tests/Makefile.am (TESTS): Add pr307.test. + Reported by Laurent Morichetti. + 2002-04-25 Alexandre Duret-Lutz * lib/am/check.am: Show skipped tests. Display the diff --git a/THANKS b/THANKS index c5032c7f..7c067ab3 100644 --- a/THANKS +++ b/THANKS @@ -96,6 +96,7 @@ L. Peter Deutsch ghost@aladdin.com Larry Jones larry.jones@sdrc.com Lars Hecking lhecking@nmrc.ucc.ie Lars J. Aas larsa@sim.no +Laurent Morichetti laurentm@cup.hp.com Maciej Stachowiak mstachow@mit.edu Maciej W. Rozycki macro@ds2.pg.gda.pl Manu Rouat emmanuel.rouat@wanadoo.fr diff --git a/lib/depcomp b/lib/depcomp index 3480ce4e..094d6812 100755 --- a/lib/depcomp +++ b/lib/depcomp @@ -209,7 +209,7 @@ aix) tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. @@ -252,32 +252,9 @@ dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. + "$@" || exit $? test -z "$dashmflag" && dashmflag=-M - ( IFS=" " - case " $* " in - *" --mode=compile "*) # this is libtool, let us make it quiet - for arg - do # cycle over the arguments - case "$arg" in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi + "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' @@ -295,33 +272,28 @@ dashXmstdout) ;; makedepend) + "$@" || exit $? # X makedepend - ( - shift - cleared=no - for arg in "$@"; do - case $cleared in no) - set ""; shift - cleared=yes - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift;; - -*) - ;; - *) - set fnord "$@" "$arg"; shift;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + -*) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' @@ -336,33 +308,10 @@ cpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. - ( IFS=" " - case " $* " in - *" --mode=compile "*) - for arg - do # cycle over the arguments - case $arg in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - "$@" -E | + "$@" || exit $? + "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" @@ -374,47 +323,25 @@ msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. - ( IFS=" " - case " $* " in - *" --mode=compile "*) - for arg - do # cycle over the arguments - case $arg in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; - *) + *) set fnord "$@" "$arg" shift shift ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" diff --git a/tests/Makefile.am b/tests/Makefile.am index 4f8c4b8d..54685aaa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -270,6 +270,7 @@ pr287.test \ pr300-lib.test \ pr300-ltlib.test \ pr300-prog.test \ +pr307.test \ prefix.test \ primary.test \ primary2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index e6b58bb4..612defce 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -354,6 +354,7 @@ pr287.test \ pr300-lib.test \ pr300-ltlib.test \ pr300-prog.test \ +pr307.test \ prefix.test \ primary.test \ primary2.test \ diff --git a/tests/pr307.test b/tests/pr307.test new file mode 100755 index 00000000..cab6dd3b --- /dev/null +++ b/tests/pr307.test @@ -0,0 +1,49 @@ +#! /bin/sh + +# Test for PR 307: depcomp with depmode=dashmstdout libtool race condition +# Report from Laurent Morichetti. +# (Also exercises check_LTLIBRARIES.) + +required='libtoolize gcc' +. $srcdir/defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_OUTPUT +END + +cat > Makefile.am << 'END' +check_LTLIBRARIES = librace.la +librace_la_SOURCES = a.c b.c c.c d.c e.c f.c g.c h.c +END + +for i in a b c d e f g h; do + echo "int $i() { return 0; }" > $i.c +done + +set -e + +libtoolize --force +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +# Sanity check: make sure the variable we are attempting to force +# is used by configure +grep am_cv_CC_dependencies_compiler_type configure + +./configure am_cv_CC_dependencies_compiler_type=dashmstdout +$MAKE +test -f librace.la && exit 1 +$MAKE check + +# The failure we check usually occurs during the above build, +# with an output such as +# +# mv -f .libs/f.lo f.lo +# mv: cannot stat `.libs/f.lo': No such file or directory +# +# (This may happen on `f' or on some other files.) + +test -f librace.la -- 2.43.5