Skip to content

Commit 5befea4

Browse files
committed
build: query the resource dir when needed
When building the standard library standalone with the host compiler, we do not have the location of the resource dir available to us nor can it be computed. Use `-print-resource-dir` to query the value from the compiler and use that. This is needed to cross-compile the standard library to android from Windows.
1 parent 096d32b commit 5befea4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,15 @@ endif()
8484
# First extract the "version" used for Clang's resource directory.
8585
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
8686
"${LLVM_PACKAGE_VERSION}")
87-
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
87+
if(NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
88+
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-resource-dir
89+
OUTPUT_VARIABLE clang_headers_location
90+
OUTPUT_STRIP_TRAILING_WHITESPACE
91+
ERROR_QUIET)
92+
message(STATUS "using clang resource directory: ${clang_headers_location}")
93+
else()
94+
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
95+
endif()
8896

8997
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
9098
set(cmake_symlink_option "copy_directory")

0 commit comments

Comments
 (0)