Bug 1546704 - Define _GLIBCXX_USE_CXX11_ABI gets ignored by gcc in devtoolset-7
Summary: Define _GLIBCXX_USE_CXX11_ABI gets ignored by gcc in devtoolset-7
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc
Version: DTS 7.1 RHEL 7
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: alpha
: 7.1
Assignee: Marek Polacek
QA Contact: Martin Cermak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-19 11:05 UTC by Christian Hägele
Modified: 2023-07-04 13:53 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-19 11:08:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DTS-620 0 None None None 2023-07-04 13:53:47 UTC

Description Christian Hägele 2018-02-19 11:05:43 UTC
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.

Comment 2 Jakub Jelinek 2018-02-19 11:08:00 UTC
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).

Comment 3 Olivier BARTHELEMY 2023-07-04 13:53:28 UTC
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?


Note You need to log in before you can comment on or make changes to this bug.