[libcxx-commits] [libcxx] r362055 - [runtimes] Check if pragma comment(lib, ...) is supported first
Petr Hosek via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 29 21:40:21 PDT 2019
Author: phosek
Date: Wed May 29 21:40:21 2019
New Revision: 362055
URL: http://llvm.org/viewvc/llvm-project?rev=362055&view=rev
Log:
[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.
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/config-ix.cmake
libcxx/trunk/src/algorithm.cpp
libcxx/trunk/src/chrono.cpp
libcxx/trunk/src/debug.cpp
libcxx/trunk/src/experimental/memory_resource.cpp
libcxx/trunk/src/filesystem/operations.cpp
libcxx/trunk/src/mutex.cpp
libcxx/trunk/src/shared_mutex.cpp
libcxx/trunk/src/thread.cpp
Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed May 29 21:40:21 2019
@@ -552,6 +552,10 @@ if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINIT
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(
Modified: libcxx/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/config-ix.cmake?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/cmake/config-ix.cmake (original)
+++ libcxx/trunk/cmake/config-ix.cmake Wed May 29 21:40:21 2019
@@ -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-
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
Modified: libcxx/trunk/src/algorithm.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/algorithm.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/algorithm.cpp (original)
+++ libcxx/trunk/src/algorithm.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/chrono.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/debug.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/debug.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/debug.cpp (original)
+++ libcxx/trunk/src/debug.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/filesystem/operations.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/filesystem/operations.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/filesystem/operations.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/shared_mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/shared_mutex.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/shared_mutex.cpp (original)
+++ libcxx/trunk/src/shared_mutex.cpp Wed May 29 21:40:21 2019
@@ -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
Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=362055&r1=362054&r2=362055&view=diff
==============================================================================
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Wed May 29 21:40:21 2019
@@ -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
More information about the libcxx-commits
mailing list