[PATCH] D65323: 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...
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 01:35:13 PDT 2019
arichardson created this revision.
arichardson added reviewers: beanz, kubamracek.
Herald added subscribers: llvm-commits, Sanitizers, mgorny.
Herald added projects: Sanitizers, LLVM.
...the variable OSX_SYSROOT will be empty and OSX_SYSROOT_FLAG is set to "-isysroot". This then caused 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65323
Files:
compiler-rt/cmake/base-config-ix.cmake
Index: compiler-rt/cmake/base-config-ix.cmake
===================================================================
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -91,15 +91,29 @@
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)
+ # 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 xcodebuild -version -sdk macosx Path
OUTPUT_VARIABLE OSX_SYSROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}")
+ # Fall back to xcrun if XCode is not installed
+ if (NOT OSX_SYSROOT)
+ execute_process(COMMAND xcrun -sdk macosx --show-sdk-path
+ OUTPUT_VARIABLE OSX_SYSROOT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65323.211893.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190726/472f3784/attachment.bin>
More information about the llvm-commits
mailing list