diff --git a/libcxx/src/algorithm.cpp b/libcxx/src/algorithm.cpp --- a/libcxx/src/algorithm.cpp +++ b/libcxx/src/algorithm.cpp @@ -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 diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -37,6 +37,10 @@ #endif #endif +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "rt") +#endif + _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono diff --git a/libcxx/src/condition_variable.cpp b/libcxx/src/condition_variable.cpp --- a/libcxx/src/condition_variable.cpp +++ b/libcxx/src/condition_variable.cpp @@ -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() diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp --- a/libcxx/src/debug.cpp +++ b/libcxx/src/debug.cpp @@ -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 diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp --- a/libcxx/src/experimental/memory_resource.cpp +++ b/libcxx/src/experimental/memory_resource.cpp @@ -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 diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -44,6 +44,10 @@ #include // for gettimeofday and timeval #endif // !defined(CLOCK_REALTIME) +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "rt") +#endif + #if defined(_LIBCPP_COMPILER_GCC) #if _GNUC_VER < 500 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp --- a/libcxx/src/memory.cpp +++ b/libcxx/src/memory.cpp @@ -10,6 +10,9 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" #include "thread" +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif #endif #include "include/atomic_support.h" diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp --- a/libcxx/src/mutex.cpp +++ b/libcxx/src/mutex.cpp @@ -12,6 +12,12 @@ #include "include/atomic_support.h" #include "__undef_macros" +#ifndef _LIBCPP_HAS_NO_THREADS +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif +#endif + _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS diff --git a/libcxx/src/shared_mutex.cpp b/libcxx/src/shared_mutex.cpp --- a/libcxx/src/shared_mutex.cpp +++ b/libcxx/src/shared_mutex.cpp @@ -10,6 +10,9 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include "shared_mutex" +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -35,6 +35,10 @@ #include #endif +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif + _LIBCPP_BEGIN_NAMESPACE_STD thread::~thread() diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -27,6 +27,9 @@ #if _LIBUNWIND_USE_DLADDR #include +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "dl") +#endif #endif #ifdef __APPLE__