diff --git a/ChangeLog b/ChangeLog index e71142de..17bb7984 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,88 @@ +Mon Jan 19 10:03:03 1998 Gordon Matzigkeit + + * ltconfig.in (old_postuninstall_cmds): Reorder so that chmod + happens after ranlib. From Markus F.X.J. Oberhumer. + + * ltmain.in (mode): Added `gcc*' and `*-gcc*' to the patterns that + recognize compilers. From Pieter Schoenmakers. + (link): Recognize `.a' files again. Suggested by Pieter + Schoenmakers. + +Sun Jan 18 15:16:34 1998 Gordon Matzigkeit + + * ltmain.in (compile): Recognize `.asm' extension, for use with + the nasm assembler. From Markus F.X.J. Oberhumer. + +Mon Jan 12 14:01:06 1998 Gordon Matzigkeit + + * ltconfig.in (runpath_var): Use instead of + `hardcode_runpath_var'. + +Sun Jan 11 11:55:32 1998 Gordon Matzigkeit + + * ltmain.in (finish): Add a better --finish message. Suggested by + Kenneth Albanowski. + + * ltconfig.in, ltmain.in: Fix a few typos. + +Sat Jan 3 10:03:41 1998 Gordon Matzigkeit + + * ltmain.in (link): Quote the definition of $echo in the wrapper + script. + + * ltconfig.in (export_dynamic_flag_spec): Use `--export-dynamic' + instead of `-export-dynamic', which is not accepted by all GNU + ld's. From Eiichi Takamori. + + * ltmain.in (install): Don't print silly `library stripping' + warnings. Reported by François Pinard. + +Fri Dec 19 08:24:32 1997 Gordon Matzigkeit + + * ltmain.in: Don't forget to quote the CDPATH substitution. From + Tor Lillqvist. + +Thu Dec 18 07:10:27 1997 Gordon Matzigkeit + + * ltconfig.in, ltmain.in (CDPATH): Unset this environment variable + so that HP-UX shells, at least, don't print out the directory name + after a `cd' command. From Tor Lillqvist. + +Wed Dec 10 23:00:12 1997 Gordon Matzigkeit + + * demo/Makefile.am (hardcode): Change a bunch of references to + `$(LIBS)' to `-lm', since we no longer put -lm in LIBS. + + * demo/configure.in: Delete the test for libm, since it is + standard on every system. + + * demo/Makefile.am (libhello_la_LDFLAGS): Change to include -lm, + in accordance with new inter-library dependency code. + + * ltmain.in (dependency_libs): Added to help people link programs + without having to explicitly specify inter-library dependencies. + + * ltconfig.in (COLLECT_NAMES): Oops... I forgot to apply the AIX 3 + restriction to the generated libtool script. Reported by Stefan + Westerfeld. + +Fri Dec 5 00:21:07 1997 Gordon Matzigkeit + + * ltconfig.in (thisdir): Quote $echo in the generated libtool + script for HP-UX. From Markus F.X.J. Oberhumer. + + * ltmain.in (link): Recognize the `.s' suffix. From Markus + F.X.J. Oberhumer. + + * ltconfig.in (link_static_flag): Don't quote ${wl} on HP-UX + because link_static_flag is never evaled. From Eric Backus. + Mon Dec 1 00:50:37 1997 Gordon Matzigkeit + * demo/Makefile.am (helldl_DEPENDENCIES): Add `libhello.la' to our + dependencies so that parallel builds work correctly. From Jim + Meyering. + * Makefile.am ($(srcdir)/ltconfig, $(srcdir)/ltmain.sh): Rewrite these rules so that they are parallelizable. Reported by Jim Meyering. diff --git a/NEWS b/NEWS index 53537d91..4f0a1ab1 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ NEWS - list of user-visible changes between releases of GNU Libtool +New: +* Inter-library dependencies are automatically handled when linking + against a `.la' file. This, along with `-no-undefined', should + prevent many accidental libtool misuses. + New in 1.0h - 1997-12-01, Gordon Matzigkeit: * A fix for an insidious bug in the quoting code, which broke everything on almost all platforms. diff --git a/TODO b/TODO index ba6aa587..8c1faa68 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,52 @@ For next public release: ************************ -* Document `execute' mode, and the experimental nature of -dlopen and --dlpreopen. +* Get rid of the sections that try to change behaviour for GNU ld. We +really should make our shared library support just depend on the +compiler type. -Franc,ois Pinard about debugging: +* Explain why we have the `-lm' in: +libhello_la_LDFLAGS = -version-info 3:12:1 -lm + +* Explain why we don't allow `-o SOMEFILE' with compile mode. + +* Alexandre Oliva suggests that we hardcode paths into libraries, as +well as binaries: `... -Wl,-soname -Wl,/tmp/libtest.so.0 ...'. + +* Primoz Peterlin -Aicrit: + +> A very first impression after compiling the new recode on HP-UX 9.05 +> (with gcc and various other gnuities). I encountered the following +> problem [...] +> ../libtool: /./ltmain.sh: not found + +This is a bug in HP-UX sed. The correct solution is to obtain a sed +update from your HP-UX vendor, or to install GNU sed. The sed +distributed with HP-UX is so horribly broken that it is impossible to +change libtool so that it works by using it. + +* From Kenneth Albanowski: + +At the very least, this message should be tailored for the OS and +libraries -- if Linux's ld requires explicit -rpath arguments (instead of +treating all -L paths as -rpaths) then this message should mention it, as +well as the full options. Something like this would seem ideal: + + Libraries have been installed to /usr/lib, /usr/local/lib, /foo/bar + and /foo/baz. To link against libraries in /foo/bar and /foo/baz, users + may have to: + - Use the -L/foo/bar and -L/foo/baz linker flags, and + - Add /foo/bar:/foo/baz to their LD_LIBRARY_PATH environment + variable during execution, or + - Add /foo/bar:/foo/baz to their LD_RUN_PATH environment + variable during linking, or + - Use the -rpath /foo/bar and -rpath /foo/baz linker flags, or + - Have the system administrator add /foo/bar and /foo/bz to + /etc/ld.so.conf + [See the ld.so(8) manual page and any operating system documentation + about shared libraries for more information.] + +* Franc,ois Pinard about debugging: ``Another thing I'm curious to experiment is how will `gdb' perform with shared libraries. There are a few notes in the manual about @@ -45,13 +87,6 @@ maintainers add this kind of note to their package documentation. The biggest motivation, mentioned by Franc,ois Pinard, is to turn off double-compilation. -* Bengt Martensson says: - -"Some compilers may allow identifiers which are not legal in ANSI C, -for example dollar signs. Such symbols will not be exported. Only -symbols which are legal in ANSI C (ASCII letters, digits, and -underscore; not starting with a digit) are exported." - In the future: ************** @@ -87,7 +122,8 @@ is to have undocumented utility libraries, where only the shared version is installed. * We could use libtool object convenience libraries that resolve -symbols to be included in a libtool archive. +symbols to be included in a libtool archive. This would require some +sort of -whole-archive option, as well. * Somehow we need to make sure that static libraries never appear in $deplibs. This, will probably require that libtool discover exactly diff --git a/demo/Makefile.am b/demo/Makefile.am index b5f6cf93..859d1a56 100644 --- a/demo/Makefile.am +++ b/demo/Makefile.am @@ -13,7 +13,7 @@ CLEANFILES = $(hardcode_tests) # Build a libtool library, libhello.la for installation in libdir. lib_LTLIBRARIES = libhello.la libhello_la_SOURCES = hello.c foo.c -libhello_la_LDFLAGS = -version-info 3:12:1 +libhello_la_LDFLAGS = -version-info 3:12:1 -lm include_HEADERS = foo.h @@ -31,6 +31,7 @@ hell_debug_LDFLAGS = -static # Create a version of hell that does a preloaded dlopen. helldl_SOURCES = dlmain.c helldl_LDFLAGS = -export-dynamic -dlpreopen libhello.la +helldl: libhello.la # Unfortunately, in order to test libtool thoroughly, we need access # to its private directory. @@ -55,8 +56,8 @@ helldl: $(helldl_OBJECTS) $(helldl_DEPENDENCIES) 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); \ + echo '$(LINK) $(helldl_LDFLAGS) $(helldl_OBJECTS) $(helldl_LDADD) -lm'; \ + $(LINK) $(helldl_LDFLAGS) $(helldl_OBJECTS) $(helldl_LDADD) -lm; \ fi # Test programs to see what gets hardcoded. @@ -70,8 +71,8 @@ hc-direct: $(hell_OBJECTS) $(hell_DEPENDENCIES) for lib in $$library_names; do \ shlib="./$(objdir)/$$lib"; \ done; \ - echo "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) || echo unsupported > $@"; \ - eval "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib $(LIBS) || echo unsupported > $@" + echo "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib -lm || echo unsupported > $@"; \ + eval "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$shlib -lm || echo unsupported > $@" # We need to create an alias for $(objdir) so that this test works regardless # of $hardcode_minus_L @@ -88,8 +89,8 @@ hc-libflag: $(hell_OBJECTS) $(hell_DEPENDENCIES) echo "echo unsupported > $@"; \ echo unsupported > $@ || status="$$?"; \ else \ - echo "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L./_hclibs -lhello $(LIBS)"; \ - $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L./_hclibs -lhello $(LIBS) || status="$$?"; \ + echo "$(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L./_hclibs -lhello -lm"; \ + $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) $$flag -L./_hclibs -lhello -lm || status="$$?"; \ fi; \ echo "rm -rf _hclibs"; \ rm -rf _hclibs; \ @@ -99,9 +100,9 @@ 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=./$(objdir) $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) || echo unsupported > $@"; \ - eval "$$shlibpath_var=./$(objdir) $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) || echo unsupported > $@" + echo "$$shlibpath_var=./$(objdir) $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello -lm || echo unsupported > $@"; \ + eval "$$shlibpath_var=./$(objdir) $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello -lm || echo unsupported > $@" hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES) @rm -f hc-minusL - $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello $(LIBS) + $(CC) $(LDFLAGS) -o $@ $(hell_OBJECTS) -L./$(objdir) -lhello -lm diff --git a/demo/configure.in b/demo/configure.in index 2bd01f55..f7b80378 100644 --- a/demo/configure.in +++ b/demo/configure.in @@ -5,8 +5,5 @@ AM_INIT_AUTOMAKE(hell,1.0) AC_PROG_CC AM_PROG_LIBTOOL -dnl Check for the math library. -AC_CHECK_LIB(m, cos) - dnl Output the makefile AC_OUTPUT(Makefile) diff --git a/doc/libtool.texi b/doc/libtool.texi index d343a469..19ae86d7 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -93,6 +93,9 @@ This file documents GNU Libtool, a script that allows package developers to provide generic shared library support. This edition documents version @value{VERSION}. +@xref{Reporting bugs}, for information on how to report problems with +libtool. + @menu * Introduction:: What the heck is libtool? * Libtool paradigm:: How libtool's view of libraries is different. @@ -123,6 +126,7 @@ Using libtool * Creating object files:: Compiling object files for libraries. * Linking libraries:: Creating libraries from object files. * Linking executables:: Linking object files against libtool libraries. +* Debugging executables:: Running GDB on libtool-generated programs. * Installing libraries:: Making libraries available to users. * Installing executables:: Making programs available to users. * Static libraries:: When shared libraries are not wanted. @@ -131,6 +135,7 @@ Invoking @code{libtool} * Compile mode:: Creating library object files. * Link mode:: Generating executables and libraries. +* Execute mode:: Debugging libtool-generated programs. * Install mode:: Making libraries and executables public. * Finish mode:: Completing a library installation. * Uninstall mode:: Removing executables and libraries. @@ -166,13 +171,13 @@ Tips for interface design Dlopened modules * Building modules:: Creating dlopenable objects and libraries. -* Dlpreopening:: +* Dlpreopening:: Dlopening that works on static platforms. * Finding the dlname:: Choosing the right file to @code{dlopen(3)}. * Dlopen issues:: Unresolved problems that need your attention. Using libtool with other languages -* C++ libraries:: +* C++ libraries:: Building libraries for C++. Troubleshooting @@ -441,6 +446,7 @@ After we have built that library, we want to create a program by linking * Creating object files:: Compiling object files for libraries. * Linking libraries:: Creating libraries from object files. * Linking executables:: Linking object files against libtool libraries. +* Debugging executables:: Running GDB on libtool-generated programs. * Installing libraries:: Making libraries available to users. * Installing executables:: Making programs available to users. * Static libraries:: When shared libraries are not wanted. @@ -490,7 +496,7 @@ files are identical to ``standard'' object files. To create library object files for @file{foo.c} and @file{hello.c}, simply invoke libtool with the standard compilation command as -arguments: +arguments (@pxref{Compile mode}): @example a23$ @kbd{libtool gcc -g -O -c foo.c} @@ -503,9 +509,9 @@ a23$ @end example Note that libtool creates two object files for each invocation. The -@samp{.lo} file is a library object, and the @samp{.o} file is a standard object -file. On @samp{a23}, these files are identical, because only static -libraries are supported. +@samp{.lo} file is a library object, and the @samp{.o} file is a +standard object file. On @samp{a23}, these files are identical, because +only static libraries are supported. On shared library systems, libtool automatically inserts the PIC generation flags into the compilation command, so that the library @@ -555,7 +561,7 @@ shared libraries, libtool simply acts as a wrapper for the system Again, the libtool library name differs from the standard name (it has a @samp{.la} suffix instead of a @samp{.a} suffix). The arguments to libtool are the same ones you would use to produce an executable named -@file{libhello.la} with your compiler: +@file{libhello.la} with your compiler (@pxref{Link mode}): @example burger$ @kbd{libtool gcc -g -O -o libhello.la foo.o hello.o} @@ -658,8 +664,9 @@ burger$ Libtool's way is almost the same@footnote{However, you should never use @samp{-L} or @samp{-l} flags to link against an uninstalled libtool library. Just specify the relative path to the @samp{.la} file, such as -@file{../intl/libintl.la}. This is a design decision to eliminate -any ambiguity when linking against uninstalled shared libraries.}: +@file{../intl/libintl.la}. This is a design decision to eliminate any +ambiguity when linking against uninstalled shared libraries.} +(@pxref{Link mode}): @example a23$ @kbd{libtool gcc -g -O -o hell main.o libhello.la -lm} @@ -733,6 +740,74 @@ price of being dynamic is eight kilobytes, and the payoff is about four kilobytes. So, having a shared @file{libhello} won't be an advantage until we link it against at least a few more programs. +@node Debugging executables +@section Debugging executables + +If @file{hell} was a complicated program, you would certainly want to +test and debug it before installing it on your system. In the above +section, you saw how it the libtool wrapper script makes it possible to +run the program directly, but unfortunately, it interferes with the +debugger: + +@example +burger$ @kbd{gdb hell} +GDB is free software and you are welcome to distribute copies of it + under certain conditions; type "show copying" to see the conditions. +There is absolutely no warranty for GDB; type "show warranty" for details. +GDB 4.16 (i386-unknown-netbsd), Copyright 1996 Free Software Foundation, Inc... + +"hell": not in executable format: File format not recognized + +(gdb) @kbd{quit} +burger$ +@end example + +Sad. It doesn't work because GDB isn't doesn't know where the +executable lives. So, let's try again, by invoking GDB directly on the +executable: + +@example +burger$ @kbd{gdb @value{objdir}/hell} +trick:/home/src/libtool/demo$ gdb .libs/hell +GDB is free software and you are welcome to distribute copies of it + under certain conditions; type "show copying" to see the conditions. +There is absolutely no warranty for GDB; type "show warranty" for details. +GDB 4.16 (i386-unknown-netbsd), Copyright 1996 Free Software Foundation, Inc... +(gdb) @kbd{break main} +Breakpoint 1 at 0x8048547: file main.c, line 29. +(gdb) @kbd{run} +Starting program: /home/src/libtool/demo/.libs/hell +/home/src/libtool/demo/.libs/hell: can't load library 'libhello.so.2' + +Program exited with code 020. +(gdb) @kbd{quit} +burger$ +@end example + +Argh. Now GDB complains because it cannot find the shared library that +@file{hell} is linked against. So, we must use libtool in order to +properly set the library path and run the debugger. Fortunately, we can +forget all about the @file{@value{objdir}} directory, and just run it on +the executable wrapper (@pxref{Execute mode}): + +@example +burger$ @kbd{libtool gdb hell} +GDB is free software and you are welcome to distribute copies of it + under certain conditions; type "show copying" to see the conditions. +There is absolutely no warranty for GDB; type "show warranty" for details. +GDB 4.16 (i386-unknown-netbsd), Copyright 1996 Free Software Foundation, Inc... +(gdb) @kbd{break main} +Breakpoint 1 at 0x8048547: file main.c, line 29. +(gdb) @kbd{run} +Starting program: /home/src/libtool/demo/.libs/hell + +Breakpoint 1, main (argc=1, argv=0xbffffc40) at main.c:29 +29 printf ("Welcome to GNU Hell!\n"); +(gdb) @kbd{quit} +The program is running. Quit anyway (and kill it)? (y or n) @kbd{y} +burger$ +@end example + @node Installing libraries @section Installing libraries @@ -758,7 +833,8 @@ burger# @pindex install Libtool installation is quite simple, as well. Just use the -@code{install} or @code{cp} command that you normally would: +@code{install} or @code{cp} command that you normally would +(@pxref{Install mode}): @example a23# @kbd{libtool cp libhello.la /usr/local/lib/libhello.la} @@ -799,7 +875,7 @@ make sure that where the library is installed actually agrees with the @cindex Installation, finishing @cindex Libraries, finishing installation Then, running @samp{libtool -n --finish @var{libdir}} can give you -further hints on what to do: +further hints on what to do (@pxref{Finish mode}): @example burger# @kbd{libtool -n --finish /usr/local/lib} @@ -917,8 +993,9 @@ If @var{mode} is specified, it must be one of the following: @item compile Compile a source file into a libtool object. -@item dlname -Find the correct name that programs should @code{dlopen(3)}. +@item execute +Automatically set the library path so that another program can use +uninstalled libtool-generated programs or libraries. @item finish Complete the installation of libtool libraries on the system. @@ -940,6 +1017,7 @@ Print libtool version information and exit. @menu * Compile mode:: Creating library object files. * Link mode:: Generating executables and libraries. +* Execute mode:: Debugging libtool-generated programs. * Install mode:: Making libraries and executables public. * Finish mode:: Completing a library installation. * Uninstall mode:: Removing executables and libraries. @@ -983,10 +1061,14 @@ If @var{output-file} is a program, then do not link it against any shared libraries at all. If @var{output-file} is a library, then only create a static library. -@item -allow-undefined -If @var{output-file} is a libtool library, allow it to contain -references to symbols that aren't defined in that library or its -dependencies (@pxref{Inter-library dependencies}). +@item -dlopen @var{file} +Same as @samp{-dlpreopen @var{file}}, if native dlopening is not +supported on the host platform (@pxref{Dlopened modules}). Otherwise, +no effect. + +@item -dlpreopen @var{file} +Link @var{file} into the output program, and add its symbols to +@var{dld_preloaded_symbols} (@pxref{Dlpreopening}). @item -export-dynamic Allow symbols from @var{output-file} to be resolved with @code{dlsym(3)} @@ -1001,6 +1083,11 @@ installed. This option is required even when @var{output-file} is not an executable. +@item -no-undefined +Declare that @var{output-file} does not depend on any other libraries. +Some platforms cannot create shared libraries that depend on other +libraries (@pxref{Inter-library dependencies}). + @item -o @var{output-file} Create @var{output-file} from the specified objects and libraries. @@ -1037,6 +1124,31 @@ This method is often called @dfn{partial linking}. Otherwise, an executable program is created. +@node Execute mode +@section Execute mode +@cindex Execute mode +@cindex Mode, execute + +For @samp{execute} mode, the library path is automatically set, then a +program is executed. + +The first of the @var{mode-args} is treated as a program name, with the +rest as arguments to that program. + +The following components of @var{mode-args} are treated specially: + +@table @samp +@item -dlopen @var{file} +Add the directory containing @var{file} to the library path. +@end table + +This mode sets the library path environment variable according to any +@samp{-dlopen} flags. + +If any of the @var{args} are libtool executable wrappers, then they are +translated into the name of their corresponding uninstalled binary, and +any of their required library directories are added to the library path. + @node Install mode @section Install mode @cindex Install mode @@ -1544,10 +1656,9 @@ Libtool's description of the interfaces that a program uses is very simple: it encodes the least and the greatest interface numbers in the resulting binary (@var{first-interface}, @var{last-interface}). -Then, the dynamic linker is guaranteed that if a library supports -@emph{every} interface number between @var{first-interface} and -@var{last-interface}, then the program can be relinked against that -library. +The dynamic linker is guaranteed that if a library supports @emph{every} +interface number between @var{first-interface} and @var{last-interface}, +then the program can be relinked against that library. Note that this can cause problems because libtool's compatibility requirements are actually stricter than is necessary. @@ -1575,7 +1686,7 @@ The most recent interface number that this library implements. The implementation number of the @var{current} interface. @item age -The difference between the oldest and newest interfaces that this +The difference between the newest and oldest interfaces that this library implements. In other words, the library implements all the interface numbers in the range from number @code{@var{current} - @var{age}} to @code{@var{current}}. @@ -1597,7 +1708,7 @@ This flag accepts an argument of the form @samp{-version-info 3:12:1} sets @var{current} to 3, @var{revision} to 12, and @var{age} to 1. -If either @var{age} or @var{revision} are omitted, they default to 0. +If either @var{revision} or @var{age} are omitted, they default to 0. Also note that @var{age} must be less than or equal to the @var{current} interface number. @@ -1845,12 +1956,12 @@ libraries are found. This restriction is only necessary to preserve compatibility with static library systems and simple dynamic library systems. -If your library depends on symbols that are defined in executables or -static libraries, then you cannot express the dependency with a -@samp{-l@var{name}} flag,@footnote{For static libraries, you -@emph{could} use a @samp{-l} flag, but it would cause conflicts -on systems which have non-PIC objects.} so you need to use the -@samp{-allow-undefined} link flag (@pxref{Link mode}). +Some platforms, such as AIX, do not even allow you this flexibility. In +order to build a shared library, it must be entirely self-contained +(i.e. have no references to external symbols), and you need to specify +the @var{-no-undefined} flag to allow a shared library to be built. By +default, libtool builds only static libraries on these kinds of +platforms. @node Dlopened modules @chapter Dlopened modules @@ -1902,7 +2013,7 @@ problems associated with dlopened modules. @menu * Building modules:: Creating dlopenable objects and libraries. -* Dlpreopening:: +* Dlpreopening:: Dlopening that works on static platforms. * Finding the dlname:: Choosing the right file to @code{dlopen(3)}. * Dlopen issues:: Unresolved problems that need your attention. @end menu @@ -1976,6 +2087,40 @@ module, or the module is not found, then the application can recover without crashing. @end enumerate +Libtool emulates @samp{-export-dynamic} on static platforms by linking +objects into the program at compile time, and creating data structures +that represent the program's symbol table. + +In order to use this feature, you must declare the objects you want your +application to dlopen by using the @samp{-dlopen} or @samp{-dlpreopen} +flags when you link your program (@pxref{Link mode}). + +@deftp {Structure} dld_symbol name address +The @var{name} attribute is a 0-terminated character string of the +symbol name, such as @code{"fprintf"}. The @var{address} attribute is a +generic pointer to the appropriate object, which is @code{&fprintf} in +this example. +@end deftp + +@deftypevr {Variable} {dld_symbol *} dld_preloaded_symbols +An array of @var{dld_symbol} structures, representing all the preloaded +symbols linked into the program. The last element has a @var{name} of +@code{0}. +@end deftypevr + +@deftypevr {Variable} int dld_preloaded_symbol_count +The number of elements in @var{dld_preloaded_symbols}, if it is sorted +in ascending order by @var{name}. Otherwise, @code{-1}, to indicate +that the application needs to sort and count @var{dld_preloaded_symbols} +itself, or search it linearly. +@end deftypevr + +Some compilers may allow identifiers which are not valid in ANSI C, such +as dollar signs. Libtool only recognizes valid ANSI C symbols (an +initial ASCII letter or underscore, followed by zero or more ASCII +letters, digits, and underscores), so non-ANSI symbols will not appear +in @var{dld_preloaded_symbols}. + @node Finding the dlname @section Finding the correct name to dlopen @cindex Names of dynamic modules @@ -2056,7 +2201,7 @@ This chapter describes how libtool interacts with other languages, and what special considerations you need to make if you do not use C. @menu -* C++ libraries:: +* C++ libraries:: Building libraries for C++. @end menu @node C++ libraries diff --git a/ltconfig.in b/ltconfig.in index 9705defa..81b76d94 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -26,6 +26,10 @@ # A lot of this script is taken from autoconf-2.10. +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi + echo=echo if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : else @@ -342,7 +346,7 @@ fi if test -n "$RANLIB"; then old_archive_cmds="$old_archive_cmds;\$RANLIB \$oldlib" - old_postinstall_cmds="$old_postinstall_cmds;\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib;$old_postinstall_cmds" fi # Check to see if we are using GCC. @@ -476,7 +480,7 @@ else hpux9* | hpux10*) # Is there a better link_static_flag that works with the bundled CC? wl='-Wl,' - link_static_flag='${wl}-a ${wl}archive' + link_static_flag="${wl}-a ${wl}archive" pic_flag='+Z' ;; @@ -686,7 +690,6 @@ hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no -hardcode_runpath_var=no hardcode_shlibpath_var=unsupported runpath_var= @@ -707,15 +710,14 @@ if test "$with_gnu_ld" = yes && test "$gnu_ld_acts_native" != yes; then if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared ${wl}-soname $wl$soname -o $lib$libobjs' runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes ld_shlibs=yes else ld_shlibs=no fi if test "$ld_shlibs" = yes; then - hardcode_libdir_flag_spec='${wl}-rpath $wl$libdir' - export_dynamic_flag_spec='${wl}-export-dynamic' + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' fi else # PORTME fill in a description of your system's linker (not GNU ld) @@ -999,7 +1001,7 @@ dld_preloaded_symbols[] = EOF sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> conftest.c cat <<\EOF >> conftest.c - {0}, + {0, (__ptr_t) 0} }; #ifdef __cplusplus @@ -1042,7 +1044,7 @@ test "$pipe_works" = yes || global_symbol_pipe= echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ - test "$hardcode_runpath_var" = yes; then + test -n "$runpath_var"; then # We can hardcode non-existant directories. if test "$hardcode_direct" != no && \ @@ -1308,6 +1310,10 @@ cat < $ofile # Compiler and other test output produced by $progname, useful for # debugging $progname, is in ./config.log if it exists. +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi + # An echo program that doesn't interpret backslashes. echo="$ltecho" @@ -1434,10 +1440,6 @@ hardcode_direct=$hardcode_direct # resulting binary. hardcode_minus_L=$hardcode_minus_L -# Set to yes if using RUNPATH_VAR=DIR during linking hardcodes DIR into the -# resulting binary. -hardcode_runpath_var=$hardcode_runpath_var - # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var @@ -1445,7 +1447,7 @@ hardcode_shlibpath_var=$hardcode_shlibpath_var EOF case "$host_os" in -aix*) +aix3*) cat <<\EOF >> $ofile # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems @@ -1468,7 +1470,7 @@ EOF ;; *) cat <> $ofile # Find the path to this script. -thisdir=\`$echo "\$0" | sed -e 's%/[^/]*\$%%'\` +thisdir=\`\$echo "\$0" | sed -e 's%/[^/]*\$%%'\` test "X\$0" = "X\$thisdir" && thisdir=. # Execute the libtool backend. diff --git a/ltmain.in b/ltmain.in index 033a928f..cb300fd2 100644 --- a/ltmain.in +++ b/ltmain.in @@ -166,7 +166,7 @@ if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then case "$nonopt" in - *cc | *++) + *cc | *++ | gcc* | *-gcc*) mode=link for arg do @@ -181,7 +181,7 @@ if test -z "$show_help"; then *db | *dbx) mode=execute ;; - *install*|cp) + *install*|cp|mv) mode=install ;; *rm) @@ -266,8 +266,9 @@ if test -z "$show_help"; then libobj=`$echo "$srcfile" | sed -e 's%^.*/%%'` # Recognize several different file suffixes. - xform='[cCFSfm]' + xform='[cCFSfms]' case "$libobj" in + *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.cpp) xform=cpp ;; @@ -605,7 +606,10 @@ if test -z "$show_help"; then # If there is no dlname, we need to preload. prev=dlprefiles else - # We should not create a dependency on this library. + # We should not create a dependency on this library, but we + # may need any libraries it requires. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" prev= continue fi @@ -659,7 +663,7 @@ if test -z "$show_help"; then compile_command="$compile_command $flag" finalize_command="$finalize_command $flag" fi - elif test "$hardcode_runpath_var" = yes; then + elif test -n "$runpath_var"; then # Do the same for the permanent run path. case "$perm_rpath " in *" $libdir "*) ;; @@ -741,6 +745,10 @@ if test -z "$show_help"; then finalize_command="$finalize_command -L$dir -l$name" fi fi + + # Add in any libraries that this one depends upon. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" continue ;; @@ -784,6 +792,15 @@ if test -z "$show_help"; then exit 1 ;; + *.a) + # Now set the variables for building old libraries. + build_libtool_libs=no + build_old_libs=yes + oldlib="$output" + $show "$rm $oldlib" + $run $rm $oldlib + ;; + *.la) # Make sure we only generate libraries of the form `libNAME.la'. case "$output" in @@ -818,6 +835,7 @@ if test -z "$show_help"; then fi # Add libc to deplibs on all systems. + dependency_libs="$deplibs" deplibs="$deplibs -lc" if test -n "$dlfiles$dlprefiles"; then @@ -1000,6 +1018,9 @@ if test -z "$show_help"; then dlname="$soname" fi fi + + # Now set the variables for building old libraries. + oldlib="$objdir/$libname.a" ;; *.lo | *.o) @@ -1123,7 +1144,7 @@ if test -z "$show_help"; then compile_command="$compile_command $flag" finalize_command="$finalize_command $flag" fi - elif test "$hardcode_runpath_var" = yes; then + elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; @@ -1244,7 +1265,7 @@ EOF fi cat <<\EOF >> "$objdir/$dlsyms" - {0}, + {0, (__ptr_t) 0} }; #ifdef __cplusplus @@ -1330,7 +1351,7 @@ EOF finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi - if test -n "$perm_rpath"; then + if test -n "$runpath_var"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do @@ -1357,6 +1378,9 @@ EOF # Quote the finalize command for shipping. finalize_command=`$echo "$finalize_command" | sed "$sed_quote_subst"` + # Quote $echo for shipping. + qecho=`$echo "$echo" | sed "$sed_quote_subst"` + # Only actually do things if our run command is non-null. if test -z "$run"; then $rm $output @@ -1374,6 +1398,10 @@ EOF # This wrapper script should never be moved out of \``pwd`'. # If it is, it will not operate correctly. +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi + # This environment variable determines our operation mode. if test "\$libtool_install_magic" = "$magic"; then # install mode needs the following variables: @@ -1383,7 +1411,7 @@ else # When we are sourced in execute mode, \$file and \$echo are already set. if test "\$libtool_execute_magic" = "$magic"; then : else - echo='$echo' + echo="$qecho" file="\$0" fi @@ -1468,23 +1496,11 @@ EOF ;; esac - # See if we need to build an old-fashioned archive. if test "$build_old_libs" = "yes"; then - # Now set the variables for building old libraries. - oldlib="$objdir/$libname.a" - # Transform .lo files to .o files. oldobjs="$objs"`$echo "$libobjs " | sed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` - if test -d "$objdir"; then - $show "$rm $oldlib" - $run $rm $oldlib - else - $show "$mkdir $objdir" - $run $mkdir $objdir - fi - # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=`eval \\$echo \"$old_archive_from_new_cmds\"` @@ -1523,6 +1539,9 @@ library_names='$library_names' # The name of the static archive. old_library='$old_library' +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + # Version information for $libname. current=$current age=$age @@ -1746,13 +1765,9 @@ EOF test "X$dlname" = "X$realname" && dlname= # Support stripping libraries. - if test -n "$stripme"; then - if test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run $striplib $destdir/$realname || exit $? - else - $echo "$modename: warning: no library stripping program" 1>&2 - fi + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run $striplib $destdir/$realname || exit $? fi if test $# -gt 0; then @@ -1919,13 +1934,9 @@ EOF $run eval "$install_prog \$file \$oldlib" || exit $? # Support stripping libraries. - if test -n "$stripme"; then - if test -n "$old_striplib"; then - $show "$old_striplib $oldlib" - $run $old_striplib $oldlib || exit $? - else - $echo "$modename: warning: no static library stripping program" 1>&2 - fi + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run $old_striplib $oldlib || exit $? fi # Do each command in the postinstall commands. @@ -1984,11 +1995,37 @@ EOF done fi - echo "To link against installed libraries in LIBDIR, users may have to:" + echo "------------------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "To link against installed libraries in a given directory, LIBDIR," + echo "you must use the \`-LLIBDIR' flag during linking." + echo + echo " You will also need to do one of the following:" if test -n "$shlibpath_var"; then - echo " - add LIBDIR to their \`$shlibpath_var' environment variable" + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" fi - echo " - use the \`-LLIBDIR' linker flag" + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + flag=`eval \\$echo \"$hardcode_libdir_flag_spec\"` + + echo " - use the \`$flag' linker flag" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "------------------------------------------------------------------------------" exit 0 ;; @@ -2252,6 +2289,7 @@ MODE must be one of the following: MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE. EOF + exit 0 ;; compile) diff --git a/tests/ChangeLog b/tests/ChangeLog index c04d18f2..9497982d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,18 @@ +Fri Jan 23 01:28:06 1998 Gordon Matzigkeit + + * Makefile.am (TESTS_ENVIRONMENT): Export some important + environment variables. Reported by Ian Haggard. + +Sun Jan 18 15:23:04 1998 Gordon Matzigkeit + + * suffix.test (extensions): Recognize `.asm'. From Markus + F.X.J. Oberhumer. + +Fri Dec 5 00:26:13 1997 Gordon Matzigkeit + + * suffix.test (extensions): Recognize `.s'. From Markus + F.X.J. Oberhumer. + Tue Nov 11 15:08:12 1997 Gordon Matzigkeit * quote.test: Add backticks to the backslashify test. diff --git a/tests/Makefile.am b/tests/Makefile.am index 32fd349c..d9b179b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,10 @@ TESTS = assign.test demo-conf.test $(makesequence) \ if.test link.test link-2.test nomode.test \ quote.test suffix.test test-e.test +# Be sure to reexport important environment variables. +TESTS_ENVIRONMENT = CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \ + LD="$(LD)" NM="$(NM)" RANLIB="$(RANLIB)" LN_S="$(LN_S)" + EXTRA_DIST = defs tlibtool $(TESTS) # We need to remove any files that the above tests created. diff --git a/tests/suffix.test b/tests/suffix.test index e577128a..86bfc63d 100755 --- a/tests/suffix.test +++ b/tests/suffix.test @@ -2,7 +2,7 @@ # suffix.test - check that libtool knows how to transform source suffices. # Extensions taken from the ones that Automake recognizes, plus Objective C. -extensions="C F S c c++ cc cpp cxx f f90 for m" +extensions="C F S asm c c++ cc cpp cxx f f90 for m s" bad_names="foo." # Test script header.