[PATCH] D15598: [Driver] Make AddCXXStdlibLibArgs responsible for handling -static-libstdc++.

Rafael EspĂ­ndola via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 18 14:25:34 PST 2015


I am not sure what is "expected" is here:

$ gcc test.o -o test.so -lstdc++ -shared -static-libstdc++ && ldd
test.so | grep libst
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f848e57d000)

$ gcc test.o -o test.so -shared -static-libstdc++ -lstdc++ && ldd
test.so | grep libst
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fc25516d000)



On 16 December 2015 at 20:34, Alexey Samsonov <vonosmas at gmail.com> wrote:
> samsonov created this revision.
> samsonov added reviewers: rafael, compnerd.
> samsonov added a subscriber: cfe-commits.
>
> After this change, AddCXXStdlibLibArgs will check the presence of
> -static-libstdc++ flag and, if necessary, wrap -lc++/-lstdc++ in
> -Bstatic/-Bdynamic to force static linking of C++ standard library.
>
> It's no longer necessary to copy this code around across toolchains
> (unless toolchain is overriding AddCXXStdlibLibArgs).
>
> This change has an important consequnce: if the user provides "-lstdc++"
> manually (i.e. it's not added automatically when we're linking C++ binary),
> then "-static-libstdc++" *will* work as expected.
>
> Other than that, the change attempts to preserve the existing behavior.
>
> http://reviews.llvm.org/D15598
>
> Files:
>   lib/Driver/CrossWindowsToolChain.cpp
>   lib/Driver/ToolChain.cpp
>   lib/Driver/ToolChains.cpp
>   lib/Driver/Tools.cpp
>   test/Driver/static-libstdcxx.c
>


More information about the cfe-commits mailing list