Skip to content

Commit d716b09

Browse files
committed
Only disable _StringProcessing imports when the compiler supports the flag.
Thank you to @etcwilde for the quick fix!
1 parent 45b5066 commit d716b09

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,27 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2323

2424
set(CMAKE_MACOSX_RPATH YES)
2525

26-
# Ensure that we do not link the _StringProcessing module.
27-
add_compile_options(
28-
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend>
29-
$<$<COMPILE_LANGUAGE:Swift>:-disable-implicit-string-processing-module-import>)
30-
31-
# Force single-threaded builds to eliminate the Darwin dependency.
26+
# Ensure that we do not link the _StringProcessing module. But we can
27+
# only pass this flag for new-enough compilers that support it.
28+
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift" "")
29+
execute_process(
30+
COMMAND
31+
"${CMAKE_Swift_COMPILER}"
32+
-Xfrontend -disable-implicit-string-processing-module-import
33+
-c - -o /dev/null
34+
INPUT_FILE
35+
"${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift"
36+
OUTPUT_QUIET ERROR_QUIET
37+
RESULT_VARIABLE
38+
SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
39+
if (NOT SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
40+
add_compile_options(
41+
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend>
42+
$<$<COMPILE_LANGUAGE:Swift>:-disable-implicit-string-processing-module-import>)
43+
endif()
44+
45+
# Force single-threaded-only syntax trees to eliminate the Darwin
46+
# dependency in the compiler.
3247
add_compile_definitions(
3348
$<$<COMPILE_LANGUAGE:Swift>:SWIFT_SYNTAX_ALWAYS_SINGLE_THREADED>
3449
)

0 commit comments

Comments
 (0)