Description of problem: Define _GLIBCXX_USE_CXX11_ABI gets ignored by gcc in devtoolset-7. As a result the old CoW-String Implementation is used. But I need the new SSO-String-Implementation. Also the old implementation of std::list is used. See https://stackoverflow.com/questions/47951367/d-glibcxx-use-cxx11-abi-1-ineffective-for-devtoolset-7-on-centos-7 for another person who has the same problem. Version-Release number of selected component (if applicable): devtoolset-7 on RHEL7 How reproducible: Program to reproduce: #include <string> #include <iostream> #include <type_traits> int main() { std::cout << "_GLIBCXX_USE_CXX11_ABI=" << _GLIBCXX_USE_CXX11_ABI << std::endl; std::cout << "std::is_base_of<std::__sso_string, std::string>::value: " << std::is_base_of<std::__sso_string, std::string>::value << std::endl; std::cout << "sizeof(std::string): " << sizeof(std::string) << std::endl; return 0; } Actual results: $ scl enable devtoolset-7 bash $ g++ --version g++ (GCC) 7.2.1 20170829 (Red Hat 7.2.1-1) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ --std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1 cxx_abi_test.cpp [haegele@localhost source]$ ./a.out _GLIBCXX_USE_CXX11_ABI=0 std::is_base_of<std::__sso_string, std::string>::value: 1 sizeof(std::string): 8 $ g++ --std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 cxx_abi_test.cpp $ ./a.out _GLIBCXX_USE_CXX11_ABI=0 std::is_base_of<std::__sso_string, std::string>::value: 1 sizeof(std::string): 8 As you can see the define _GLIBCXX_USE_CXX11_ABI gets overwritten somewhere magically. Expected results: I tested with gcc (SUSE Linux) 7.1.1 20170607 [gcc-7-branch revision 248970] $ g++ -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1 cxx_abi_test.cpp haegele@Dev-05:~/source> ./a.out _GLIBCXX_USE_CXX11_ABI=1 std::is_base_of<std::__sso_string, std::string>::value: 1 sizeof(std::string): 32 $ g++ -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 cxx_abi_test.cpp haegele@Dev-05:~/source> ./a.out _GLIBCXX_USE_CXX11_ABI=0 std::is_base_of<std::__sso_string, std::string>::value: 0 sizeof(std::string): 8 Additional info: I suspect this is somehow on purpose to get compatibility with RHEL6 which doesn't support _GLIBCXX_USE_CXX11_ABI=1. However, in my case I don't care about RHEL6. I just want GCC7 on RHEL7 and that's why I'm using the devtoolset-7.
We've tried hard, but it is not possible to support this, neither on RHEL6 nor on RHEL7, which is why it is forcefully disabled. It will work in RHEL8 (and be the default there as well).
Could it be clarified if it is any different for devtoolset-9 on RHEL7? In our case: -When compiling with -D_GLIBCXX_USE_CXX11_ABI=0, we get some crash/memory corruption when using some recent version of (externally built) libraries that disappear without _GLIBCXX_USE_CXX11_ABI defined. Which would indicate there is a way to make g++ use the 'new' std::string implementation. -But when trying to rebuild a library previously built with GCC 4.8 or 7.3 or RHEL with gcc9.3 of RH7/devtoolset-9, the library seems to be compiled with the old std::string implementation So, if i understand correclty, RHEL7/devtoolset-9 is not able to generate code for that contians the new implementation (because RHEL7's base libc++ doesn't know it?), but will try by default to link to external libraries with the newest implementation?