]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltconfig.in (need_locks): if neither `-c -o' nor hard links are
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Wed, 4 Nov 1998 05:50:33 +0000 (05:50 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Wed, 4 Nov 1998 05:50:33 +0000 (05:50 +0000)
  available, fallback to not so safe mechanism, by setting
need_locks to warn
* ltmain.in (need_locks): when need_locks is set to warn, use the
lockfile to try to fail in case of incorrect concurrent builds

ChangeLog
ltconfig.in
ltmain.in

index c438a1d3d04c9479a9e4f7837522f7b0c8b1aa97..5be397b9e369737553f82e959d279f77f2d92b72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 1998-11-04  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
+       * ltconfig.in (need_locks): if neither `-c -o' nor hard links are
+       available, fallback to not so safe mechanism, by setting
+       need_locks to warn
+       * ltmain.in (need_locks): when need_locks is set to warn, use the
+       lockfile to try to fail in case of incorrect concurrent builds
+
        * THANKS: Added Eric Estievenart
 
 1998-11-04  Eric Estievenart  <eric@via.ecp.fr>
index affa7912432f815c8706be112de9656f650051c5..4ddc33e3dd5173088d508ed7d7db79dd1ff53c1e 100755 (executable)
@@ -655,23 +655,14 @@ if test "$compiler_c_o" = no && test "$need_locks" != no; then
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   echo "$ac_t$hard_links" 1>&6
   $rm conftest*
+  if test "$hard_links" = no; then
+    echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe"
+    need_locks=warn
+  fi
 else
   need_locks=no
 fi
 
-# Abort if we need locks and they don't work and the user didn't disable them
-
-if test "$hard_links" = no; then
-  echo "*** Warning, your platform support neither -c and -o with your compiler"
-  echo "*** and doesn't provide working hard links to do file locking."
-  echo "*** You can use ltconfig --disable-lock or configure --disable-libtool-lock"
-  echo "*** but you should never try to do parallel compilation (make -j n)"
-  echo "*** unless the package maintainer told you that you could."
-  echo "***             You should report this bug to <bug-libtool@gnu.org>"
-  exit 1
-fi
-
-
 # Check for any special shared library compilation flags.
 if test -n "$special_shlib_compile_flags"; then
   echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
index 730481217bc4dd44ccb50fd078bf6753c5db50f3..f5f9de4961dcbfa56cd62312d5e28f4ae7a9ab58 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -362,27 +362,50 @@ if test -z "$show_help"; then
 
     # Delete any leftover library objects.
     if test "$build_old_libs" = yes; then
-      $run $rm $obj $libobj
-      trap "$run $rm $obj $libobj; exit 1" 1 2 15
+      removelist="$obj $libobj $lockfile"
     else
-      $run $rm $libobj
-      trap "$run $rm $libobj; exit 1" 1 2 15
+      removelist="$libobj $lockfile"
     fi
 
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit 1" 1 2 15
+
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
     if test "$compiler_c_o" = no; then
       output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.o
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit 1" 1 2 15
+    else
+      need_locks=no
+      lockfile=
     fi
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
     if test "$need_locks" = yes; then
-      until ln "$0" "$output_obj.lock" 2>/dev/null; do
-        $show "Waiting for lock on $output_obj to be removed"
+      until ln "$0" "$lockfile" 2>/dev/null; do
+        $show "Waiting for $lockfile to be removed"
         sleep 2
       done
-      trap "rm $output_obj.lock; exit 1" 1 2 15
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+      echo $srcfile > "$lockfile"
     fi
  
     # Only build a PIC object if we are building libtool libraries.
@@ -400,21 +423,51 @@ if test -z "$show_help"; then
       $show "$command"
       if $run eval "$command"; then :
       else
-        test -n "$output_obj" && $run $rm $output_obj
+        test -n "$output_obj" && $run $rm $removelist
         exit 1
       fi
 
+      if test "$need_locks" = warn &&
+        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+       echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+
       # Just move the object if needed, then go on to compile the next one
-      if test "$compiler_c_o" = no; then 
+      if test "$compiler_c_o" = no && test x"$output_obj" != x"$libobj"; then 
         $show "$mv $output_obj $libobj"
-        $run $mv $output_obj $libobj || exit $?
+        if $run $mv $output_obj $libobj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
       fi
 
       # If we have no pic_flag, then copy the object into place and finish.
       if test -z "$pic_flag"; then
         $show "$LN_S $libobj $obj"
-        $run $LN_S $libobj $obj
-        exit $?
+        if $run $LN_S $libobj $obj; then
+         exit 0
+       else
+          error=$?
+         $run $rm $removelist
+         exit $error
+       fi
       fi
 
       # Allow error messages only from the first compilation.
@@ -434,20 +487,45 @@ if test -z "$show_help"; then
       $show "$command"
       if $run eval "$command"; then :
       else
-        $run $rm $output_obj $libobj
+        $run $rm $removelist
         exit 1
       fi
 
+      if test "$need_locks" = warn &&
+        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+       echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+
       # Just move the object if needed
-      if test "$compiler_c_o" = no; then 
+      if test "$compiler_c_o" = no && test x"$output_obj" != x"$obj"; then 
         $show "$mv $output_obj $obj"
-        $run $mv $output_obj $obj || exit $?
+        if $run $mv $output_obj $obj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
       fi
     fi
 
     # Unlock the critical section if it was locked
-    if test "$need_locks" = yes; then
-      rm "$output_obj.lock"
+    if test "$need_locks" != no; then
+      rm -f "$lockfile"
     fi
 
     # Create an invalid libtool object if no PIC, so that we do not