Skip to content

Commit ad93463

Browse files
committed
Shims: support clang-cl for building the runtime for Windows
`-print-resource-dir` is not available with `clang-cl` which is required for building the standard library for Windows on Windows. Use the `/clang:-print-resource-dir` spelling instead. This allows us to build the standalone runtime for Windows on Windows.
1 parent e156713 commit ad93463

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,18 @@ endif()
8585
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
8686
"${LLVM_PACKAGE_VERSION}")
8787
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}")
88+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
89+
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
90+
OUTPUT_VARIABLE clang_headers_location
91+
OUTPUT_STRIP_TRAILING_WHITESPACE
92+
ERROR_QUIET)
93+
else()
94+
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-resource-dir
95+
OUTPUT_VARIABLE clang_headers_location
96+
OUTPUT_STRIP_TRAILING_WHITESPACE
97+
ERROR_QUIET)
98+
endif()
99+
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
93100
else()
94101
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
95102
endif()

0 commit comments

Comments
 (0)