libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libtool locking issue (was: [patch 00/19] @patch@ Queue)


From: Ralf Wildenhues
Subject: Re: libtool locking issue (was: [patch 00/19] @patch@ Queue)
Date: Mon, 10 Oct 2005 17:37:31 +0200
User-agent: Mutt/1.5.11

* Ralf Wildenhues wrote on Mon, Oct 10, 2005 at 05:10:21PM CEST:
> 
> One example of it goes as follows: User uses
>   LIBTOOL = /usr/bin/libtool 
> in his Makefile.  That `libtool' has 
>   need_locks=yes
> Now, the build tree is below a different mount point than /usr.
> 
> This code in ltmain:

> |    until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
> |      func_echo "Waiting for $lockfile to be removed"
> |      sleep 2
> |    done
> |  elif test "$need_locks" = warn; then
> 
> will then deadlock.

Quite some time ago, I started a test for this.  Since compilers without
`-c -o' support were hard to come by before Peter Ekberg joined in, :-))
I started out building a simulator, a script that will not allow both
options.  It's not perfect yet, in that it emulates all the possible
failures of those compilers (there are different incarnations with
subtly different behavior wrt. subdirs, IIRC).

Maybe it helps, so here it is, for reference, cheaply forward-ported to
current CVS HEAD.  It needs fixing wrt. the LT_AT_BOOTSTRAP arguments
given.

Cheers,
Ralf

Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.172
diff -u -r1.172 Makefile.am
--- Makefile.am 7 Oct 2005 08:52:10 -0000       1.172
+++ Makefile.am 10 Oct 2005 15:35:07 -0000
@@ -478,6 +478,7 @@
                  tests/link-order.at \
                  tests/convenience.at \
                  tests/early-libtool.at \
+                 tests/lock.at \
                  tests/template.at
 
 EXTRA_DIST     += $(TESTSUITE) $(TESTSUITE_AT) tests/package.m4
Index: tests/testsuite.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/testsuite.at,v
retrieving revision 1.25
diff -u -r1.25 testsuite.at
--- tests/testsuite.at  7 Oct 2005 08:52:10 -0000       1.25
+++ tests/testsuite.at  10 Oct 2005 15:35:07 -0000
@@ -143,6 +143,8 @@
 m4_include([link-order.at])
 # Ensure our continued support for old interfaces.
 m4_include([old-m4-iface.at])
+# locking
+m4_include([lock.at])
 # Torturing subdir-objects builds
 m4_include([am-subdir.at])
 # standalone libltdl compilation
--- /dev/null   2005-08-03 12:45:51.659987528 +0200
+++ tests/lock.at       2005-10-10 17:29:45.000000000 +0200
@@ -0,0 +1,222 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Test libtool locking, simulate compiler that does not understand `-c -o'.
+
+# TODO: --disable-libtool-lock
+
+AT_SETUP([locking test])
+
+eval `$LIBTOOL --config | $EGREP '^(SED|Xsed)='`
+
+mkdir bin
+AT_DATA([bin/wrapper],
+[[#!/bin/sh
+realcc=`echo "$0" | sed 's%.*/%%'`
+eat=
+errmsg=${wrapper_c_o_fatal+", bailing out"}
+for arg0
+do
+  case $arg0 in
+  -c)
+    for arg
+    do
+      case $eat in
+      yes) eat=no;;
+      *)
+       case $1 in
+       -o)
+         eat=1
+         case $2 in
+         *.o | *.obj)
+           echo "bogus option: -o $2$errmsg." >&2
+           test -n "$wrapper_c_o_fatal" && exit 1
+           ;;
+         *)
+           set x "$@" -o "$2"; 
+           shift
+           ;;
+         esac
+         ;;
+       *)
+         set x "$@" "$1"
+         shift
+         ;;
+       esac
+      esac
+      shift
+    done
+    break
+    ;;
+  esac
+done
+exec "$realcc" ${1+"$@"}
+exit 1
+]])
+
+chmod +x bin/wrapper
+ln -s wrapper bin/echo
+AT_CHECK([bin/echo a -b -c bla -o foo bar -baz], 0, ignore)
+AT_CHECK([bin/echo a -b -c bla -o foo.o bar -baz], 0, ignore, ignore)
+AT_CHECK([bin/echo a -b -c bla -o foo.obj bar -baz], 0, ignore, ignore)
+AT_CHECK([bin/echo a -b bla -o foo.obj bar -baz], 0, ignore)
+AT_CHECK([wrapper_c_o_fatal=: bin/echo a -b -c bla -o foo bar -baz], 0, ignore)
+AT_CHECK([wrapper_c_o_fatal=: bin/echo a -b -c bla -o foo.o bar -baz], 1, 
ignore, ignore)
+AT_CHECK([wrapper_c_o_fatal=: bin/echo a -b -c bla -o foo.obj bar -baz], 1, 
ignore, ignore)
+AT_CHECK([wrapper_c_o_fatal=: bin/echo a -b bla -o foo.obj bar -baz], 0, 
ignore)
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# KEEP THIS IN SYNC WITH THE VERSION FROM LIBTOOL.m4
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+_LT_CC_BASENAME($CC)
+CC_base=$cc_basename
+ln -s wrapper bin/$cc_basename 
+
+
+AT_DATA([[configure.ac]],
+[[AC_INIT([subdir-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
+AC_CONFIG_HEADERS([config.h:config-h.in])
+AM_INIT_AUTOMAKE([subdir-objects foreign])
+LT_INIT([win32-dll])
+AM_PROG_CC_C_O
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([[Makefile.am]],
+[[ACLOCAL_AMFLAGS = -I m4
+AM_CPPFLAGS    = -I$(top_srcdir)/../..
+
+lib_LTLIBRARIES                = subdir/libsub.la
+subdir_libsub_la_SOURCES= subdir/sub.c
+
+bin_PROGRAMS           = subdir/subdemo
+subdir_subdemo_SOURCES = subdir/main.c
+subdir_subdemo_LDADD   = subdir/libsub.la
+]])
+
+test -d subdir || { rm -f subdir && mkdir subdir; }
+
+AT_DATA([[subdir/main.c]],
+[[#include <stdio.h>
+
+extern void sub (void);
+
+int main (int argc, char **argv)
+{
+  printf ("Welcome to GNU Libtool subdir-objects test!\n");
+  sub();
+  return 0;
+}
+]])
+
+AT_DATA([[subdir/sub.c]],
+[[#include <stdio.h>
+void sub (void) { printf ("** This is libsub **\n"); }
+]])
+
+AT_DATA(expout,
+[[Welcome to GNU Libtool subdir-objects test!
+** This is libsub **
+]])
+
+LT_AT_BOOTSTRAP([CC=`pwd`/bin/$cc_basename])
+LT_AT_MAKE
+LT_AT_EXEC_CHECK([subdir/subdemo], 0, expout)
+LT_AT_MAKE([clean])
+
+wrapper_c_o_fatal=:
+export wrapper_c_o_fatal
+LT_AT_CONFIGURE([CC=`pwd`/bin/$cc_basename])
+LT_AT_MAKE
+LT_AT_EXEC_CHECK([subdir/subdemo], 0, expout)
+LT_AT_MAKE([distclean])
+
+######################
+# now without Automake
+sed '/^AM/d' configure.ac >configure.tmp && mv -f configure.tmp configure.ac
+AT_DATA([Makefile.in],
+[[srcdir = @srcdir@
+VPATH = @srcdir@
+libdir = @libdir@
+top_builddir = .
+DEFAULT_INCLUDES = -I. -I$(srcdir)
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+DEFS = @DEFS@
+EXEEXT = @EXEEXT@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+OBJEXT = @OBJEXT@
+
+subdir/subdemo$(EXEEXT): subdir/main.$(OBJEXT) subdir/libsub.la
+       @rm -f subdir/subdemo$(EXEEXT)
+       $(LINK) subdir/main.$(OBJEXT)  subdir/libsub.la $(LIBS)
+
+subdir/libsub.la: subdir/sub.lo
+       $(LINK) -rpath $(libdir) subdir/sub.lo $(LIBS)
+
+subdir/main.$(OBJEXT): subdir/main.c
+       $(COMPILE) -c subdir/main.c
+       mv -f main.$(OBJEXT) subdir/main.$(OBJEXT)
+
+subdir/sub.lo: subdir/sub.c
+       $(LTCOMPILE) -c -o subdir/sub.lo subdir/sub.c
+clean:
+       -rm -rf .libs _libs subdir/.libs subdir/_libs
+       -rm -f *.lo subdir/*.lo subdir/*.$(OBJEXT) subdir/subdemo$(EXEEXT) 
subdir/libsub.la
+]])
+
+rm -rf Makefile.am ltmain.sh configure autom4te.cache
+LT_AT_BOOTSTRAP([CC=`pwd`/bin/$cc_basename])
+LT_AT_MAKE
+LT_AT_EXEC_CHECK([subdir/subdemo], 0, expout)
+LT_AT_MAKE([clean])
+
+wrapper_c_o_fatal=:
+export wrapper_c_o_fatal
+LT_AT_CONFIGURE([CC=`pwd`/bin/$cc_basename])
+LT_AT_MAKE
+LT_AT_EXEC_CHECK([subdir/subdemo], 0, expout)
+LT_AT_MAKE([clean])
+
+AT_CLEANUP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]