From: Gordon Matzigkeit Date: Sun, 20 Jul 1997 05:03:16 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release-1-0b~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef0f6f6861411335447ac086a568c3fe0cc14bdd;p=thirdparty%2Flibtool.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index afcf774fc..6649b031f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +Sat Jul 19 21:54:33 1997 Gordon Matzigkeit + + * ltconfig.in (pipe_works): Check to make sure our guessed + global_symbol_pipe actually works. + + * ltmain.sh.in (link): Revert change from Kenneth Albanowski. The + wrapper scripts are more reliable when they just use the argv[0] + value. Generally, when the argv[0] method doesn't work, the user + is trying to do something weird with an uninstalled binary, and + should try a different approach. + + * ltconfig.in, ltmain.sh.in (CC): Always use `$CC' instead of + `$cc'. This fixes a FreeBSD bug. Reported by Chuck Robey, and + others. + +Mon Jul 14 22:26:15 1997 Gordon Matzigkeit + + * ltmain.sh.in (link): In wrapper scripts, hardcode the current + directory to prevent phony argv[0] values from screwing up our + program. From Kenneth Albanowski. + +Sun Jul 13 19:14:32 1997 Gordon Matzigkeit + + * Makefile.am (demo_distfiles): Add demo/dlmain.c to the + distribution. + Sat Jul 12 10:07:28 1997 Gordon Matzigkeit * demo/Makefile.am: Add helldl, made from dlmain.c, to demostrate diff --git a/Makefile.am b/Makefile.am index 81641895f..92f99ea19 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ MAINTAINERCLEANFILES = ltconfig ltmain.sh demo_distfiles = demo/Makefile.in demo/Makefile.am demo/README \ demo/acinclude.m4 demo/aclocal.m4 \ demo/configure demo/configure.in demo/foo.c demo/foo.h \ - demo/hello.c demo/main.c demo/run.test + demo/dlmain.c demo/hello.c demo/main.c demo/run.test # These are required by libtoolize. pkgdata_SCRIPTS = config.guess config.sub ltconfig diff --git a/TODO b/TODO index 2239f42c3..759067fe9 100644 --- a/TODO +++ b/TODO @@ -13,25 +13,8 @@ fixed in GCC. * We could use libtool object convenience libraries that resolve symbols to be included in a libtool archive. -* Delete dlname mode, and integrate DLD support. We need a way for -different major versions of the same .la to coexist. This also -involves writing a better uninstall mode, so that nothing breaks. - -Semantics: - -# Just link a library normally. -./libtool gcc -o testld testld.o libhello.la -lm - -# Again, link normally. -./libtool gcc -o testld -export-dynamic testld.o libhello.la -lm - -# This time, preload the symbols from the specified library (or -# object), as well as normal linking. -./libtool gcc -o testld -export-dynamic testld.o -dlopen libhello.la -lm -dlfiles="$dlfiles libhello.la" - -This defines an array called `dld_preloaded_symbols', that can be used -to lookup symbols already present in the running executable. +* Add a flag to make sure at least a null dld_preloaded_symbols is +generated. * Implement full multi-language support. Currently, this is only for C++, but there are beginnings of this in the manual (Other Languages). diff --git a/demo/Makefile.am b/demo/Makefile.am index d67384203..d7b8c00f4 100644 --- a/demo/Makefile.am +++ b/demo/Makefile.am @@ -1,4 +1,8 @@ # A brief demonstration of using Automake with Libtool. -*-Makefile-*- +# +# NOTE: Don't forget that in the libtool distribution, files in this +# directory are distributed by the demo_distfiles variable in the top +# level Makefile. AUTOMAKE_OPTIONS = foreign EXTRA_DIST = $(TESTS) acinclude.m4 @@ -36,10 +40,26 @@ $(srcdir)/acinclude.m4: rm -f $(srcdir)/acinclude.m4 ln -s ../libtool.m4 $(srcdir)/acinclude.m4 +# Don't build helldl on unsupported platforms. +helldl: $(helldl_OBJECTS) $(helldl_DEPENDENCIES) + @rm -f helldl helldlT + @eval "`egrep '^global_symbol_pipe=' libtool`"; \ + if test -z "$$global_symbol_pipe"; then \ + echo 'creating helldl (-dlopen is unsupported)'; \ + echo "#! /bin/sh" > helldlT; \ + echo "echo '-dlopen is unsupported'" >> helldlT; \ + chmod +x helldlT; \ + mv -f helldlT helldl; \ + else \ + echo '$(LINK) $(helldl_LDFLAGS) $(helldl_OBJECTS) $(helldl_LDADD) $(LIBS)'; \ + $(LINK) $(helldl_LDFLAGS) $(helldl_OBJECTS) $(helldl_LDADD) $(LIBS); \ + fi + # Test programs to see what gets hardcoded. .PHONY: hardcode hardcode: $(hardcode_tests) hc-direct: $(hell_OBJECTS) $(hell_DEPENDENCIES) + @rm -f hc-direct @shlib=./.libs/libhello.a; \ eval "`egrep '^library_names' libhello.la`"; \ for lib in $$library_names; do \ @@ -49,9 +69,11 @@ hc-direct: $(hell_OBJECTS) $(hell_DEPENDENCIES) eval "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS)" hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES) + @rm -f hc-minusL $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./.libs -lhello $(LIBS) hc-libpath: $(hell_OBJECTS) $(hell_DEPENDENCIES) + @rm -f hc-libpath @echo "You may ignore any linking errors from the following command:" @eval `egrep -e '^shlibpath_var=' ./libtool`; \ echo "$$shlibpath_var=./.libs $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) || echo unsupported > $@"; \ diff --git a/demo/dlmain.c b/demo/dlmain.c index d61ffb976..307796249 100644 --- a/demo/dlmain.c +++ b/demo/dlmain.c @@ -37,7 +37,7 @@ main (int argc, char **argv) int (*phello)() = 0; int *pnothing = 0; - printf ("Welcome to dynamic GNU Hell!\n"); + printf ("Welcome to GNU Hell **dynamically**!\n"); s = dld_preloaded_symbols; while (s->name) @@ -67,15 +67,21 @@ main (int argc, char **argv) return 1; } else - fprintf (stderr, "did not find the `foo' function\n"); + { + fprintf (stderr, "did not find the `foo' function\n"); + return 2; + } if (phello) { if ((*phello) () != HELLO_RET) - return 2; + return 3; } else - fprintf (stderr, "did not find the `hello' function\n"); + { + fprintf (stderr, "did not find the `hello' function\n"); + return 4; + } return 0; } diff --git a/libtool.m4 b/libtool.m4 index e449e9a7f..54b0225cb 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -100,7 +100,7 @@ AC_CACHE_VAL(ac_cv_path_LD, # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU ld|with BFD)' > /dev/null; then + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" = yes && break else test "$with_gnu_ld" != yes && break @@ -124,7 +124,7 @@ AM_PROG_LD_GNU AC_DEFUN(AM_PROG_LD_GNU, [AC_CACHE_CHECK([whether we are using GNU ld], ac_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 /dev/null; then +if $LD -v 2>&1 /dev/null; then ac_cv_prog_gnu_ld=yes else ac_cv_prog_gnu_ld=no diff --git a/ltconfig.in b/ltconfig.in index 19b5ba3d8..d5e53614c 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -1,7 +1,7 @@ #! /bin/sh # ltconfig - Create a system-specific libtool. -# When updating this script, search for LINENUM and fix line number refs. +# When updating this script, search for LINENO and fix line number refs. # @configure_input@ # Copyright (C) 1996, 1997, Free Software Foundation, Inc. # Gordon Matzigkeit , 1996 @@ -35,6 +35,7 @@ PROGRAM=ltconfig PACKAGE=@PACKAGE@ VERSION=@VERSION@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' rm="rm -f" help="Try \`$progname --help' for more information." @@ -211,6 +212,7 @@ if test -z "$srcdir"; then test "$srcdir" = "$ltmain" && srcdir=. fi +trap "$rm conftest*; exit 1" 1 2 15 if test "$verify_host" = yes; then # Check for config.guess and config.sub. ac_aux_dir= @@ -368,14 +370,13 @@ if test "$with_gcc" != yes || test -z "$CC"; then with_gcc=no echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 - trap "$rm conftest.c; exit 1" 1 2 15 $rm conftest.c cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then with_gcc=yes fi @@ -533,7 +534,7 @@ if test "$with_gnu_ld" != yes || test -z "$LD"; then # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - if "$LD" -v 2>&1 < /dev/null | egrep '(GNU ld|with BFD)' > /dev/null; then + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" = yes && break else test "$with_gnu_ld" != yes && break @@ -599,7 +600,7 @@ if test "$with_gnu_ld" = yes; then esac if test "$ld_shlibs" = yes; then - archive_cmds='$cc -shared ${wl}-soname $wl$soname -o $lib$libobjs$deplibs' + archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs$deplibs' hardcode_libdir_flag_spec='${wl}-rpath $wl$libdir' export_dynamic_flag='${wl}-export-dynamic' fi @@ -616,7 +617,7 @@ else aix4*) allow_undefined_flag=unsupported - archive_cmds='$NM$libobjs | $global_symbol_pipe | sed \"s/.* //\" > $lib.exp;$cc -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry$deplibs;$AR cru $lib $objdir/$soname' + archive_cmds='$NM$libobjs | $global_symbol_pipe | sed \"s/.* //\" > $lib.exp;$CC -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry$deplibs;$AR cru $lib $objdir/$soname' hardcode_direct=yes hardcode_minus_L=yes ;; @@ -738,27 +739,94 @@ fi # Check for command to grab the raw symbol name followed by C symbol from nm. echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 -global_symbol_pipe= -# WARNING: these filters need to be compatible with GNU nm, so they should -# accept at least [BDT]. -case "$host_os" in -aix*) - global_symbol_pipe="sed '/^.* [BCDT] [^.]/!d; s/^.* [BCDT] \(.*\)$/\1 \1/'" - ;; -# These platforms may need to strip leading underscores from C symbols. -linux-gnuoldld*) ;; +# This is a sane default that works on at least a few old systems. +# [It comes from Ultrix. What could be older than Ultrix?!! ;)] +global_symbol_pipe="sed '/^.* [BCDEGRST] /!d; s/^.* [BCDEGRST] \(.*\)$/\1 \1/'" -linux*) - global_symbol_pipe="sed '/^.* [BCDT] /!d; s/^.* [BCDT] \(.*\)$/\1 \1/'" - ;; -esac +# Take a first stab at what the pipe should be. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + # We're using GNU nm. + global_symbol_pipe="sed '/^.* [BCDGIST] /!d; s/^.* [BCDGIST] \(.*\)$/\1 \1/'" +else + # It's the system nm. + case "$host_os" in + aix*) + # Delete symbols that begin with a dot. + global_symbol_pipe="sed '/^.* [BCDT] [^.]/!d; s/^.* [BCDT] \(.*\)$/\1 \1/'" + ;; + solaris2*) + global_symbol_pipe="sed '/^.* [BDT] /!d; s/^.* [BDT] \(.*\)$/\1 \1/'" + ;; + esac +fi -if test -z "$global_symbol_pipe"; then - echo "$ac_t"no +# Check to see that the pipe works correctly. +pipe_works=no +rm -f conftest* +cat > conftest.c <&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then + # Now try to grab the symbols. + if { echo "$progname:752: eval \"$NM conftest.o | $global_symbol_pipe > conftest.nm\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > conftest.nm 2>&5"; } && test -s conftest.nm; then + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' conftest.nm >/dev/null; then + if egrep ' nm_test_func$' conftest.nm >/dev/null; then + # Now generate the symbol file. + sed 's/^.* \(.*\)$/extern char \1;/' < conftest.nm > conftest.c + cat <<\EOF >> conftest.c +#if defined (__STDC__) && __STDC__ +# define __ptr_t void * +#else +# define __ptr_t char * +#endif + +/* The mapping between symbol names and symbols. */ +struct { + char *name; + __ptr_t address; +} +dld_preloaded_symbols[] = +{ +EOF + sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < conftest.nm >> conftest.c + cat <<\EOF >> conftest.c + {0}, +}; +EOF + # Now try linking the two files. + mv conftest.o conftestm.o + save_LIBS="$LIBS" + LIBS='conftestm.o' + if { (eval echo configure:807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + fi + else + echo "cannot find nm_test_func in conftest.nm" >&5 + fi + else + echo "cannot find nm_test_var in conftest.nm" >&5 + fi else - echo "$ac_t"yes + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 fi +rm -f conftest* + +# Don't use the global_symbol_pipe unless it works. +echo "$ac_t$pipe_works" 1>&6 +test "$pipe_works" = yes || global_symbol_pipe= # Check hardcoding attributes. echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 diff --git a/ltmain.sh.in b/ltmain.sh.in index 27b243336..eaac8d540 100644 --- a/ltmain.sh.in +++ b/ltmain.sh.in @@ -284,11 +284,11 @@ if test -z "$show_help"; then link) progname="$progname: link" # Go through the arguments, transforming them on the way. - cc="$nonopt" - args="$cc" + CC="$nonopt" + args="$CC" allow_undefined=no - compile_command="$cc" - finalize_command="$cc" + compile_command="$CC" + finalize_command="$CC" compile_shlibpath= finalize_shlibpath= deplibs= @@ -406,7 +406,7 @@ if test -z "$show_help"; then continue ;; - -*) cc="$cc $arg" ;; # Some other compiler flag. + -*) CC="$CC $arg" ;; # Some other compiler flag. *.o) # A standard object. @@ -1000,7 +1000,7 @@ dld_preloaded_symbols[] = EOF if test -f "$nlist"; then - sed 's/^\(.*\) \(.*\)$/ {"\1", \&\1},/' < $nlist >> $dlsyms + sed 's/^\(.*\) \(.*\)$/ {"\1", \&\2},/' < $nlist >> $dlsyms fi cat <<\EOF >> $dlsyms @@ -1133,7 +1133,6 @@ else # Try to get the absolute directory name. absdir=\`cd "\$thisdir" && pwd\` test -n "\$absdir" && thisdir="\$absdir" - progdir="\$thisdir/$objdir" program="$output" diff --git a/tests/demo-exec.test b/tests/demo-exec.test index 286e8c5c4..0babad1c9 100755 --- a/tests/demo-exec.test +++ b/tests/demo-exec.test @@ -31,7 +31,7 @@ else exit 1 fi -if ../demo/helldl | grep 'Welcome to GNU Hell'; then : +if ../demo/helldl | egrep -e '(Welcome to GNU Hell|unsupported)'; then : else echo "$0: cannot execute ../demo/helldl" 1>&2 exit 1 diff --git a/tests/demo-inst.test b/tests/demo-inst.test index 57e05517d..281939f4e 100755 --- a/tests/demo-inst.test +++ b/tests/demo-inst.test @@ -43,7 +43,7 @@ else status=1 fi -if $prefix/bin/helldl | grep 'Welcome to GNU Hell'; then : +if $prefix/bin/helldl | egrep -e '(Welcome to GNU Hell|unsupported)'; then : else echo "$0: cannot execute $prefix/bin/helldl" 1>&2