diff --git a/src/algorithm.cpp b/src/algorithm.cpp index 28e452f52..5ce2a23b4 100644 --- a/src/algorithm.cpp +++ b/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/src/chrono.cpp b/src/chrono.cpp index c1eb67b61..a2f88c94c 100644 --- a/src/chrono.cpp +++ b/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/src/condition_variable.cpp b/src/condition_variable.cpp index 4022ff2e9..69264c680 100644 --- a/src/condition_variable.cpp +++ b/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/src/debug.cpp b/src/debug.cpp index 7fdf90c37..950241310 100644 --- a/src/debug.cpp +++ b/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/src/experimental/memory_resource.cpp b/src/experimental/memory_resource.cpp index 22bc12c10..84c950804 100644 --- a/src/experimental/memory_resource.cpp +++ b/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/src/filesystem/operations.cpp b/src/filesystem/operations.cpp index 5ba979ca9..319d9f65d 100644 --- a/src/filesystem/operations.cpp +++ b/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/src/memory.cpp b/src/memory.cpp index 8b05c3f16..6df7226b3 100644 --- a/src/memory.cpp +++ b/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/src/mutex.cpp b/src/mutex.cpp index cecb89b33..d100f2df2 100644 --- a/src/mutex.cpp +++ b/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/src/shared_mutex.cpp b/src/shared_mutex.cpp index e918e1bdf..3f1aecfdf 100644 --- a/src/shared_mutex.cpp +++ b/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/src/thread.cpp b/src/thread.cpp index 29b06fdf6..92690f667 100644 --- a/src/thread.cpp +++ b/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()