summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-08-23 23:01:16 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-08-23 23:01:16 +0000
commit12a0b1f4c847a3dd8efc53b2fe1746fea7f2edc5 (patch)
treefab31351da98ca802a5511e3f66ade40242b9f4f /libcxx
parent84c4cc47f5fb52e680ca3f3790a7e15a3499731f (diff)
downloadbcm5719-llvm-12a0b1f4c847a3dd8efc53b2fe1746fea7f2edc5.tar.gz
bcm5719-llvm-12a0b1f4c847a3dd8efc53b2fe1746fea7f2edc5.zip
libc++: Perform configuration checks with -nodefaultlibs
We're compiling libc++ with -nodefaultlibs, so we should also pass this option during the configuration checks to ensure those checks are consistent with the actual build. The primary motivation here is to ease cross-compilation against a non-standard set of C++ libraries. Previously, the configuration checks would attempt to link against the standard C++ libraries, which would cause link failures when cross-compiling, even though the actual library link would go through correctly (because of the use of -nodefaultlibs and explicitly specifying any needed libraries). This is more correct even ignoring the motivation, however. Patch by Shoaib Meenai! llvm-svn: 279584
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/cmake/config-ix.cmake23
1 files changed, 21 insertions, 2 deletions
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 3e6c3599d23..b4c9ac482cf 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -1,5 +1,26 @@
include(CheckLibraryExists)
include(CheckCXXCompilerFlag)
+
+check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+# libc++ is built with -nodefaultlibs, so we want all our checks to also
+# use this option, otherwise we may end up with an inconsistency between
+# the flags we think we require during configuration (if the checks are
+# performed without -nodefaultlibs) and the flags that are actually
+# required during compilation (which has the -nodefaultlibs). libc is
+# required for the link to go through.
+check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES -nodefaultlibs)
+ if (LIBCXX_HAS_C_LIB)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES c)
+ endif ()
+ if (LIBCXX_HAS_GCC_S_LIB)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+ endif ()
+endif ()
+
include(CheckLibcxxAtomic)
# Check compiler flags
@@ -14,7 +35,5 @@ check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
# Check libraries
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
-check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
-check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
OpenPOWER on IntegriCloud