diff options
author | Petr Hosek <phosek@chromium.org> | 2019-05-30 04:34:41 +0300 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2019-05-30 04:34:41 +0300 |
commit | 996e62eef750942e174c4b80892b28e198e3a8d0 (patch) | |
tree | 2e09939f07555f5484d37ca2f644413f42ba6e86 /libcxxabi/src/cxa_thread_atexit.cpp | |
parent | 7e041d6dac7489735915ff1879992dc25cb365bc (diff) |
[runtimes] Support ELF dependent libraries feature
As of r360984, LLD supports dependent libraries feature for ELF.
libunwind, libc++abi and libc++ have library dependencies: libdl librt
and libpthread, which means that when libunwind and libc++ are being
statically linked (using -static-libstdc++ flag), user has to manually
specify -ldl -lpthread which is onerous.
This change includes the lib pragma to specify the library dependencies
directly in the source that uses those libraries. This doesn't make any
difference when using linkers that don't support dependent libraries.
However, when using LLD that has dependent libraries feature, users no
longer have to manually specifying library dependencies when using
static linking, linker will pick the library automatically.
Differential Revision: https://reviews.llvm.org/D62090
llvm-svn: 362048
Diffstat (limited to 'libcxxabi/src/cxa_thread_atexit.cpp')
-rw-r--r-- | libcxxabi/src/cxa_thread_atexit.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libcxxabi/src/cxa_thread_atexit.cpp b/libcxxabi/src/cxa_thread_atexit.cpp index da1df8617088..38787f18fe30 100644 --- a/libcxxabi/src/cxa_thread_atexit.cpp +++ b/libcxxabi/src/cxa_thread_atexit.cpp @@ -9,6 +9,12 @@ #include "abort_message.h" #include "cxxabi.h" #include <__threading_support> +#ifndef _LIBCXXABI_HAS_NO_THREADS +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif +#endif + #include <cstdlib> namespace __cxxabiv1 { |