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

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 04:49:33 PDT 2019


arichardson created this revision.
arichardson added reviewers: yln, delcypher.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, dberris.
Herald added projects: Sanitizers, LLVM.

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 <https://reviews.llvm.org/D69610>), this did not cause an erro for me since the fallback to
/usr/include for the OSX sysroot worked.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69659

Files:
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/config-ix.cmake


Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -316,6 +316,7 @@
   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()
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -18,7 +18,7 @@
   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 @@
   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 @@
   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()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69659.227266.patch
Type: text/x-patch
Size: 1740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191031/2f646cff/attachment.bin>


More information about the llvm-commits mailing list