]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorThomas Tanner <tanner@gmx.de>
Wed, 13 Jan 1999 21:39:14 +0000 (21:39 +0000)
committerThomas Tanner <tanner@gmx.de>
Wed, 13 Jan 1999 21:39:14 +0000 (21:39 +0000)
13 files changed:
ChangeLog
cdemo/configure.in
demo/dlmain.c
demo/foo.h
doc/libtool.texi
libltdl/Makefile.am
libltdl/ltdl.c
libltdl/ltdl.h
ltconfig.in
ltmain.in
mail/deplibs.html [new file with mode: 0644]
mdemo/Makefile.am
mdemo/main.c

index ea7d28563fc604fbfec3897c540ad054fb17d44c..94b8d1b2705b3434e5c556816da5633aceb21be7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+1999-01-13  Thomas Tanner  <tanner@gmx.de>
+
+       * demo/dlmain.c, libltdl/ltdl.c, ltconfig.in, ltmain.in, 
+         doc/libtool.texi: renamed dld_preloaded_symbols to 
+         lt_preloaded_symbols, symbol lists are 'const'
+       * cdemo/configure.in: don't check for string.h
+       * demo/dlmain.c: renamed dld_symlist to lt_symlist,
+         preloaded symbols are 'const', use lt_ptr_t instead of void*
+       * demo/foo.h: define lt_ptr_t
+       * doc/libtool.texi: document lt_preloaded_symbols correctly
+       * libltdl/Makefile.am, mdemo/Makefile.am: renamed libtest to libltdlc
+       * libltdl/ltdl.c: fixed some minor typos, renamed dldpre to presym,
+         bugfix: search in search_path only if we have no directory 
+         and a search_path, in lt_dlsym() check whether symbol != 0
+       * libltdl/ltdl.h: removed lt_dlpreopen_default()
+       * ltconfig.in (dlpreopen): removed dld_preloaded_symbol_count
+       * ltmain.in: added help for -avoid-versioning, -export-symbols,
+         -module, add @SYMFILE@ if one of -export-dynamic, -dlopen or
+         -dlpreopen is used
+       * mail/deplibs.html: added Gordon Matzigkeit's inter-library
+         dependencies article
+       * mdemo/Makefile.am: removed -export-dynamic from LDFLAGS
+         (no longer necessary, since libtool defines lt_preloaded_symbols
+         when -dlopen is used), initialize with lt_preloaded_symbols
+       
 1999-01-13  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
        * doc/libtool.texi (Test descriptions): cdemo-static works, thanks 
@@ -21,7 +46,7 @@
        * ltconfig.in (NM): PATH search was not updated like in
        libtool.m4, in last Alexandre Oliva's change to it
        (sysv4*, ncr): pass all library dependencies
-       * ltmain.in (dependency_libs, -R): use `dep' instead of `arg' to
+       * ltmain.in (dependency_libs, -R): use `deplib' instead of `arg' to
        iterate, otherwise we'd overwrite `arg'
        (convenience, old_libs): if --disable-shared, convenience
        libraries are just old archives, as .lo's are of no use
index df5a50563523703b9d0c6fea210a59cc3e642f7b..97f3a3b47ba734ef65cd904f5184ac5337bfb5ea 100644 (file)
@@ -6,7 +6,7 @@ AC_PROG_CC
 AC_EXEEXT
 AM_PROG_LIBTOOL
 
-AC_CHECK_HEADERS(string.h math.h)
+AC_CHECK_HEADERS(math.h)
 
 AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=)
 AC_SUBST(LIBADD_M)
index aa0095d6093a66d180e8c6148861177b85115840..aab440c60a1a7b642b67b8c4284e3cf6a664d9d5 100644 (file)
@@ -24,21 +24,21 @@ USA. */
 #include <string.h>
 #endif
 
-struct dld_symlist
+struct lt_symlist
 {
-  char *name;
-  void *address;
+  const char *name;
+  lt_ptr_t address;
 };
 
-extern struct dld_symlist dld_preloaded_symbols[];
+extern const struct lt_symlist lt_preloaded_symbols[];
 
 #ifdef __CYGWIN32__
 int
 win32_force_data_import_address __P((void))
 {
-  struct dld_symlist *s;
+  const struct lt_symlist *s;
   
-  s = dld_preloaded_symbols;
+  s = lt_preloaded_symbols;
   while (s->name)
     {
       if (!strcmp ("nothing", s->name))
@@ -56,7 +56,7 @@ main (argc, argv)
      int argc;
      char **argv;
 {
-  struct dld_symlist *s;
+  const struct lt_symlist *s;
   int (*pfoo)() = 0;
   int (*phello)() = 0;
   int *pnothing = 0;
@@ -69,7 +69,7 @@ main (argc, argv)
 #endif
 
   /* Look up the symbols we require for this demonstration. */
-  s = dld_preloaded_symbols;
+  s = lt_preloaded_symbols;
   while (s->name)
     {
       if (s->address) {
index d0c4265e56fcef668c11ee33eb45112b65de88ec..175c019cf68b89495b67e1661a5e4e1f34b3ff66 100644 (file)
@@ -51,8 +51,10 @@ USA. */
 #undef __P
 #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN32__) || defined(__cplusplus)
 # define __P(protos) protos
+# define lt_ptr_t     void*
 #else
 # define __P(protos) ()
+# define lt_ptr_t     char*
 #endif
 
 #ifdef __CYGWIN32__
index 00c16d09475611618340aa6028cd9c56e626956a..45b09f88e8e5a7eb90a0558a7c6e4911a3076b72 100644 (file)
@@ -1147,7 +1147,7 @@ no effect.
 
 @item -dlpreopen @var{file}
 Link @var{file} into the output program, and add its symbols to
-@var{dld_preloaded_symbols} (@pxref{Dlpreopening}).
+@var{lt_preloaded_symbols} (@pxref{Dlpreopening}).
 
 @item -export-dynamic
 Allow symbols from @var{output-file} to be resolved with @code{dlsym}
@@ -2373,14 +2373,16 @@ 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}).
 
-@deftypefn {Structure} {typedef struct} dld_symbol @{ @w{char *@var{name};} @w{ptr_t @var{address};} @}
+@deftypefn {Structure} {typedef struct}
+lt_symbol @{ @w{const char *@var{name};} @w{lt_ptr_t @var{address};} @}
+
 The @var{name} attribute is a zero-terminated character string of the
 symbol name, such as @code{"fprintf"}.  The @var{address} attribute is a
 generic pointer to the appropriate object, such as @code{&fprintf}.
 @end deftypefn
 
-@deftypevar {dld_symbol *} dld_preloaded_symbols
-An array of @var{dld_symbol} structures, representing all the preloaded
+@deftypevar {const lt_symbol *} lt_preloaded_symbols
+An array of @var{lt_symbol} structures, representing all the preloaded
 symbols linked into the program. For each @samp{-dlpreloaded} file 
 there is an element with the @var{name} of the file and a @var{address} 
 of @code{0}, followed by all symbols exported from this file.
@@ -2391,7 +2393,7 @@ 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}.
+in @var{lt_preloaded_symbols}.
 
 @node Finding the dlname
 @section Finding the correct name to dlopen
index bd39633c2f2d2a0b2dc49a2ea99edfda8d13f0c7..c0a115cf8ed8888b01c97e97525450117f1ede0a 100644 (file)
@@ -12,7 +12,7 @@ LTDL_FLAGS =
 noinst_HEADERS = ltdl.h
 endif
 
-EXTRA_LTLIBRARIES = libltdl.la libtest.la
+EXTRA_LTLIBRARIES = libltdl.la libltdlc.la
 
 lib_LTLIBRARIES = @LIBLIBS@
 noinst_LTLIBRARIES = @NOINSTLIBS@
@@ -22,10 +22,10 @@ libltdl_la_LDFLAGS = $(LTDL_FLAGS)
 libltdl_la_LIBADD = $(LIBADD_DL)
 libltdl_la_DEPENDENCIES = libtool
 
-libtest_la_SOURCES = $(libltdl_la_SOURCES)
-libtest_la_LDFLAGS =
-libtest_la_LIBADD = $(libltdl_la_LIBADD)
-libltdl_la_DEPENDENCIES = libtool
+libltdlc_la_SOURCES = $(libltdl_la_SOURCES)
+libltdlc_la_LDFLAGS =
+libltdlc_la_LIBADD = $(libltdl_la_LIBADD)
+libltdlc_la_DEPENDENCIES = libtool
 
 libtool: ../libtool
        ./config.status --recheck
index f764e8ec67c8fb96bf0bfbd14ec1435c63a8e466..e2142695920ebc212f5c0b2230641eaa675db520 100644 (file)
@@ -63,7 +63,7 @@ static const char *symbol_error = "symbol not found";
 static const char *memory_error = "not enough memory";
 static const char *invalid_handle_error = "invalid handle";
 static const char *buffer_overflow_error = "internal buffer overflow";
-static const char *shutdown_error = "libraries already shutdown";
+static const char *shutdown_error = "library already shutdown";
 
 static const char *last_error;
 
@@ -299,7 +299,7 @@ dl = { LT_DLTYPE_TOP, dl_init, dl_exit,
 #define        BIND_RESTRICTED 0
 #endif /* BIND_RESTRICTED */
 
-#define        OPT_BIND_FLAGS  (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH)
+#define        LTDL_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH)
 
 static int
 shl_init ()
@@ -318,8 +318,7 @@ shl_open (handle, filename)
        lt_dlhandle handle;
        const char *filename;
 {
-       handle->handle = shl_load (filename, OPT_BIND_FLAGS, 0L);
-       /* the hp-docs say we should better abort() if errno==ENOSYM ;( */
+       handle->handle = shl_load(filename, LTDL_BIND_FLAGS, 0L);
        if (!handle->handle) {
                last_error = unknown_error;
                return 1;
@@ -345,7 +344,7 @@ shl_sym (handle, symbol)
 {
        lt_ptr_t address;
 
-       if (shl_findsym ((shl_t) (handle->handle), symbol, TYPE_UNDEFINED, 
+       if (shl_findsym((shl_t) (handle->handle), symbol, TYPE_UNDEFINED, 
            &address) != 0 || !(handle->handle) || !address) {
                last_error = unknown_error;
                return 0;
@@ -497,17 +496,17 @@ wll = { LT_DLTYPE_TOP, wll_init, wll_exit,
 
 #if HAVE_DLPREOPEN
 
-/* emulate dynamic linking using dld_preloaded_symbols */
+/* emulate dynamic linking using preloaded_symbols */
 
 typedef struct lt_dlsymlists_t {
        struct lt_dlsymlists_t *next;
-       lt_dlsymlist    *syms;
+       const lt_dlsymlist *syms;
 } lt_dlsymlists_t;
 
 static lt_dlsymlists_t *preloaded_symbols = 0;
 
 static int
-dldpre_init ()
+presym_init ()
 {
        /* Don't nullify preloaded_symbols here, it would prevent one
           from calling lt_dlpreload_default() before lt_dlinit() */
@@ -515,7 +514,7 @@ dldpre_init ()
 }
 
 static void
-dldpre_free_symlists ()
+presym_free_symlists ()
 {
        lt_dlsymlists_t *lists = preloaded_symbols;
        
@@ -529,7 +528,7 @@ dldpre_free_symlists ()
 }
 
 static int
-dldpre_exit ()
+presym_exit ()
 {
        /* Don't reset preloaded_symbols here; adding/removing symbols
            should be unrelated with init/exit */
@@ -537,8 +536,8 @@ dldpre_exit ()
 }
 
 static int
-dldpre_add_symlist (preloaded)
-       lt_dlsymlist *preloaded;
+presym_add_symlist (preloaded)
+       const lt_dlsymlist *preloaded;
 {
        lt_dlsymlists_t *tmp;
        lt_dlsymlists_t *lists = preloaded_symbols;
@@ -569,7 +568,7 @@ dldpre_add_symlist (preloaded)
 }
 
 static int
-dldpre_open (handle, filename)
+presym_open (handle, filename)
        lt_dlhandle handle;
        const char *filename;
 {
@@ -584,12 +583,12 @@ dldpre_open (handle, filename)
                return 1;
        }
        while (lists) {
-               lt_dlsymlist *syms = lists->syms;
+               const lt_dlsymlist *syms = lists->syms;
        
                while (syms->name) {
                        if (!syms->address &&
                            strcmp(syms->name, filename) == 0) {
-                               handle->handle = syms;
+                               handle->handle = (lt_ptr_t) syms;
                                return 0;
                        }
                        syms++;
@@ -601,14 +600,14 @@ dldpre_open (handle, filename)
 }
 
 static int
-dldpre_close (handle)
+presym_close (handle)
        lt_dlhandle handle;
 {
        return 0;
 }
 
 static lt_ptr_t
-dldpre_sym (handle, symbol)
+presym_sym (handle, symbol)
        lt_dlhandle handle;
        const char *symbol;
 {
@@ -630,11 +629,11 @@ dldpre_sym (handle, symbol)
 
 static
 lt_dltype_t
-dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit,
-          dldpre_open, dldpre_close, dldpre_sym };
+presym = { LT_DLTYPE_TOP, presym_init, presym_exit,
+          presym_open, presym_close, presym_sym };
 
 #undef LT_DLTYPE_TOP
-#define LT_DLTYPE_TOP &dldpre
+#define LT_DLTYPE_TOP &presym
 
 #endif
 
@@ -676,13 +675,13 @@ lt_dlinit ()
 
 int
 lt_dlpreopen (preloaded)
-       lt_dlsymlist *preloaded;
+       const lt_dlsymlist *preloaded;
 {
 #if HAVE_DLPREOPEN
        if (preloaded)
-               return dldpre_add_symlist(preloaded);
+               return presym_add_symlist(preloaded);
        else {
-               dldpre_free_symlists();
+               presym_free_symlists();
                return 0;
        }
 #else
@@ -835,7 +834,7 @@ find_library (handle, filename, have_dir, basename, search_path)
        if (tryall_dlopen(handle, filename) == 0)
                return 0; 
                        
-       if (have_dir && !search_path) {
+       if (have_dir || !search_path) {
                last_error = file_not_found_error;
                return 1;
        }
@@ -899,7 +898,7 @@ find_file (filename, basename, have_dir, search_path)
        if (file)
                return file;
                        
-       if (have_dir && !search_path) {
+       if (have_dir || !search_path) {
                last_error = file_not_found_error;
                return 0;
        }
@@ -1157,6 +1156,10 @@ lt_dlsym (handle, symbol)
                last_error = invalid_handle_error;
                return 0;
        }
+       if (!symbol) {
+               last_error = symbol_error;
+               return 0;
+       }
        lensym = strlen(symbol);
        if (handle->name)
                lenhand = strlen(handle->name);
index 96f5c7dee07ebab9afece2ac208f61d5c288044a..3bca1ce92e02818fc3997690bf642bbc9e0e9dfe 100644 (file)
@@ -69,21 +69,21 @@ typedef     lt_ptr_t lt_dlhandle;
 #endif
 
 typedef struct {
-       char *name;
+       const char *name;
        lt_ptr_t address;
 } lt_dlsymlist;
 
 __BEGIN_DECLS
 _LTDLL_EXTERN int lt_dlinit __P((void));
-_LTDLL_EXTERN int lt_dlpreopen __P((lt_dlsymlist *preloaded));
+_LTDLL_EXTERN int lt_dlpreopen __P((const lt_dlsymlist *preloaded));
 _LTDLL_EXTERN int lt_dlexit __P((void));
 _LTDLL_EXTERN lt_dlhandle lt_dlopen __P((const char *filename));
 _LTDLL_EXTERN int lt_dlclose __P((lt_dlhandle handle));
 _LTDLL_EXTERN lt_ptr_t lt_dlsym __P((lt_dlhandle handle, const char *name));
 _LTDLL_EXTERN const char *lt_dlerror __P((void));
 
-extern lt_dlsymlist dld_preloaded_symbols[];
-#define lt_dlpreopen_default() (lt_dlpreopen(dld_preloaded_symbols))
+extern const lt_dlsymlist lt_preloaded_symbols[];
+
 __END_DECLS
 
 #endif /* !_LTDL_H_ */
index d6c6b039af8b2d678f838f7ee7b8c62cc3654e5d..dada60aaafdcc2f64334fb67d46dcad5129b336c 100755 (executable)
@@ -1429,12 +1429,8 @@ EOF
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
         mv -f "$nlist"T "$nlist"
-        wcout=`wc "$nlist" 2>/dev/null`
-        count=`$echo "X$wcout" | $Xsed -e 's/^[        ]*\([0-9][0-9]*\).*$/\1/'`
-        (test "$count" -ge 0) 2>/dev/null || count=-1
       else
         rm -f "$nlist"T
-        count=-1
       fi
 
       # Make sure that we snagged all the symbols we need.
@@ -1456,15 +1452,12 @@ EOF
 # define lt_ptr_t char *
 #endif
 
-/* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
-int dld_preloaded_symbol_count = $count;
-
 /* The mapping between symbol names and symbols. */
-struct {
-  char *name;
+const struct {
+  const char *name;
   lt_ptr_t address;
 }
-dld_preloaded_symbols[] =
+lt_preloaded_symbols[] =
 {
 EOF
          sed 's/^\(.*\) \(.*\)$/  {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
index b2c213cc0ae62c9960619329dce59575c1a107e9..28e255d5310cb7a2687d0ddc99d6e13f6c1168a1 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -625,6 +625,7 @@ compiler."
     ltlibs=
     module=no
     objs=
+    preload=no
     prev=
     prevarg=
     release=
@@ -668,6 +669,12 @@ compiler."
 
        case "$prev" in
        dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           compile_command="$compile_command @SYMFILE@"
+           finalize_command="$finalize_command @SYMFILE@"
+           preload=yes
+         fi
          case "$arg" in
          *.la | *.lo) ;;  # We handle these cases below.
          *)
@@ -748,10 +755,12 @@ compiler."
          else
            arg=
          fi
-
-         # Add the symbol object into the linking commands.
-         compile_command="$compile_command @SYMFILE@"
-         finalize_command="$finalize_command @SYMFILE@"
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           compile_command="$compile_command @SYMFILE@"
+           finalize_command="$finalize_command @SYMFILE@"
+           preload=yes
+         fi
        fi
        ;;
 
@@ -939,10 +948,10 @@ compiler."
        if test -n "$dependency_libs"; then
          # Extract -R from dependency_libs
          temp_deplibs=
-         for dep in $dependency_libs; do
-           case "$dep" in
-           -R*) xrpath="$xrpath "`echo "X$dep" | $Xsed -e 's/^-R//'`;;
-           *) temp_deplibs="$temp_deplibs $dep";;
+         for deplib in $dependency_libs; do
+           case "$deplib" in
+           -R*) xrpath="$xrpath "`echo "X$deplib" | $Xsed -e 's/^-R//'`;;
+           *) temp_deplibs="$temp_deplibs $deplib";;
            esac
          done
          dependency_libs="$temp_deplibs"
@@ -1922,7 +1931,7 @@ extern \"C\" {
 #endif
 
 /* Prevent the only kind of declaration conflicts we can make. */
-#define dld_preloaded_symbols some_other_symbol
+#define lt_preloaded_symbols some_other_symbol
 
 /* External symbol declarations for the compiler. */\
 "
@@ -1955,7 +1964,7 @@ extern \"C\" {
 
            $echo >> "$output_objdir/$dlsyms" "\
 
-#undef dld_preloaded_symbols
+#undef lt_preloaded_symbols
 
 #if defined (__STDC__) && __STDC__
 # define lt_ptr_t void *
@@ -1964,11 +1973,11 @@ extern \"C\" {
 #endif
 
 /* The mapping between symbol names and symbols. */
-struct {
-  char *name;
+const struct {
+  const char *name;
   lt_ptr_t address;
 }
-dld_preloaded_symbols[] =
+lt_preloaded_symbols[] =
 {\
 "
 
@@ -2016,7 +2025,7 @@ dld_preloaded_symbols[] =
        esac
       else
        # We keep going just in case the user didn't refer to
-       # dld_preloaded_symbols.  The linker will fail if global_symbol_pipe
+       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
        # really was required.
        if test -n "$dlfiles$dlprefiles"; then
          $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
@@ -3182,11 +3191,15 @@ a program from several object files.
 The following components of LINK-COMMAND are treated specially:
 
   -all-static       do not do any dynamic linking at all
+  -avoid-versioning do not add a version suffix if possible
   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
-  -dlpreopen FILE   link in FILE and add its symbols to dld_preloaded_symbols
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                   try to export only the symbols listed in SYMFILE
   -LLIBDIR          search LIBDIR for required installed libraries
   -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
   -release RELEASE  specify package release information
diff --git a/mail/deplibs.html b/mail/deplibs.html
new file mode 100644 (file)
index 0000000..5d8ebf7
--- /dev/null
@@ -0,0 +1,213 @@
+<html>
+<head>
+<title>Libtool Inter-library Dependencies</title>
+<body bgcolor="#ffffff">
+<center><h1><img src="/graphics/libtool.gif" width=477 height=192
+ alt="Libtool"></h1></center>
+
+<h1>Inter-library Dependencies</h1>
+
+<p>About twice a week, for the last five weeks, I've been receiving
+bug reports which tell me that libtool's inter-library dependency
+handling is broken.
+
+<p>I know.  I broke it intentionally, until I have the time to fix it
+myself, or somebody else takes the time to help me with it.
+
+<p>These same people often give me a simple one-line patch which
+re-enables my old, simplistic inter-library dependencies, but nobody
+seems to want to test things thoroughly and come up with a real
+solution.
+
+<p>If you don't care about the history, and you just want to help me
+out, jump to <a href="#solution">the bottom of this document</a>.
+
+<h2>Background</h2>
+
+<p>Libtool's basic premise is to make static and shared libraries
+behave the same way from a programmer's point of view.  This allows
+users to build a libtoolized package with or without shared libraries,
+determined at configuration time.  It does this by using a
+<dfn>libtool object</dfn> (<samp>.lo</samp>) and <dfn>libtool
+archive</dfn> (<samp>.la</samp>) abstraction, so that the package
+maintainer can use libtool to operate on these files without making
+any assumptions about their underlying representation.
+
+<p>For the most part, this abstraction works well, and has made
+libtool as popular as it is today.  Without this abstraction, it would
+be significantly harder to port libtool to new platforms.
+
+<p>Unfortunately, what this abstraction has also done is reveal some
+fundamental inconsistencies with most shared library implementations.
+Every shared library implementation works well for `hello world'-type
+examples, but very few are robust and well-designed so that libtool
+doesn't need special tricks in order to build correct, featureful
+shared libraries.
+
+<p>Providing inter-library dependencies is one feature that has
+revealed these kinds of inconsistencies.
+
+<h2>The problem</h2>
+
+<p>My orginal inter-library dependency code received rigourous testing
+in beta releases of <a href="http://www.red-bean.com/guile/">GNU
+Guile</a>.  As soon as the Guile people started using my code, I
+received a flood of bug reports.  People were reporting that
+<samp>libguile</samp> (Guile's main shared library) was failing to
+link, or that programs linked against <samp>libguile</samp> were
+dumping core.
+
+<p>Not good.
+
+<p>The Guile people chased this bug down to the following scenario:
+
+<ol>
+<li>The user's system has a static regexp library installed,
+<samp>librx.a</samp>.
+
+<li>Guile's <samp>configure</samp> script detects that the
+<samp>-lrx</samp> linker option can be used to link in
+<samp>librx</samp>.
+
+<li>When <samp>libguile</samp> is built, the <samp>-lrx</samp> linker
+option is used.
+
+<li>Some linkers fail at this point, because they don't allow shared
+libraries to contain or depend on static libraries.
+
+<li>If the linker didn't fail, then a few programs are linked against
+<samp>libguile</samp>.
+
+<li>On some systems, these programs core dump because
+<samp>libguile</samp> is a shared library that contains non-PIC code
+(from <samp>librx</samp>).
+</ol>
+
+<h2>The interim solution</h2>
+
+<p>I needed some way to respond to these reports.  I saw my options (in
+order of my preference) as:
+
+<ol>
+<li>Write code in <samp>ltmain.sh</samp> to prevent static libraries
+from appearing in inter-library dependencies.  This would take some
+work, but obviously is the best solution.
+
+<li>Find the systems that fail, and turn off inter-library
+dependencies on only those systems.
+
+<li>Force the package maintainer to guarantee that static libraries
+never appear in inter-library dependencies.
+</ol>
+
+<p>I immediately vetoed the last solution, because that would violate
+the whole point of using libtool, and would cause a lot of people to
+waste time solving a problem that really should be fixed by libtool.
+
+<p>I preferred the first solution, but at the time of the reports, I
+didn't see an obviously simple mechanism for detecting the difference
+between shared and static libraries.
+
+<p>So, in the meantime, I tried turning off inter-library dependencies
+on the systems that failed.
+
+<p>I quickly discovered, to my chagrin, that many systems fail.  So,
+it was be simpler for me to turn off <em>all</em> inter-library
+dependencies, then find out which systems work, rather than vice
+versa.
+
+<h2>The current situation</h2>
+
+<p>I've been busy trying to avoid bankruptcy.  It's been over three
+months since I first turned off inter-library dependencies, and I
+still haven't completed the solution I want.
+
+<p>I've been gearing up for the 1.1 release of libtool, because there
+is a high demand for a stable public release.  So, I'm not going to
+introduce any destabilizing changes to the inter-library dependency
+code until after 1.1 is released.
+
+<h2><a name="solution">The solution</a></h2>
+
+<p>So, I want to tell you how you can help me solve the various
+dilemmas surrounding this issue:
+
+<ol>
+<li>I need to find out more about the nature of the problems I ran
+into with Guile.  Unfortunately, I cannot reproduce them in simple
+tests on my own platform (i586-pc-linux-gnulibc1), even though I think
+they were reported here.  I need to find out which platforms already
+have perfect inter-library dependency support, how to work around the
+problem on other platforms, and, more importantly, exactly
+<em>why</em> some systems give me problems and others don't.
+
+<p>On correct platforms, you can link <em>any</em> static library
+against a shared library via the <samp>-lNAME</samp> option without
+the linker complaining, then link a program against this library and
+run it without dumping core.  I know that this scenario will always
+work fine on the following systems:
+
+ <ul>
+ <li>None reported yet.
+ </ul>
+
+<p>I also know that on some systems, you can create a shared library
+linked against a static one, but running programs linked against such
+a library will dump core:
+
+ <ul>
+ <li>None reported yet.
+ </ul>
+
+<p>Finally, there are some systems which won't even allow you to link
+a shared library against a static one:
+
+ <ul>
+ <li>Solaris 2.x
+ </ul>
+
+<li>Help me figure out a good, portable way to detect if a given
+<samp>-lNAME</samp> option refers to a shared library or not, since
+that is needed as a workaround to the problem.  Some suggestions so
+far have been:
+
+ <ul>
+ <li>Link the library against a tiny test program, and:
+
+  <ul>
+  <li>run <samp>ldd(1)</samp> on the test program and search for
+  <samp>libNAME</samp> in the ldd output.
+  <li>use the <samp>-verbose</samp> flag for GNU ld in order to see
+  which library is actually linked.
+  <li>run some sort of other program to determine if the library was
+  dynamic.
+  </ul>
+
+ <li>Track the <samp>-LDIR</samp> flags, do a search for the library,
+ and then check whether it is shared by:
+
+  <ul>
+  <li>using the <samp>file(1)</samp> program.
+  <li>looking at its suffix.
+  </ul>
+ </ul>
+
+<li>Contact any people you know who might be interested, get them to
+read this page, so that they can help me solve the problem.
+
+<li>Send me money, so that I can devote more of my time to solving the
+problem.
+</ol>
+
+<p>Thank you for your help, and have fun.
+
+<hr>
+<a href="http://www.gimp.org/"><img src="/graphics/gfx_by_gimp.gif"
+align="right" border=0></a>
+
+<p><a href="libtool.html">Back to the libtool home page.</a>
+
+<address>
+Gordon Matzigkeit <a href="mailto:gord@profitpress.com">&lt;gord@profitpress.com&gt;</a>
+</address>
+</html>
\ No newline at end of file
index 224c09a5b71cb2eef2581122dde892bd26cb1525..6d9875889cf005fc477aa08b954f96cdfd3423aa 100644 (file)
@@ -18,19 +18,18 @@ noinst_HEADERS = foo.h
 
 bin_PROGRAMS = mdemo mdemo.debug
 
-../libltdl/libtest.la: ../libltdl/libtool \
+../libltdl/libltdlc.la: ../libltdl/libtool \
     $(srcdir)/../libltdl/ltdl.c $(srcdir)/../libltdl/ltdl.h
-       (cd ../libltdl; $(MAKE) libtest.la)
+       (cd ../libltdl; $(MAKE) libltdlc.la)
 
 # Create a version of mdemo that does dlopen.
 mdemo_SOURCES = main.c
-mdemo_LDADD = ../libltdl/libtest.la
-mdemo_LDFLAGS = -export-dynamic -dlopen foo1.la -dlopen libfoo2.la
-mdemo_DEPENDENCIES = ../libltdl/libtest.la foo1.la libfoo2.la
+mdemo_LDADD = ../libltdl/libltdlc.la
+mdemo_LDFLAGS = -dlopen foo1.la -dlopen libfoo2.la
+mdemo_DEPENDENCIES = ../libltdl/libltdlc.la foo1.la libfoo2.la
 
 # Create an easier-to-debug version of mdemo.
 mdemo_debug_SOURCES = main.c
-mdemo_debug_LDADD = ../libltdl/libtest.la
-mdemo_debug_LDFLAGS = -static -export-dynamic \
-       -dlopen foo1.la -dlopen libfoo2.la
-mdemo_debug_DEPENDENCIES = ../libltdl/libtest.la foo1.la libfoo2.la
+mdemo_debug_LDADD = ../libltdl/libltdlc.la
+mdemo_debug_LDFLAGS = -static -dlopen foo1.la -dlopen libfoo2.la
+mdemo_debug_DEPENDENCIES = ../libltdl/libltdlc.la foo1.la libfoo2.la
index 5efc0df7b3c23805c98d06de259bd08f9b5a2043..3f678160a7ed0c33292de93334f305078d3d3476 100644 (file)
@@ -92,6 +92,10 @@ main (int argc, char **argv)
     fprintf (stderr, "error during initialization: %s\n", lt_dlerror());
     return 1;
   }
+  if (lt_dlpreopen(lt_preloaded_symbols) != 0) {
+    fprintf (stderr, "error during initialization: %s\n", lt_dlerror());
+    return 1;
+  }
 
   for (i = 1; i < argc; i++)
     if (test_dl(argv[i]))