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: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Jeffrey Walton <noloader at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 24 Mar 2016 13:05:19 +0100
- 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> <CAH8yC8=41wasMdE0XXmAZ+m3Jc4B_7MAgodhjtueZw+CgjByQw at mail dot gmail dot com>
On 2016.03.24 at 07:57 -0400, Jeffrey Walton wrote:
> >> 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).
There is no way to make it work at the moment. You have to wait until
the clang bug gets finally fixed.
--
Markus