diff options
| author | Petr Hosek <phosek@chromium.org> | 2019-05-30 04:40:21 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2019-05-30 04:40:21 +0000 |
| commit | 789b7f0828b08f5c4bf9ff1ff7ef733c73ecdc0a (patch) | |
| tree | 529f48a2d6693be385cf978860ec04995e6dfe86 /libcxx | |
| parent | 2c91c3b7af7cd4da64f1babde3798d65522a21e4 (diff) | |
| download | llvm-789b7f0828b08f5c4bf9ff1ff7ef733c73ecdc0a.tar.gz | |
[runtimes] Check if pragma comment(lib, ...) is supported first
This fixes the issue introduced by r362048 where we always use
pragma comment(lib, ...) for dependent libraries when the compiler
is Clang, but older Clang versions don't support this pragma so
we need to check first if it's supported before using it.
llvm-svn: 362055
Diffstat (limited to 'libcxx')
| -rw-r--r-- | libcxx/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | libcxx/cmake/config-ix.cmake | 10 | ||||
| -rw-r--r-- | libcxx/src/algorithm.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/chrono.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/debug.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/experimental/memory_resource.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/filesystem/operations.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/mutex.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/shared_mutex.cpp | 2 | ||||
| -rw-r--r-- | libcxx/src/thread.cpp | 2 |
10 files changed, 21 insertions, 9 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 1096898d055e..50ccbf6c4261 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -552,6 +552,10 @@ if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() +if (LIBCXX_HAS_COMMENT_LIB_PRAGMA) + add_definitions(-D_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +endif() + # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake index 23ae71025e54..b2d275bbb25a 100644 --- a/libcxx/cmake/config-ix.cmake +++ b/libcxx/cmake/config-ix.cmake @@ -1,6 +1,7 @@ include(CheckLibraryExists) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) +include(CheckCSourceCompiles) if(WIN32 AND NOT MINGW) # NOTE(compnerd) this is technically a lie, there is msvcrt, but for now, lets @@ -59,6 +60,14 @@ if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) endif () endif () +# Check compiler pragmas +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + check_c_source_compiles(" +#pragma comment(lib, \"c\") +int main() { return 0; } +" LIBCXX_HAS_COMMENT_LIB_PRAGMA) +endif() + if(NOT WIN32 OR MINGW) include(CheckLibcxxAtomic) endif() @@ -72,7 +81,6 @@ check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG) check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG) check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG) - # Check libraries if(WIN32 AND NOT MINGW) # TODO(compnerd) do we want to support an emulation layer that allows for the diff --git a/libcxx/src/algorithm.cpp b/libcxx/src/algorithm.cpp index 5ce2a23b464f..a110ae8b1a6e 100644 --- a/libcxx/src/algorithm.cpp +++ b/libcxx/src/algorithm.cpp @@ -10,7 +10,7 @@ #include "random" #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp index a2f88c94c077..8f533f1059ed 100644 --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -37,7 +37,7 @@ #endif #endif -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "rt") #endif diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp index 950241310112..c4cc281d586b 100644 --- a/libcxx/src/debug.cpp +++ b/libcxx/src/debug.cpp @@ -15,7 +15,7 @@ #include "__hash_table" #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp index 84c95080496f..9aa077942b0d 100644 --- a/libcxx/src/experimental/memory_resource.cpp +++ b/libcxx/src/experimental/memory_resource.cpp @@ -12,7 +12,7 @@ #include "atomic" #elif !defined(_LIBCPP_HAS_NO_THREADS) #include "mutex" -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index 319d9f65d738..69350ddfe9da 100644 --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -44,7 +44,7 @@ #include <sys/time.h> // for gettimeofday and timeval #endif // !defined(CLOCK_REALTIME) -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "rt") #endif diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp index d100f2df2338..33a8197dadf8 100644 --- a/libcxx/src/mutex.cpp +++ b/libcxx/src/mutex.cpp @@ -13,7 +13,7 @@ #include "__undef_macros" #ifndef _LIBCPP_HAS_NO_THREADS -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/shared_mutex.cpp b/libcxx/src/shared_mutex.cpp index 3f1aecfdfe19..eb3f5f3506f5 100644 --- a/libcxx/src/shared_mutex.cpp +++ b/libcxx/src/shared_mutex.cpp @@ -10,7 +10,7 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include "shared_mutex" -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index 92690f667982..39bb9e9bac63 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -35,7 +35,7 @@ #include <windows.h> #endif -#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) #pragma comment(lib, "pthread") #endif |
