[libcxx] r297703 - Fix cmake to find the compiler-rt libs on darwin

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 21:12:30 PDT 2017


Author: bruno
Date: Mon Mar 13 23:12:29 2017
New Revision: 297703

URL: http://llvm.org/viewvc/llvm-project?rev=297703&view=rev
Log:
Fix cmake to find the compiler-rt libs on darwin

Followup for r297553, which left darwin in a broken state
http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/3812

rdar://problem/31011980

Modified:
    libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake

Modified: libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake?rev=297703&r1=297702&r2=297703&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake Mon Mar 13 23:12:29 2017
@@ -25,15 +25,27 @@ function(find_compiler_rt_dir dest)
     message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function")
   endif()
   set(dest "" PARENT_SCOPE)
-  set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
-      "--rtlib=compiler-rt" "--print-libgcc-file-name")
-  execute_process(
-      COMMAND ${CLANG_COMMAND}
-      RESULT_VARIABLE HAD_ERROR
-      OUTPUT_VARIABLE LIBRARY_FILE
-  )
-  string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
-  get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
+  if (APPLE)
+    set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
+        "-print-file-name=lib")
+    execute_process(
+        COMMAND ${CLANG_COMMAND}
+        RESULT_VARIABLE HAD_ERROR
+        OUTPUT_VARIABLE LIBRARY_DIR
+    )
+    string(STRIP "${LIBRARY_DIR}" LIBRARY_DIR)
+    set(LIBRARY_DIR "${LIBRARY_DIR}/darwin")
+  else()
+    set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
+        "--rtlib=compiler-rt" "--print-libgcc-file-name")
+    execute_process(
+        COMMAND ${CLANG_COMMAND}
+        RESULT_VARIABLE HAD_ERROR
+        OUTPUT_VARIABLE LIBRARY_FILE
+    )
+    string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
+    get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
+  endif()
   if (NOT HAD_ERROR AND EXISTS "${LIBRARY_DIR}")
     message(STATUS "Found compiler-rt directory: ${LIBRARY_DIR}")
     set(${dest} "${LIBRARY_DIR}" PARENT_SCOPE)




More information about the cfe-commits mailing list