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

Alexey Samsonov via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 18 15:13:52 PST 2015


samsonov added a comment.

In http://reviews.llvm.org/D15598#314127, @rafael wrote:

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


Interesting.
I was assuming that Clang tends to understand "-lstdc++" as a special argument that says "link against C++ standard library", not "link against libstdc++.{a,so}".
For instance,

  clang a.cc -lstdc++ -stdlib=libc++

will effectively replace "-lstdc++" with "-lc++", and

  clang++ a.cc -stdlib=libc++ -static-libstdc++

will link against libc++ statically. In that sense, it makes sense to assume that "-static-libstdc++" will bind to "-lstdc++" argument.

Apparently, it's not what GCC does :( Do you think we should keep being compatible 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)



http://reviews.llvm.org/D15598





More information about the cfe-commits mailing list