Skip to content

Comments

Fix test suite C++ test with GCC 5.1 dual ABI#5686

Merged
WalterBright merged 1 commit intodlang:masterfrom
CyberShadow:pull-20160419-055620
Apr 20, 2016
Merged

Fix test suite C++ test with GCC 5.1 dual ABI#5686
WalterBright merged 1 commit intodlang:masterfrom
CyberShadow:pull-20160419-055620

Conversation

@CyberShadow
Copy link
Member

GCC 5.1 introduced new implementations of std::string and std::list:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

This causes e.g. std::string to be actually defined as std::__cxx11::string.

On machines with GCC 5.1, this manifests as a linker error when running the cppa.d / cppb.cpp test:

cppa.o: In function `_D4cppa6test14FZv':
cppa.d:(.text._D4cppa6test14FZv+0x11): undefined reference to `foo14a(std::string*)'
cppa.d:(.text._D4cppa6test14FZv+0x18): undefined reference to `foo14b(std::basic_string<int, std::char_traits<int>, std::allocator<int> >*)'
cppa.d:(.text._D4cppa6test14FZv+0x3a): undefined reference to `foo14f(std::char_traits<char>*, std::string*, std::string*)'
cppa.o: In function `_D4cppa7testeh3FZv':
cppa.d:(.text._D4cppa7testeh3FZv+0x19): undefined reference to `throwle()'
collect2: error: ld returned 1 exit status
--- errorlevel 1

When the .cpp file is compiled with g++ 5.3.0, the actual function signatures in the cppb.o object file are:

foo14a(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)
foo14b(std::__cxx11::basic_string<int, std::char_traits<int>, std::allocator<int> >*)
foo14f(std::char_traits<char>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)

Fortunately, it is easily possible to disable the new feature by defining _GLIBCXX_USE_CXX11_ABI as 0 before including any standard headers.

@jpf91
Copy link
Contributor

jpf91 commented Apr 19, 2016

IIRC @ibuclaw also had a pull request for this issue?

@CyberShadow
Copy link
Member Author

CyberShadow commented Apr 19, 2016

I don't see anything relevant on https://github.com/dlang/dmd/pulls/ibuclaw

@jpf91
Copy link
Contributor

jpf91 commented Apr 19, 2016

I was thinking of #5262 but it seems that has already been merged and probably wasn't meant to fix this problem.

@Geod24
Copy link
Member

Geod24 commented Apr 19, 2016

Maybe #5261 ?

@WalterBright
Copy link
Member

You have a great explanation for this in the opening comment. But the code just contains the #define. Please add the explanation as a comment!

GCC 5.1 introduced new implementations of std::string and std::list:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

This causes e.g. std::string to be actually defined as
std::__cxx11::string.

On machines with GCC 5.1, this manifests as a linker error when
running the cppa.d / cppb.cpp test:

cppa.o: In function `_D4cppa6test14FZv':
cppa.d:(.text._D4cppa6test14FZv+0x11): undefined reference to `foo14a(std::string*)'
cppa.d:(.text._D4cppa6test14FZv+0x18): undefined reference to `foo14b(std::basic_string<int, std::char_traits<int>, std::allocator<int> >*)'
cppa.d:(.text._D4cppa6test14FZv+0x3a): undefined reference to `foo14f(std::char_traits<char>*, std::string*, std::string*)'
cppa.o: In function `_D4cppa7testeh3FZv':
cppa.d:(.text._D4cppa7testeh3FZv+0x19): undefined reference to `throwle()'
collect2: error: ld returned 1 exit status
--- errorlevel 1

When the .cpp file is compiled with g++ 5.3.0, the actual function
signatures in the cppb.o object file are:

foo14a(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)
foo14b(std::__cxx11::basic_string<int, std::char_traits<int>, std::allocator<int> >*)
foo14f(std::char_traits<char>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)

Fortunately, it is easily possible to disable the new feature
by defining _GLIBCXX_USE_CXX11_ABI as 0 before including any standard
headers.
@CyberShadow CyberShadow force-pushed the pull-20160419-055620 branch from b0db8a7 to a1f74ff Compare April 20, 2016 00:20
@CyberShadow
Copy link
Member Author

OK, I copied the commit message as a comment before the #define.

@WalterBright
Copy link
Member

Auto-merge toggled on

@WalterBright WalterBright merged commit 52a3bf5 into dlang:master Apr 20, 2016
@ibuclaw
Copy link
Member

ibuclaw commented Apr 23, 2016

Nope, I hadn't addressed the C++-11 problem. Maybe we can discuss a compromise between supporting the current compiler and supporting legacy at dconf. Because this is also hurting overall gdb experience too.

I honestly have half a mind in support of using something similar to -std=xxx to allow switching between ABIs.

@MartinNowak
Copy link
Member

If at all it would need to be -c++-std ;).
How about we try to detect which C++ compiler gets used? We could insist on declaring CC=myc++ when linking against C++ code. That would also obsolete the problematic usage of -L-lstdc++ with a C compiler and provides a solution for the next C++ ABI exceptions (e.g. Intel compiler).

@MartinNowak
Copy link
Member

BTW, it took me 15m. to figure out that stable tests fail on some auto-testers b/c of this, and another 30m. to find this PR.
Remember, safe fixes should always go into stable, all the time.

MartinNowak pushed a commit that referenced this pull request Jul 25, 2016
Fix test suite C++ test with GCC 5.1 dual ABI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants