[This is a resend of an earlier patch sent on 2003-02-01; one silly typo has been corrected and the patch has been respun against libtool-1.5. Otherwise, it is unchanged.
I assume the earlier patch dropped completely out of sight and nobody noticed it, so I'm resending the explanatory text as well.] As Ulrich Drepper has commented (in <http://people.redhat.com/drepper/dsohowto.pdf>), libtool's support for non-exported symbol visibility on GNU/Linux could do with improvement. Presently, if you specify an -export-symbols file, libtool converts it into a -Wl,-retain-symbols-file argument to $CC. This is hardly ideal, as --retain-symbols-file doesn't actually affect the visibility of symbols at runtime at all! The right thing to do is to use a version script. Luckily, the code to do this is already present for Solaris without GNU ld; all that is needed is to use a similar construction for GNU/Linux as well. Therefore, a patch, against CVS HEAD (KCC and Compaq C++ parts untested). (I'd write a testcase too but I'm not sure how you suppress running single testcases, and we'd need to suppress this one for the non-GNU/Linux, non-Solaris case.) (It may also be a good idea to add this for other platforms, particularly Solaris with GNU/ld, for which it would be a matter of deleting one conditional; but I can't test this at all, so I didn't do it.) 2003-06-09 Nix <[EMAIL PROTECTED]> * libtool.m4 (AC_LIBTOOL_PROG_LD_SHLIBS): Use version scripts under GNU/Linux. (AC_LIBTOOL_LANG_CXX_CONFIG): Likewise for KCC and Compaq C++. Index: 1.5/libtool.m4 =================================================================== RCS file: /cvsroot/libtool/libtool/libtool.m4,v retrieving revision 1.314 diff -u -r1.314 libtool.m4 --- 1.5/libtool.m4 5 Apr 2003 19:32:58 -0000 1.314 +++ 1.5/libtool.m4 9 Jun 2003 20:32:30 -0000 @@ -3087,7 +3087,8 @@ # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. @@ -3118,7 +3119,8 @@ cxx) # Compaq C++ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols ${wl}-version-script ${wl}$lib.exp' runpath_var=LD_RUN_PATH _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' @@ -5125,6 +5127,12 @@ wlarc= _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + linux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols ${wl}-version-script ${wl}$lib.exp -o $lib' ;; *) -- `It is an unfortunate coincidence that the date locarchive.h was written (in hex) matches Ritchie's birthday (in octal).' -- Roland McGrath on the libc-alpha list _______________________________________________ Libtool mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/libtool