[PATCH] Make compiler-rt tests work with relocatable SDKs on OS X

Kuba Brecka kuba.brecka at gmail.com
Mon Jun 9 18:28:19 PDT 2014


Moved the lit-related stuff to http://reviews.llvm.org/D4072.

http://reviews.llvm.org/D4047

Files:
  compiler-rt/trunk/CMakeLists.txt
  compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/trunk/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/trunk/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -375,3 +375,22 @@
   add_subdirectory(unittests)
 endif()
 add_subdirectory(test)
+
+# We need c++ headers, on Darwin 10.9 there is no system-installed toolchain,
+# if we don't have libcxx, let's symlink to c++ directory provided with Xcode
+if(APPLE)
+  execute_process(
+    COMMAND bash -c "if [ -h '${LLVM_INCLUDE_DIR}/c++' ] ; then rm '${LLVM_INCLUDE_DIR}/c++' ; fi;"
+  )
+  if (NOT COMPILER_RT_HAS_LIBCXX_SOURCES)
+    execute_process(
+      COMMAND sh -c "echo $(dirname $(xcrun -f clang))"
+      OUTPUT_VARIABLE xcode_default_toolchain_clang
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    execute_process(
+      COMMAND ln -s "${xcode_default_toolchain_clang}/../lib/c++" "${LLVM_INCLUDE_DIR}/"
+    )
+    message(STATUS "Using ${xcode_default_toolchain_clang}/../lib/c++ as C++ headers")
+  endif()
+endif()
Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -140,6 +140,18 @@
   list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations)
 endif()
 
+# Unit tests on Mac depend on Foundation.
+if(APPLE)
+  execute_process(
+    COMMAND xcodebuild -version -sdk macosx Path
+    OUTPUT_VARIABLE OSX_SDK_DIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+  list(APPEND COMPILER_RT_GTEST_CFLAGS -isysroot ${OSX_SDK_DIR})
+  list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS -isysroot ${OSX_SDK_DIR})
+  list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS -framework Foundation)
+endif()
+
 # Link objects into a single executable with COMPILER_RT_TEST_COMPILER,
 # using specified link flags. Make executable a part of provided
 # test_suite.
Index: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
@@ -63,10 +63,6 @@
   list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS "-lc++")
 endif()
 
-# Unit tests on Mac depend on Foundation.
-if(APPLE)
-  list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS -framework Foundation)
-endif()
 if(ANDROID)
   list(APPEND ASAN_UNITTEST_COMMON_LINKFLAGS -pie)
 endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4047.10257.patch
Type: text/x-patch
Size: 2444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140610/529065df/attachment.bin>


More information about the llvm-commits mailing list