<p dir="ltr">What platforms was this tested on?</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Aug 22, 2016 9:20 PM, "Shoaib Meenai" <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">smeenai created this revision.<br>
smeenai added reviewers: beanz, compnerd, EricWF, mclow.lists, rsmith.<br>
smeenai added a subscriber: cfe-commits.<br>
<br>
We're compiling libc++ with -nodefaultlibs, so we should also pass this<br>
option during the configuration checks to ensure those checks are<br>
consistent with the actual build.<br>
<br>
The primary motivation here is to ease cross-compilation against a<br>
non-standard set of C++ libraries. Previously, the configuration checks<br>
would attempt to link against the standard C++ libraries, which would<br>
cause link failures when cross-compiling, even though the actual library<br>
link would go through correctly (because of the use of -nodefaultlibs<br>
and explicitly specifying any needed libraries). This is more correct<br>
even ignoring the motivation, however.<br>
<br>
<a href="https://reviews.llvm.org/D23791" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D23791</a><br>
<br>
Files:<br>
  cmake/config-ix.cmake<br>
<br>
Index: cmake/config-ix.cmake<br>
==============================<wbr>==============================<wbr>=======<br>
--- cmake/config-ix.cmake<br>
+++ cmake/config-ix.cmake<br>
@@ -1,5 +1,26 @@<br>
 include(CheckLibraryExists)<br>
 include(CheckCXXCompilerFlag)<br>
+<br>
+check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)<br>
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)<br>
+<br>
+# libc++ is built with -nodefaultlibs, so we want all our checks to also<br>
+# use this option, otherwise we may end up with an inconsistency between<br>
+# the flags we think we require during configuration (if the checks are<br>
+# performed without -nodefaultlibs) and the flags that are actually<br>
+# required during compilation (which has the -nodefaultlibs). libc is<br>
+# required for the link to go through.<br>
+check_cxx_compiler_flag(-<wbr>nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_<wbr>FLAG)<br>
+if (LIBCXX_SUPPORTS_<wbr>NODEFAULTLIBS_FLAG)<br>
+  list(APPEND CMAKE_REQUIRED_LIBRARIES -nodefaultlibs)<br>
+  if (LIBCXX_HAS_C_LIB)<br>
+    list(APPEND CMAKE_REQUIRED_LIBRARIES c)<br>
+  endif ()<br>
+  if (LIBCXX_HAS_GCC_S_LIB)<br>
+    list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)<br>
+  endif ()<br>
+endif ()<br>
+<br>
 include(CheckLibcxxAtomic)<br>
<br>
 # Check compiler flags<br>
@@ -14,7 +35,5 @@<br>
<br>
 # Check libraries<br>
 check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)<br>
-check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)<br>
 check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)<br>
 check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)<br>
-check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)<br>
<br>
<br>
</blockquote></div></div>