Boost logo

Boost Users :

Subject: Re: [Boost-users] How to build Boost with Clang/libc++ and NOT link against libstdc++?
From: Deniz Bahadir (deniz.bahadir_at_[hidden])
Date: 2017-01-20 08:26:07


Hi Jürgen,

thanks for your answer.

Am 20.01.2017 um 12:40 schrieb Jürgen Hunold:
> Hi Deniz,
>
> Am Freitag, 20. Januar 2017, 10:13:56 CET schrieb Deniz Bahadir:
>> Hi guys,
>> I am able to build the Boost libraries using Clang and flags "-std=c++14
>> -stdlib=libc++", however, I noticed that several libraries are still
>> linked against GCC's standard-library "libstdc++".
>
> This works for me for quite a while. Please make sure you rebuild all
> libraries. Hint: b2 does not cache compiler flags. Add "-a" to your command
> line to force a full rebuild.
>
> [...]
>
> Most probably a not clean rebuild.
>

I built the libraries using our build-server which made sure to use an
entirely new build- and source-directory. So that should not be the
problem in my case.

>
>> dll-path==/opt/BENOCS/clang38/lib/x86_64-linux-gnu \
>> toolset=clang-3.8 \
>
> The toolset "clang-3.8" is configured where and how?
>

I cannot really tell. At least it works. It uses the correct
clang-executable.

>> cflags="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
>
> cxxflags="$CXXFLAGS"
>

Yes, you are right. However, that error just went in when writing this
email. The build-server used the correct command.

>> linkflags="-Wl,--as-needed $LINK_LIBCXXABI"
>
> I'd put the extra flags into user-/project-/site-config.jam.
>

I am not so fond of using these. I always get confused how they work,
where they have to be located and to what project it applies.
Especially, as our build-server builds boost with several compilers with
(possibly) different settings.

>> For the environment-variable LINK_LIBCXXABI I tried "-lc++abi" as well
>> and also tried providing it only in the cxxflags or the linkflags or
>> both (as above).
>
> linkflags should contain "-stdlib=libc++", too
>

I think, that did the trick. :-)
It no longer links against "libstdc++".

> [...]
>
>> PS: BTW, does anyone know if it is correct, that shared libraries (in
>> general) that are linked against "libc++abi" do always also link to
>> "libgcc_s"? (What is it for?)
>
> The basic compiler runtime AFAIK. Might be replaced by clang's compiler-rt, I
> guess. But that is off-topic
>

Thanks for this additional insight.

> Yours,
>
> Jürgen
>

Thanks a lot,
Deniz

-- 
BENOCS GmbH
Dipl.-Inform. Deniz Bahadir
Winterfeldtstr. 21
10781 Berlin
Germany
Phone: +49 - 30 / 577 0004-22
Email: deniz.bahadir_at_[hidden]
www.benocs.com
Board of Management:
   Michael Wolz, Dr.-Ing. Oliver Holschke, Dr.-Ing. Ingmar Poese
Commercial Register: Amtsgericht Bonn HRB 19378

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net