[Top][All Lists]

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

[PATCH] Support versioned symbols better in GNU/Linux

From: Nix
Subject: [PATCH] Support versioned symbols better in GNU/Linux
Date: 01 Feb 2003 03:19:40 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Military Intelligence)

As Ulrich Drepper has commented (in
<>), 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.)

(A patch against 1.4d is also available; the patch below applies
fine, except for trivial adjustments in the KCC parts.)

(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

2003-02-01  Nix  <address@hidden>

        * 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: latest/libtool.m4
RCS file: /cvsroot/libtool/libtool/libtool.m4,v
retrieving revision 1.293
diff -u -r1.293 libtool.m4
--- latest/libtool.m4 29 Jan 2003 04:57:52 -0000 1.293
+++ latest/libtool.m4 1 Feb 2003 03:04:20 -0000
@@ -2960,7 +2960,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)='templib=`echo $lib | $SED -e 
"s/\.${shared_ext}\..*/\.${shared_ext}/"`; $CC $predep_objects $libobjs 
$deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv 
\$templib $lib'
-       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='templib=`echo $lib | $SED -e 
"s/\.${shared_ext}\..*/\.${shared_ext}/"`; $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~
+       templib=`echo $lib | $SED -e "s/\.${shared_ext}\..*/\.${shared_ext}/"`; 
$CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname 
$soname -o \$templib ${wl}-retain-symbols-file,$export_symbols 
${wl}-version-script,$lib.exp; 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.
@@ -2991,7 +2992,8 @@
        # 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'
        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -4960,6 +4962,12 @@
       _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: *; };" >> 
+      $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'

`I knew that there had to be aliens somewhere in the universe.  What I
 did not know until now was that they read USENET.' --- Mark Hughes,
      on those who unaccountably fail to like _A Fire Upon The Deep_

reply via email to

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