Index: cfe/trunk/test/lit.cfg =================================================================== --- cfe/trunk/test/lit.cfg +++ cfe/trunk/test/lit.cfg @@ -471,18 +471,4 @@ if use_gmalloc: config.environment.update({'DYLD_INSERT_LIBRARIES' : gmalloc_path_str}) -# On Darwin, support relocatable SDKs by providing Clang with a -# default system root path. -if 'darwin' in config.target_triple: - try: - cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = cmd.communicate() - out = out.strip() - res = cmd.wait() - except OSError: - res = -1 - if res == 0 and out: - sdk_path = out - lit_config.note('using SDKROOT: %r' % sdk_path) - config.environment['SDKROOT'] = sdk_path +lit.util.usePlatformSdkOnDarwin(config, lit_config) 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() Index: compiler-rt/trunk/test/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/lit.common.cfg +++ compiler-rt/trunk/test/lit.common.cfg @@ -7,6 +7,7 @@ import platform import lit.formats +import lit.util # Setup test format execute_external = (platform.system() != 'Windows' @@ -77,3 +78,5 @@ compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) if not compiler_rt_debug: config.available_features.add('compiler-rt-optimized') + +lit.util.usePlatformSdkOnDarwin(config, lit_config) Index: llvm/trunk/utils/lit/lit/util.py =================================================================== --- llvm/trunk/utils/lit/lit/util.py +++ llvm/trunk/utils/lit/lit/util.py @@ -167,3 +167,20 @@ err = str(err) return out, err, exitCode + +def usePlatformSdkOnDarwin(config, lit_config): + # On Darwin, support relocatable SDKs by providing Clang with a + # default system root path. + if 'darwin' in config.target_triple: + try: + cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = cmd.communicate() + out = out.strip() + res = cmd.wait() + except OSError: + res = -1 + if res == 0 and out: + sdk_path = out + lit_config.note('using SDKROOT: %r' % sdk_path) + config.environment['SDKROOT'] = sdk_path