This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libstdc++] Option to allow symbol versioning



As discussed on the v3 list...  This adds --enable-symvers (soon to take
arguments), which turns on symbol versioning in the libstdc++ shared library.
This is off by default, and will remain so until we solve the testsuite
failures which symbol versioning causes.

Those interested and willing to experiment can turn this on, and have
a look at the version script.  It is only half-baked and is chock full
of placeholders; it does, however, export enough symbols to permit every
program in the v3 testsuite to build, which should give us a good idea of
what needs to be in the final version.


2002-02-14  Phil Edwards  <pme@gcc.gnu.org>

	* acinclude.m4 (GLIBCPP_ENABLE_SYMVERS):  New macro, initial revision.
	* configure.in:  Call it.
	* config/linker-map.gnu:  New file, initial incomplete revision.
	* src/Makefile.am:  Optionally pass version script to the linker.
	* aclocal.m4:  Regenerate.
	* configure:  Regenerate.
	* src/Makefile.in:  Regenerate.


Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.190
diff -u -3 -p -r1.190 acinclude.m4
--- acinclude.m4	2002/02/06 17:31:27	1.190
+++ acinclude.m4	2002/02/14 18:14:34
@@ -2004,3 +2004,58 @@ fi
 ])
 
 
+dnl
+dnl Add version tags to symbols in shared library (or not), additionally
+dnl marking other symbols as private/local (or not).
+dnl
+dnl GLIBCPP_ENABLE_SYMVERS
+dnl --enable-symvers adds a version script to the linker call when creating
+dnl       the shared library.
+dnl --disable-symvers does not.
+dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
+dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
+dnl       defaults to `no'.
+AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
+AC_REQUIRE([AC_PROG_LD])
+define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
+AC_ARG_ENABLE(symvers,
+changequote(<<, >>)dnl
+<<  --enable-symvers        enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
+changequote([, ])dnl
+[case "$enableval" in
+ yes) enable_symvers=yes ;;
+ no)  enable_symvers=no ;;
+ *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
+ esac],
+enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
+dnl Option parsed, now set things appropriately
+AC_MSG_CHECKING([whether to version shared lib symbols])
+if test $enable_shared = no; then
+  enable_symvers=irrelevant
+fi
+# placeholder -- maybe have a fallback later
+LINKER_MAP=config/linker-map.gnu
+# symvers variable may evolve into holding the type of linker map someday
+if test $enable_symvers = yes; then
+  # flat-out assume a whole bunch of things right now
+  #
+  # The name of this variable changed between autoconf versions (our problem
+  # for depending on an impl detail, tsk tsk).  It used to be
+  # ac_cv_prog_gnu_ld but is now lt_cv_prog_gnu_ld, and is copied back into
+  # with_gnu_ld which can also be user-settable.  Let's use that one.
+  if test $with_gnu_ld = yes; then
+    # we also assume that the gnu ld in question has phil's patches... can't
+    # think today of an easy way to programatically test for that; revisit
+    LINKER_MAP=config/linker-map.gnu
+  else
+    # placeholder -- maybe have a fallback later
+    LINKER_MAP=config/linker-map.gnu
+    enable_symvers=no
+  fi
+fi
+AC_LINK_FILES($LINKER_MAP, src/linker.map)
+AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test "$enable_symvers" = yes)
+AC_MSG_RESULT($enable_symvers)
+])
+
+
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.in,v
retrieving revision 1.80
diff -u -3 -p -r1.80 configure.in
--- configure.in	2002/01/01 18:12:06	1.80
+++ configure.in	2002/02/14 18:14:35
@@ -49,6 +49,7 @@ GLIBCPP_ENABLE_THREADS
 GLIBCPP_ENABLE_CXX_FLAGS([none])
 GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
 GLIBCPP_ENABLE_CONCEPT_CHECKS
+GLIBCPP_ENABLE_SYMVERS([no])
 
 
 if test -n "$with_cross_host" || test x"$build" != x"$host"; then
Index: config/linker-map.gnu
===================================================================
RCS file: linker-map.gnu
diff -N linker-map.gnu
--- /dev/null	Tue May  5 13:32:27 1998
+++ linker-map.gnu	Thu Feb 14 10:14:35 2002
@@ -0,0 +1,126 @@
+## Linker script for GNU ld 2.11.94+ only.
+##
+## Copyright (C) 2002 Free Software Foundation, Inc.
+##
+## This file is part of the libstdc++ version 3 distribution.
+##
+## This file is part of the GNU ISO C++ Library.  This library is free
+## software; you can redistribute it and/or modify it under the
+## terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with this library; see the file COPYING.  If not, write to the Free
+## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+## USA.
+
+
+## The symbol version here is a SWAG based on libgcc-std.ver.
+GCC_3.1 {
+
+  global:
+
+    ## Names inside the 'extern' block are human-readable (demangled) names;
+    ## all but the last are terminated with a semicolon.
+    extern "C++"
+    {
+      std::[A-Za-z]*;
+      std::__throw_*;
+      std::__basic_file*;
+      #std::__convert_to_*;
+      std::__num_base*;
+      std::__timepunct*
+    };
+
+
+    ## Names not in an 'extern' block are mangled names.  In the non-C cases,
+    ## their demangled names are written above them, in a comment.
+    __cxa_*;
+    __gxx_personality_v0;
+    __dynamic_cast;
+
+#    DW.ref.__gxx_personality_v0;   # I have no idea what this is.
+
+######## these seem okay
+    ## operator new(unsigned)
+    _Znwj;
+
+    ## operator delete(void*)
+    _ZdlPv;
+
+    ## operator new[](unsigned)
+    _Znaj;
+
+    ## operator delete[](void*)
+    _ZdaPv;
+
+######## hmmmmm
+    ## std::_S_rb_tree_red
+    _ZSt14_S_rb_tree_red;
+
+    ## std::_S_rb_tree_black
+    _ZSt16_S_rb_tree_black;
+
+    ## std::__stl_threshold
+    _ZSt15__stl_threshold;
+
+    ## std::__stl_chunk_size
+    _ZSt16__stl_chunk_size;
+
+    ## VTT for std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >
+    _ZTTSt19basic_istringstreamIcSt11char_traitsIcESaIcEE;
+
+    ## VTT for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >
+    _ZTTSt19basic_ostringstreamIcSt11char_traitsIcESaIcEE;
+
+    # this is a function, "void std::__convert_to_v(stuff)", and as such
+    # doesn't work well in the demangled section above
+    _ZSt14__convert_to_v*;
+
+    # likewise for "std::_Setfill<char> std::setfill<char>(char)"
+    _ZSt7setfillIcESt8_SetfillIT_ES1_;
+
+    # likewise for "bool std::has_facet<std::ctype<char> >(std::locale const&)"
+    _ZSt9has_facetISt5ctypeIcEEbRKSt6locale;
+
+    # likewise for "bool
+    # std::has_facet<std::num_put<char, std::ostreambuf_iterator<char,
+    #                       std::char_traits<char> > > >(std::locale const&)"
+    _ZSt9has_facetISt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEEEbRKSt6locale;
+
+    # ditto for istreambuf_iterator
+    _ZSt9has_facetISt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEEEbRKSt6locale;
+
+
+
+#    ## vtable for std::logic_error
+#    _ZTVSt11logic_error;
+#
+#    ## vtable for std::exception
+#    _ZTVSt9exception;
+#
+#    ## vtable for __cxxabiv1::__class_type_info
+#    _ZTVN10__cxxabiv117__class_type_infoE;
+#
+#    ## vtable for __cxxabiv1::__si_class_type_info
+#    _ZTVN10__cxxabiv120__si_class_type_infoE;
+#
+#    ## vtable for __cxxabiv1::__vmi_class_type_info
+#    _ZTVN10__cxxabiv121__vmi_class_type_infoE;
+#
+# gah, screw it, export /all/ the vtables in these namespaces, somebody
+# smarter than me will have to figure this one out
+_ZTVSt*;  _ZTVN10__cxxabiv1*;
+
+
+
+  local:
+    *;
+};
+
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.102
diff -u -3 -p -r1.102 Makefile.am
--- Makefile.am	2001/12/15 07:05:03	1.102
+++ Makefile.am	2002/02/14 18:14:35
@@ -1,6 +1,7 @@
 ## Makefile for the src subdirectory of the GNU C++ Standard library.
 ##
-## Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+## Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+## Free Software Foundation, Inc.
 ##
 ## This file is part of the libstdc++ version 3 distribution.
 ## Process this file with automake to produce Makefile.in.
@@ -77,10 +78,15 @@ libstdc___la_LIBADD = \
 	../libmath/libmath.la @libio_la@ \
 	../libsupc++/libsupc++convenience.la
 
-libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ -lm
+if GLIBCPP_BUILD_VERSIONED_SHLIB
+version_arg=-Wl,--version-script=linker.map
+else
+version_arg=
+endif
 
-libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD)
+libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ -lm ${version_arg}
 
+libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD) linker.map
 
 # Use special rules for the deprecated source files so that they find
 # deprecated include files.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]