Boost ABI/Linkage of clang vs g++

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
[hidden email]

We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so build a copy of boost in each configuration as well.  This works great on the Mac development machines but the clang case doesn't generate the correct linkage on the Linux deployment machines.  The correct clang linkage is std::__1::basic_string... but boost builds with std::__cxx11::basic_string

Here's the linkage of libc++:

$ objdump -T /usr/lib/llvm-10/lib/libc++.so.1|c++filt|grep ::basic_string|head -1
0000000000057450 g    DF .text 0000000000000048  Base        std::__1::locale::locale(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

Notice: std::__1::basic_string< ...

When compiling my own code with clang++-10 the correct symbol is generated:

$ nm options.cc.o |c++filt |fgrep __ |fgrep ::set_option_name |head -1
0000000000000000 W fmt::v6::basic_format_context<std::__1::back_insert_iterator<fmt::v6::internal::buffer<char> >, char>::iterator...

Notice std::__1:: ...

However the boost object have the wrong symbol name:

$ nm 3P/llvm/lib/libboost_program_options.a |c++filt |fgrep __ |fgrep ::basic_string |head -1
0000000000000000 W boost::program_options::unknown_option::unknown_option(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

Notice std::__cxx11::basic_string< ...


I'm compiling boost this way:
export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread threading=multi -sNO_COMPRESSION=1 link=static install

It's 1.73.0

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
<[hidden email]> wrote:

> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so build a copy of boost in each configuration as well.  This works great on the Mac development machines but the clang case doesn't generate the correct linkage on the Linux deployment machines.  The correct clang linkage is std::__1::basic_string... but boost builds with std::__cxx11::basic_string

libc++ is not binary compatible with libstdc++.
You need to use either libstdc++ or libc++ with both compilers if you
want binary compatibility.

This doesn't have anything to do with Boost.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list

> On Jul 9, 2020, at 04:25, Mathias Gaunard <[hidden email]> wrote:
>
> On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
> <[hidden email]> wrote:
>
>> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so build a copy of boost in each configuration as well.  This works great on the Mac development machines but the clang case doesn't generate the correct linkage on the Linux deployment machines.  The correct clang linkage is std::__1::basic_string... but boost builds with std::__cxx11::basic_string
>
> libc++ is not binary compatible with libstdc++.
> You need to use either libstdc++ or libc++ with both compilers if you
> want binary compatibility.
>
> This doesn't have anything to do with Boost.

Thanks Mathias.  I did not express my problem clearly.  This is a b2 issue; I doubt any _library source code_ has any direct interaction with this and I'm sorry if I accidentally gave that impression.  Is there a way to get b2 to disgorge the environment and tool invocation of each step (basically what is passed to system() or exec())?

The background, perhaps clarified:

We have our own code, some third party code (like Boost) and of course different runtime platforms (Mac, iOS, Linux...).  Since different platforms use different compilers/runtimes as their "native" stack, our development system builds everything end-to-end with both gcc and clang to catch problems as early as possible.  All compilation is with c++14 or later, post the C++11 ABI break, hence the naming issues.  This process isolates us from any system libraries that don't have C linkage.

Therefore g++ is used to compile libstdc++, boost, other third party code, and our code.  Symbols are generated that use __c++11:: in their name.
And clang++ is used to compile libc++, boost, other third party code, and our code.  Symbols are generated that use use __1:: in their name.

But boost itself is compiled via b2 and what is passed to the compiler (and which compiler b2 chooses) is quite opaque.  Despite my attempts to force the use of clang it appears that b2 is either calling g++ or otherwise asking clang to use g++-style symbol linkage on Linux. On the Mac the same invocation behaves as expected.

I'm compiling boost this way:

export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread threading=multi -sNO_COMPRESSION=1 link=static install

Any thoughts on how to debug this?
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list


> -----Original Message-----
> From: Boost-users <[hidden email]> On Behalf Of DV Henkel-Wallace via Boost-
> users
> Sent: 9 July 2020 15:41
> To: Mathias Gaunard <[hidden email]>
> Cc: DV Henkel-Wallace <[hidden email]>; [hidden email]
> Subject: Re: [Boost-users] Boost ABI/Linkage of clang vs g++
>
>
> > On Jul 9, 2020, at 04:25, Mathias Gaunard <[hidden email]> wrote:
> >
> > On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
> > <[hidden email]> wrote:
> >
> >> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so
> >> build a copy of boost in each configuration as well.  This works
> >> great on the Mac development machines but the clang case doesn't
> >> generate the correct linkage on the Linux deployment machines.  The
> >> correct clang linkage is std::__1::basic_string... but boost builds
> >> with std::__cxx11::basic_string
> >
> > libc++ is not binary compatible with libstdc++.
> > You need to use either libstdc++ or libc++ with both compilers if you
> > want binary compatibility.
> >
> > This doesn't have anything to do with Boost.
>
> Thanks Mathias.  I did not express my problem clearly.  This is a b2 issue; I doubt any _library source
> code_ has any direct interaction with this and I'm sorry if I accidentally gave that impression.  Is there a
> way to get b2 to disgorge the environment and tool invocation of each step (basically what is passed to
> system() or exec())?
>
> The background, perhaps clarified:
>
> We have our own code, some third party code (like Boost) and of course different runtime platforms
> (Mac, iOS, Linux...).  Since different platforms use different compilers/runtimes as their "native" stack,
> our development system builds everything end-to-end with both gcc and clang to catch problems as
> early as possible.  All compilation is with c++14 or later, post the C++11 ABI break, hence the naming
> issues.  This process isolates us from any system libraries that don't have C linkage.
>
> Therefore g++ is used to compile libstdc++, boost, other third party code, and our code.  Symbols are
> generated that use __c++11:: in their name.
> And clang++ is used to compile libc++, boost, other third party code, and our code.  Symbols are
> generated that use use __1:: in their name.
>
> But boost itself is compiled via b2 and what is passed to the compiler (and which compiler b2 chooses) is
> quite opaque.  Despite my attempts to force the use of clang it appears that b2 is either calling g++ or
> otherwise asking clang to use g++-style symbol linkage on Linux. On the Mac the same invocation
> behaves as expected.
>
> I'm compiling boost this way:
>
> export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang
> boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --
> with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread
> threading=multi -sNO_COMPRESSION=1 link=static install
>
> Any thoughts on how to debug this?

Does b2 -debug-configuration help?

https://boostorg.github.io/build/manual/master/index.html   section 3.3 configuration


        You can use the --debug-configuration option to find which configuration files are actually loaded.

Paul



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
> Date: Thu, 9 Jul 2020 16:44:58 +0100
> From: <[hidden email]>
>
> Does b2 -debug-configuration help?
>
> https://boostorg.github.io/build/manual/master/index.html   section 3.3 configuration
>
> ?
> You can use the --debug-configuration option to find which configuration files are actually loaded.

Thanks, Paul, this helped me figure out a colleague had modified a .jam file and checked it in. -d
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
the reality is that most of us have no time to read the fuckin'docs, coz my wife would like diner in time today. Boost is not helpful in maintaining my family-relationships. The latter are my top-priorities. More and more Boost is in-compatible with my definition of being a happy chappy and based on this I try to avoid Boost, becoz daddy has to work to much, reading all that old shit a.o.t. helping me to fix a small bit of irrelevant (in the global picture) without getting a cross-examination to determine whether we would like to help degski to achieve his main goal in life, that is to say taking care of my loved ones some of them carrying half my genes (i.e. a bad copy of myself, they call those children, they are in the branch devel. and they are the future.

On Thu, 9 Jul 2020 at 18:52, Paul A. Bristow via Boost-users <[hidden email]> wrote:


> -----Original Message-----
> From: Boost-users <[hidden email]> On Behalf Of DV Henkel-Wallace via Boost-
> users
> Sent: 9 July 2020 15:41
> To: Mathias Gaunard <[hidden email]>
> Cc: DV Henkel-Wallace <[hidden email]>; [hidden email]
> Subject: Re: [Boost-users] Boost ABI/Linkage of clang vs g++
>
>
> > On Jul 9, 2020, at 04:25, Mathias Gaunard <[hidden email]> wrote:
> >
> > On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
> > <[hidden email]> wrote:
> >
> >> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so
> >> build a copy of boost in each configuration as well.  This works
> >> great on the Mac development machines but the clang case doesn't
> >> generate the correct linkage on the Linux deployment machines.  The
> >> correct clang linkage is std::__1::basic_string... but boost builds
> >> with std::__cxx11::basic_string
> >
> > libc++ is not binary compatible with libstdc++.
> > You need to use either libstdc++ or libc++ with both compilers if you
> > want binary compatibility.
> >
> > This doesn't have anything to do with Boost.
>
> Thanks Mathias.  I did not express my problem clearly.  This is a b2 issue; I doubt any _library source
> code_ has any direct interaction with this and I'm sorry if I accidentally gave that impression.  Is there a
> way to get b2 to disgorge the environment and tool invocation of each step (basically what is passed to
> system() or exec())?
>
> The background, perhaps clarified:
>
> We have our own code, some third party code (like Boost) and of course different runtime platforms
> (Mac, iOS, Linux...).  Since different platforms use different compilers/runtimes as their "native" stack,
> our development system builds everything end-to-end with both gcc and clang to catch problems as
> early as possible.  All compilation is with c++14 or later, post the C++11 ABI break, hence the naming
> issues.  This process isolates us from any system libraries that don't have C linkage.
>
> Therefore g++ is used to compile libstdc++, boost, other third party code, and our code.  Symbols are
> generated that use __c++11:: in their name.
> And clang++ is used to compile libc++, boost, other third party code, and our code.  Symbols are
> generated that use use __1:: in their name.
>
> But boost itself is compiled via b2 and what is passed to the compiler (and which compiler b2 chooses) is
> quite opaque.  Despite my attempts to force the use of clang it appears that b2 is either calling g++ or
> otherwise asking clang to use g++-style symbol linkage on Linux. On the Mac the same invocation
> behaves as expected.
>
> I'm compiling boost this way:
>
> export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang
> boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --
> with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread
> threading=multi -sNO_COMPRESSION=1 link=static install
>
> Any thoughts on how to debug this?

Does b2 -debug-configuration help?

https://boostorg.github.io/build/manual/master/index.html   section 3.3 configuration


        You can use the --debug-configuration option to find which configuration files are actually loaded.

Paul



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
i forgot the most important to all: "go suck eggs, please".

On Fri, 17 Jul 2020 at 03:46, degski <[hidden email]> wrote:
the reality is that most of us have no time to read the fuckin'docs, coz my wife would like diner in time today. Boost is not helpful in maintaining my family-relationships. The latter are my top-priorities. More and more Boost is in-compatible with my definition of being a happy chappy and based on this I try to avoid Boost, becoz daddy has to work to much, reading all that old shit a.o.t. helping me to fix a small bit of irrelevant (in the global picture) without getting a cross-examination to determine whether we would like to help degski to achieve his main goal in life, that is to say taking care of my loved ones some of them carrying half my genes (i.e. a bad copy of myself, they call those children, they are in the branch devel. and they are the future.

On Thu, 9 Jul 2020 at 18:52, Paul A. Bristow via Boost-users <[hidden email]> wrote:


> -----Original Message-----
> From: Boost-users <[hidden email]> On Behalf Of DV Henkel-Wallace via Boost-
> users
> Sent: 9 July 2020 15:41
> To: Mathias Gaunard <[hidden email]>
> Cc: DV Henkel-Wallace <[hidden email]>; [hidden email]
> Subject: Re: [Boost-users] Boost ABI/Linkage of clang vs g++
>
>
> > On Jul 9, 2020, at 04:25, Mathias Gaunard <[hidden email]> wrote:
> >
> > On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
> > <[hidden email]> wrote:
> >
> >> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so
> >> build a copy of boost in each configuration as well.  This works
> >> great on the Mac development machines but the clang case doesn't
> >> generate the correct linkage on the Linux deployment machines.  The
> >> correct clang linkage is std::__1::basic_string... but boost builds
> >> with std::__cxx11::basic_string
> >
> > libc++ is not binary compatible with libstdc++.
> > You need to use either libstdc++ or libc++ with both compilers if you
> > want binary compatibility.
> >
> > This doesn't have anything to do with Boost.
>
> Thanks Mathias.  I did not express my problem clearly.  This is a b2 issue; I doubt any _library source
> code_ has any direct interaction with this and I'm sorry if I accidentally gave that impression.  Is there a
> way to get b2 to disgorge the environment and tool invocation of each step (basically what is passed to
> system() or exec())?
>
> The background, perhaps clarified:
>
> We have our own code, some third party code (like Boost) and of course different runtime platforms
> (Mac, iOS, Linux...).  Since different platforms use different compilers/runtimes as their "native" stack,
> our development system builds everything end-to-end with both gcc and clang to catch problems as
> early as possible.  All compilation is with c++14 or later, post the C++11 ABI break, hence the naming
> issues.  This process isolates us from any system libraries that don't have C linkage.
>
> Therefore g++ is used to compile libstdc++, boost, other third party code, and our code.  Symbols are
> generated that use __c++11:: in their name.
> And clang++ is used to compile libc++, boost, other third party code, and our code.  Symbols are
> generated that use use __1:: in their name.
>
> But boost itself is compiled via b2 and what is passed to the compiler (and which compiler b2 chooses) is
> quite opaque.  Despite my attempts to force the use of clang it appears that b2 is either calling g++ or
> otherwise asking clang to use g++-style symbol linkage on Linux. On the Mac the same invocation
> behaves as expected.
>
> I'm compiling boost this way:
>
> export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang
> boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --
> with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread
> threading=multi -sNO_COMPRESSION=1 link=static install
>
> Any thoughts on how to debug this?

Does b2 -debug-configuration help?

https://boostorg.github.io/build/manual/master/index.html   section 3.3 configuration


        You can use the --debug-configuration option to find which configuration files are actually loaded.

Paul



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost ABI/Linkage of clang vs g++

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
Am 09.07.20 um 16:40 schrieb DV Henkel-Wallace via Boost-users:

>
>> On Jul 9, 2020, at 04:25, Mathias Gaunard <[hidden email]> wrote:
>>
>> On Thu, 9 Jul 2020 at 08:07, DV Henkel-Wallace via Boost-users
>> <[hidden email]> wrote:
>>
>>> We build with clang++-10 w/libc++.a and g++-10 w/libstdc++.a, so build a copy of boost in each configuration as well.  This works great on the Mac development machines but the clang case doesn't generate the correct linkage on the Linux deployment machines.  The correct clang linkage is std::__1::basic_string... but boost builds with std::__cxx11::basic_string
>>
>> libc++ is not binary compatible with libstdc++.
>> You need to use either libstdc++ or libc++ with both compilers if you
>> want binary compatibility.
>>
>> This doesn't have anything to do with Boost.
>
> Thanks Mathias.  I did not express my problem clearly.  This is a b2 issue; I doubt any _library source code_ has any direct interaction with this and I'm sorry if I accidentally gave that impression.  Is there a way to get b2 to disgorge the environment and tool invocation of each step (basically what is passed to system() or exec())?
>
> The background, perhaps clarified:
>
> We have our own code, some third party code (like Boost) and of course different runtime platforms (Mac, iOS, Linux...).  Since different platforms use different compilers/runtimes as their "native" stack, our development system builds everything end-to-end with both gcc and clang to catch problems as early as possible.  All compilation is with c++14 or later, post the C++11 ABI break, hence the naming issues.  This process isolates us from any system libraries that don't have C linkage.
>
> Therefore g++ is used to compile libstdc++, boost, other third party code, and our code.  Symbols are generated that use __c++11:: in their name.
> And clang++ is used to compile libc++, boost, other third party code, and our code.  Symbols are generated that use use __1:: in their name.
>
> But boost itself is compiled via b2 and what is passed to the compiler (and which compiler b2 chooses) is quite opaque.  Despite my attempts to force the use of clang it appears that b2 is either calling g++ or otherwise asking clang to use g++-style symbol linkage on Linux. On the Mac the same invocation behaves as expected.
>
> I'm compiling boost this way:
>
> export CC=clang CXX="clang++ -stdlib=libc++" CXXSTD=c++20 ; ./b2 stdlib=libc++ toolset=clang boost.locale.icu=off boost.locale.std=off --with-atomic --with-chrono --with-date_time --with-headers --with-locale --with-log --with-program_options --with-random --with-regex --with-system --with-thread threading=multi -sNO_COMPRESSION=1 link=static install
>
> Any thoughts on how to debug this?

Just a wild guess, but could it be that your combined value for
environment variable CXX is not used verbatim by b2?

You should probably try to set CXX only to the compiler-executable and
put the `-stdlib=libc++` option into CXXFLAGS environment variable.

If b2 has an option `stdlib=libc++` I am also not sure.

For me it always succeeds by building Boost with Clang and libc++ like this:

```
./b2 toolset=clang cxxflags="-std=c++20 -stdlib=libc++"
linkflags="-stdlib=libc++" cxxstd=20 install ...
```

Probably I could omit the `cxxflags` option but I have not tried it lately.

Hope that helps,
Deniz


--
BENOCS GmbH
Dipl.-Inform. Deniz Bahadir
Reuchlinstr. 10 D
10553 Berlin
Germany
Phone: +49 - 30 / 577 0004-22
Email: [hidden email]
www.benocs.com

Board of Management: Stephan Schröder, Dr.-Ing. Ingmar Poese
Commercial Register: Amtsgericht Bonn HRB 19378
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users