[compiler-rt] Use xcrun instead of xcodebuild to find the SDK directory

Summary:
xcodebuild does not work unless XCode is installed whereas xcrun also work
when only the Command Line Tools are installed. Unlike the check for the
version (D69610), this did not cause an erro for me since the fallback to
/usr/include for the OSX sysroot worked.

Reviewers: yln, delcypher

Reviewed By: yln

Subscribers: dberris, mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69659
This commit is contained in:
Alex Richardson 2019-10-31 21:17:55 +00:00
parent 52beec76de
commit 8baedb82ba
2 changed files with 4 additions and 2 deletions

View File

@ -18,7 +18,7 @@ function(find_darwin_sdk_dir var sdk_name)
if(NOT DARWIN_PREFER_PUBLIC_SDK)
# Let's first try the internal SDK, otherwise use the public SDK.
execute_process(
COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path
COMMAND xcrun --sdk ${sdk_name}.internal --show-sdk-path
RESULT_VARIABLE result_process
OUTPUT_VARIABLE var_internal
OUTPUT_STRIP_TRAILING_WHITESPACE
@ -27,7 +27,7 @@ function(find_darwin_sdk_dir var sdk_name)
endif()
if((NOT result_process EQUAL 0) OR "" STREQUAL "${var_internal}")
execute_process(
COMMAND xcodebuild -version -sdk ${sdk_name} Path
COMMAND xcrun --sdk ${sdk_name} --show-sdk-path
RESULT_VARIABLE result_process
OUTPUT_VARIABLE var_internal
OUTPUT_STRIP_TRAILING_WHITESPACE
@ -39,6 +39,7 @@ function(find_darwin_sdk_dir var sdk_name)
if(result_process EQUAL 0)
set(${var} ${var_internal} PARENT_SCOPE)
endif()
message(STATUS "Checking DARWIN_${sdk_name}_SYSROOT - '${var_internal}'")
set(DARWIN_${sdk_name}_CACHED_SYSROOT ${var_internal} CACHE STRING "Darwin SDK path for SDK ${sdk_name}." FORCE)
endfunction()

View File

@ -316,6 +316,7 @@ if(APPLE)
find_darwin_sdk_dir(DARWIN_tvos_SYSROOT appletvos)
if(NOT DARWIN_osx_SYSROOT)
message(WARNING "Could not determine OS X sysroot, trying /usr/include")
if(EXISTS /usr/include)
set(DARWIN_osx_SYSROOT /)
else()