Commit 996e62ee authored by Petr Hosek's avatar Petr Hosek
Browse files

[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
parent 7e041d6d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -8,7 +8,12 @@

#include "algorithm"
#include "random"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
#pragma comment(lib, "pthread")
#endif
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@
#endif
#endif

#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
#pragma comment(lib, "rt")
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

namespace chrono
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@
#include "system_error"
#include "__undef_macros"

#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
#pragma comment(lib, "pthread")
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

condition_variable::~condition_variable()
+5 −0
Original line number Diff line number Diff line
@@ -13,7 +13,12 @@
#include "string"
#include "cstdio"
#include "__hash_table"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
#pragma comment(lib, "pthread")
#endif
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@
#include "atomic"
#elif !defined(_LIBCPP_HAS_NO_THREADS)
#include "mutex"
#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
#pragma comment(lib, "pthread")
#endif
#endif

_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
Loading