From d7f30833549aa0378f41f8cdb132cff5826847fe Mon Sep 17 00:00:00 2001
From: Jonathan Wakely C++ applications often dependent on specific language support
@@ -101,7 +101,7 @@ given compiler ABI. In a nutshell:
The C++ interface has evolved throughout the history of the GNU
@@ -170,8 +170,8 @@ on ELF systems).
- The C++ interface
+ The C++ interface
- Versioning
+ Versioning
mapfile: gcc/libgcc-std.ver
@@ -220,8 +220,8 @@ on ELF systems).Incremental bumping of a compiler pre-defined macro, @@ -266,22 +266,26 @@ on ELF systems).
- This macro is defined in the file "lang-specs.h" in the gcc/cp directory. - Later versions define it in "c-common.c" in the gcc directory. + This macro was defined in the file "lang-specs.h" in the gcc/cp directory. + Later versions defined it in "c-common.c" in the gcc directory, and from + G++ 3.4 it is defined in c-cppbuiltin.c and its value determined by the + '-fabi-version' command line option.
- It is versioned as follows: + It is versioned as follows, where 'n' is given by '-fabi-version=n':
Changes to the default compiler option for @@ -297,8 +301,8 @@ on ELF systems).
-fabi-version=1
-fabi-version=2
Incremental bumping of a library pre-defined macro. For releases @@ -335,8 +339,8 @@ on ELF systems).
@@ -375,8 +380,8 @@ on ELF systems).
@@ -389,7 +394,7 @@ on ELF systems).
directory hierarchy corresponding to the C++ compiler's released version. This version corresponds to the variable "gcc_version" in "libstdc++-v3/acinclude.m4," and more details can be found in that - file's macro GLIBCPP_CONFIGURE. + file's macro GLIBCXX_CONFIGURE (GLIBCPP_CONFIGURE before gcc-3.4.0).C++ includes are versioned as follows: @@ -412,8 +417,8 @@ on ELF systems).
Taken together, these techniques can accurately specify interface @@ -457,7 +462,7 @@ on ELF systems).
impact versioning and compatibility. - +For more information on configure options, including ABI impacts, see: http://gcc.gnu.org/onlinedocs/libstdc++/configopts.html
@@ -507,11 +512,11 @@ int main() %g++ hello.cc -o hello.out %ldd hello.out - libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000) - libm.so.6 => /lib/tls/libm.so.6 (0x004a8000) - libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40016000) - libc.so.6 => /lib/tls/libc.so.6 (0x0036d000) - /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) + libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000) + libm.so.6 => /lib/tls/libm.so.6 (0x004a8000) + libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40016000) + libc.so.6 => /lib/tls/libc.so.6 (0x0036d000) + /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) %nm hello.out @@ -524,7 +529,7 @@ of the name, then the executable is versioned. Here's an example: U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4
The following will cause the library minor version number to @@ -543,7 +548,7 @@ Other allowed changes are possible.
@@ -574,24 +579,24 @@ number to increase, say from "libstdc++.so.3.0.4" to
This is accomplished by two techniques that separate the API from the ABI: forcing undefined references to link against a library binary for definitions.
- For non-templatized types, such as much of class
-locale
, the appropriate standard C++ include, say
-locale
, can contain full declarations, while various
-source files (say locale.cc, locale_init.cc,
-localename.cc
) contain definitions.
class
+ locale
, the appropriate standard C++ include, say
+ locale
, can contain full declarations, while various
+ source files (say locale.cc, locale_init.cc,
+ localename.cc
) contain definitions.For parts of the standard that have an explicit list of required +
extern template
can be used to control where template definitions
reside. By marking required instantiations as extern
@@ -601,14 +606,15 @@ localename.cc
) contain definitions.
on parts of the standard that require char
and
wchar_t
instantiations, and includes
basic_string
, the locale facets, and the types in
- iostreams
.
+ iostreams.In addition, these techniques have the additional benefit that they reduce binary size, which can increase runtime performance.
+All symbols in the shared library binary are processed by a linker script at build time that either allows or disallows external @@ -623,34 +629,37 @@ impacting ABI compatibility.
The following namespaces are transformed by the mapfile:
-namespace std
Defaults to exporting all symbols in label +
namespace std
GLIBCXX
that do not begin with an underscore, ie
__test_func
would not be exported by default. Select
-exceptional symbols are allowed to be visible.
+exceptional symbols are allowed to be visible.namespace __gnu_cxx
Defaults to not exporting any symbols in label
-GLIBCXX
, select items are allowed to be visible.
namespace __gnu_cxx
GLIBCXX
, select items are allowed to be visible.namespace __gnu_internal
Defaults to not exported, no items are allowed to be visible.
+namespace __gnu_internal
namespace __cxxabiv1
, aliased to namespace abi
Defaults to not exporting any symbols in label
-CXXABI
, select items are allowed to be visible.
namespace __cxxabiv1
, aliased to namespace abi
CXXABI
, select items are allowed to be visible.+
Disallowed changes, as above, are not made on a stable release branch. Enforcement tends to be less strict with GNU extensions that -standard includes.
@@ -743,7 +752,7 @@ us. We'd like to know about them!
@@ -784,18 +793,18 @@ exceptions, locale, etc.
...with the resulting libraries looking like
%ldd libone.so.1.0.0 - libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40016000) - libm.so.6 => /lib/tls/libm.so.6 (0x400fa000) - libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x4011c000) - libc.so.6 => /lib/tls/libc.so.6 (0x40125000) - /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) + libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40016000) + libm.so.6 => /lib/tls/libm.so.6 (0x400fa000) + libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x4011c000) + libc.so.6 => /lib/tls/libc.so.6 (0x40125000) + /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) %ldd libtwo.so.1.0.0 - libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40027000) - libm.so.6 => /lib/tls/libm.so.6 (0x400e1000) - libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40103000) - libc.so.6 => /lib/tls/libc.so.6 (0x4010c000) - /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) + libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40027000) + libm.so.6 => /lib/tls/libm.so.6 (0x400e1000) + libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x40103000) + libc.so.6 => /lib/tls/libc.so.6 (0x4010c000) + /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)@@ -810,12 +819,12 @@ Which gives the expected:
%ldd a.out - libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000) - libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40015000) - libc.so.6 => /lib/tls/libc.so.6 (0x0036d000) - libm.so.6 => /lib/tls/libm.so.6 (0x004a8000) - libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x400e5000) - /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000) + libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00764000) + libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40015000) + libc.so.6 => /lib/tls/libc.so.6 (0x0036d000) + libm.so.6 => /lib/tls/libm.so.6 (0x004a8000) + libgcc_s.so.1 => /mnt/hd/bld/gcc/gcc/libgcc_s.so.1 (0x400e5000) + /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00355000)
@@ -830,28 +839,42 @@ dependent libstdc++.so.5.
ABIcheck, a vague idea of checking ABI compatibility
-http://abicheck.sourceforge.net/
+
+http://abicheck.sourceforge.net/
+
C++ ABI reference
-http://www.codesourcery.com/cxx-abi/
+
+http://www.codesourcery.com/cxx-abi/
Intel ABI documentation
+
"Intel® Compilers for Linux* -Compatibility with the GNU Compilers"
+
(included in icc 6.0)
Sun Solaris 2.9 docs
+
Linker and Libraries Guide (document 816-1386)
+
C++ Migration Guide (document 816-2459)
-http://docs.sun.com/db/prod/solaris.9
-http://docs.sun.com/?p=/doc/816-1386&a=load
+
+http://docs.sun.com/db/prod/solaris.9
+
+http://docs.sun.com/?p=/doc/816-1386&a=load
Ulrich Drepper, "ELF Symbol Versioning"
-http://people.redhat.com/drepper/symbol-versioning
+
+http://people.redhat.com/drepper/symbol-versioning