IT lexicon › Programming › Dual ABI (libstdc++)

Dual ABI (libstdc++)

Programming På svenska → Updated: 2026-11-07

GCC's 2015 trick for replacing std::string without breaking every existing C++ binary on Linux: two versions side by side, chosen by a macro.

C++11 effectively outlawed the copy-on-write string libstdc++ had shipped for over a decade, and required std::list::size() to run in constant time. Both changes alter object layout. GCC 5 therefore put the new types in std::__cxx11, made an inline namespace so source code still says std::string. The mangled names differ, so old and new code can't mix them up by accident. The macro _GLIBCXX_USE_CXX11_ABI picks which version a translation unit sees, and the abi_tag attribute marks functions whose return type changed.

Elegant in theory. In practice it produced years of undefined-symbol errors with __cxx11 in the name, whenever a prebuilt library had been compiled with one setting and the program with the other. Red Hat's toolchains stuck with the old ABI for a long time for exactly that reason.

← Back to the lexicon