This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to provide coexisting std::string's (with and without abi:cxx11) in GCC 5.1 and above?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 24 Mar 2016 07:57:42 -0400
- Subject: Re: How to provide coexisting std::string's (with and without abi:cxx11) in GCC 5.1 and above?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8ne=Dy7onnzDLmq8FYHJNkmXHQGHUiQjctRBLf9fc5Ljg at mail dot gmail dot com> <20160324105416 dot GA311 at x4> <CAH8yC8mbwwu2psUKfXEHc+oQ-jcYmZvoQT7mgvxRYROF3wo=9g at mail dot gmail dot com> <20160324114942 dot GB311 at x4>
- Reply-to: noloader at gmail dot com
>> Please forgive my ignorance... What is the "coexistence" that is
>> discussed? Naively, I thought it would have been something like this
>> contrived example:
>>
>> $ cat test.cxx
>> #include <string>
>>
>> std::string foo __attribute__ ((visibility ("default")));
>> std::string bar __attribute__ ((visibility ("default")));
>>
>> $ g++ -g3 -O2 -shared test.cxx -o test.so
>>
>> $ nm test.so | grep _Z3
>> ...
>> 0000201c B _Z3barB5cxx11
>> 00002034 B _Z3fooB5cxx11
>>
>> $ echo _Z3fooB5cxx11 _Z3barB5cxx11 | c++filt
>> foo[abi:cxx11] bar[abi:cxx11]
>> foo bar
>>
>> In the above contrived example, foo and bar are in both namespaces.
>> That is, the symbol coexists and "things just work".
>
> Consider the following example:
>
> markus@x4 /tmp % cat test.cpp
> #include <string>
>
> struct Test {
> __attribute__((used)) std::string foo() { return "foo"; };
> };
>
> markus@x4 /tmp % g++ -c test.cpp && nm test.o | grep _ZN4Test
> 0000000000000000 W _ZN4Test3fooB5cxx11Ev
> markus@x4 /tmp % clang++ -c test.cpp && nm test.o | grep _ZN4Test
> 0000000000000000 W _ZN4Test3fooEv
Exactly! How do I get both _ZN4Test3fooB5cxx11Ev and _ZN4Test3fooEv
into the shared object so both GCC and Clang "just work". I thought
that's what "coexistence" meant, but it appears to mean something else
(that I have not been able to nail down).
Jeff