[compiler-rt] r367170 - [compiler-rt] Fix running tests on macOS when XCode is not installed
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 05:30:15 PDT 2019
Author: arichardson
Date: Sat Jul 27 05:30:15 2019
New Revision: 367170
URL: http://llvm.org/viewvc/llvm-project?rev=367170&view=rev
Log:
[compiler-rt] Fix running tests on macOS when XCode is not installed
Summary:
If XCode is not installed, `xcodebuild -version -sdk macosx Path` will give
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
In this case the variable OSX_SYSROOT will be empty and
OSX_SYSROOT_FLAG is set to "-isysroot" (without a path).
This then causes the CompilerRTUnitTestCheckCxx target failed to for me
because "${COMPILER_RT_TEST_COMPILER} ${OSX_SYSROOT_FLAG} -E" expanded to
"clang -isysroot -E". This results in a warning "sysroot -E does not exist"
and the target fails to run because the C++ headers cannot be found.
Reviewers: beanz, kubamracek
Reviewed By: beanz
Subscribers: dberris, mgorny, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D65323
Modified:
compiler-rt/trunk/cmake/base-config-ix.cmake
Modified: compiler-rt/trunk/cmake/base-config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/base-config-ix.cmake?rev=367170&r1=367169&r2=367170&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/base-config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/base-config-ix.cmake Sat Jul 27 05:30:15 2019
@@ -91,15 +91,22 @@ else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
endif()
if(APPLE)
- # On Darwin if /usr/include doesn't exist, the user probably has Xcode but not
- # the command line tools. If this is the case, we need to find the OS X
- # sysroot to pass to clang.
- if(NOT EXISTS /usr/include)
- execute_process(COMMAND xcodebuild -version -sdk macosx Path
+ # On Darwin if /usr/include/c++ doesn't exist, the user probably has Xcode but
+ # not the command line tools (or is using macOS 10.14 or newer). If this is
+ # the case, we need to find the OS X sysroot to pass to clang.
+ if(NOT EXISTS /usr/include/c++)
+ execute_process(COMMAND xcrun -sdk macosx --show-sdk-path
OUTPUT_VARIABLE OSX_SYSROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}")
+ if (NOT OSX_SYSROOT OR NOT EXISTS ${OSX_SYSROOT})
+ message(WARNING "Detected OSX_SYSROOT ${OSX_SYSROOT} does not exist")
+ else()
+ message(STATUS "Found OSX_SYSROOT: ${OSX_SYSROOT}")
+ set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}")
+ endif()
+ else()
+ set(OSX_SYSROOT_FLAG "")
endif()
option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
More information about the llvm-commits
mailing list