Tutorial :Is it safe to replace GCC's system-level C++ runtime with a version from newer GCC?



Question:

Linux C++ programs build with GCC link against libgcc_s.so.1 and libstdc++.so.6 libraries, each of which contains multiple ABIs: newer versions contain ABIs from previous version plus new ones. GCC ABI policy document says programs build against older runtime should be able to be run with the new runtime. So, theoretically, older binaries should be runnable on new systems.

If I have a system with an older runtime and don't want to go through the trouble of upgrading GCC on this system, can I manually replace the above mentioned libraries with new ones? In theory all old executables that link against it should work (including GCC itself), but it feels like a kludge.

Is it safe to do so?


Solution:1

Maybe, but I don't recommend it, at least not without extensive testing that would almost certainly eat up any gain. Here's why:

  • "ABI compatible" is not necessarily "bug compatible". Even if ABI compatibility is maintained, your apps might still break in surprising ways if they somehow depended on behavior that was incorrect in a previous version of the library.
  • There might be new bugs that end up breaking your apps, again without being ABI-incompatible.
  • If you don't compile the new libraries exactly right, they might not be ABI compatible.
  • Are you sure the original libraries were compiled from pristine GNU sources? Maybe there were patches you don't know about. If you can't be sure of that, you can't be sure of compatibility of your existing system/apps.

What's your goal here? If you just want to be able to compile C++ apps that use newer features, you can install a new version of GCC alongside the original, you just need to make sure all the libraries you might be using are built with the new version, too.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »