CentOS 5.8 with gcc 4.4.7 links against libstdc++ 6.0.8. How is it possible

centosgcc

According to the gcc ABI policy, gcc 4.4.7 should depend on libstdc++ 6.0.13. As far as I understood, the compiler version and the libstdc++ version are deeply interrelated and can't be swapped, so it came to me as a surprise to discover the following facts:

  • CentOS 5.8 somehow manages to have a gcc44 package that links against 6.0.8, apparently coming with the default system (which is based on gcc-4.1.2)
  • that the libstdc++.so in the compiler directory (/usr/lib/gcc/x86_64-redhat-linux6E/4.4.7, where I expected to find a libstdc++-6.0.13) is not a link to a shared object of any sort, but a text file containing INPUT ( -lstdc++_nonshared /usr/lib64/libstdc++.so.6 )

What kind of magic is going on here?

Specifically:

  • How could they provide a gcc 4.4.7 that links against an older version of libstdc++? I thought it was not possible.
  • what is this stdc++_nonshared library?
  • I didn't know a .so file could contain that text. Who parses it (dynamic linker I guess) and what are its specifications and consequences?
  • How far can this magic go? Can I use gcc4.7 with libstdc++ 6.0.3? What is the spectrum of compatibility

Best Answer

If I do a rpm -q --requires gcc44 I see the following:

libstdc++.so.6()(64bit)
libstdc++.so.6(CXXABI_1.3)(64bit)
libstdc++.so.6(GLIBCXX_3.4)(64bit)

So there is no explicit version dependency to 6.0.13 in the rpm itselv.

As you found, the libstdc++.so.6 belongs to libstdc++-4.1.2-53.el5

This Version 4.1.2 has no real meaning in RedHat - it will contain backports for newer versions as well.

Look at this: rpm -q libstdc++ --changelog|more:

* Fri Mar 23 2012 Jakub Jelinek <jakub@redhat.com> 4.1.2-53.el5
- backport N2179 exception propagation support to improve
  gcc44 as well as Developer Toolset (#806275)

So obviously RedHat is actively patching this version so it is compatible with gcc44.

Related Question