This is an archive of the discontinued LLVM Phabricator instance.

Allow static linking of libc++ on Linux, just like -static-libstdc++
Needs ReviewPublic

Authored by erikjv on Jun 14 2019, 4:58 AM.

Details

Summary

Dynamic linking against libc++ on Linux was already supported, as is
dynamic and static linking against libstdc++. What was missing is being
able to statically link against libc++. This can be used by applications
that choose to use libc++ instead of libstdc++, but do not (or can not)
require the dynamic libraries of libc++(abi) to be installed.

Diff Detail

Event Timeline

erikjv created this revision.Jun 14 2019, 4:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jfb. · View Herald Transcript
erikjv added a comment.EditedJun 14 2019, 6:45 AM

Tests?

I'll add a test along the lines of "test/Driver/fuchsia.cpp" line 36, where it tests "-static-libstdc++".

For the short discussion we had on IRC: there currently is no real protection on mixing things like -stdlib=libc++ and -static-libstdc++ in the linker command-line, other than the linker complaining about missing symbols. I've been looking at the drivers, but I'm not sure in which Tool subclass to put the check.

hfinkel added inline comments.
clang/lib/Driver/ToolChains/Gnu.cpp
570

Why does this say FIXME?

574

It seems to me that, in general, the answer will be yes. std::thread is built on pthreads, generally, and if we need to change this for particular systems, then that can always be done as a special case.

@erikjv Are you still working on this? Or is a better alternative being pursued? IIUC, this functionality is still missing in trunk.

ldionne changed the repository for this revision from rC Clang to rG LLVM Github Monorepo.
jansvoboda11 resigned from this revision.Feb 19 2021, 5:19 AM

Is this going to continue?
And also if we use libunwind to handle EH, then it uses dladdr function which need link libdl.

Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 6:57 PM
Herald added a subscriber: MaskRay. · View Herald Transcript