]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | C++17 and libstdc++ ABI |
2 | ======================= | |
3 | ||
4 | Ceph has switched over to C++17 in mimic. To build Ceph on old distros without | |
5 | GCC-7, it is required to install GCC-7 from additionary repos. On RHEL/CentOS, | |
6 | we are using devtoolset-7_ from SCLs_ for building Ceph. But devltoolset-7 is | |
7 | always using the old ABI_ even if ``_GLIBCXX_USE_CXX11_ABI=1`` is defined. So, | |
8 | on RHEL/CentOS, the old implementations of ``std::string`` and ``std::list`` | |
9 | are still used. In other words, ``std::string`` is still copy-on-write, and | |
10 | ``std::list::size()`` is still O(n) on these distros. But on Ubuntu Xenial, | |
11 | Ceph is built using the new ABI. So, because we are still using libstdc++ and | |
12 | devtoolset for building packages on RHEL/CentOS, please do not rely on the | |
13 | behavior of the new ABI or the old one. | |
14 | ||
15 | For those who argue that "GCC supports dual ABI!", here comes the long story. | |
16 | The problem is in the system shared library and ``libstdc++_nonshared.a`` model. | |
17 | If some symbol is exported from the system shared library, we must use that, and | |
18 | cannot override it. Also, the dual ABI support requires several of the system | |
19 | shared library symbols to behave differently (e.g. for locale facets, need | |
20 | to register twice as many, one set for old ABI, another for new ABI). So, this | |
21 | leaves us with no options but to stick with the old ABI, if we want to enable | |
22 | the built binaries to run on old distros where only the libstdc++ with the old | |
23 | ABI is available. | |
24 | ||
25 | .. _ABI: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html | |
26 | .. _devtoolset-7: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ | |
27 | .. _SCLs: https://www.softwarecollections.org/ |