Skip to content

Commit 3423e4a

Browse files
committed
Disable _StringProcessing import in _CompilerPluginSupport
1 parent 31af288 commit 3423e4a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/CompilerPluginSupport/CMakeLists.txt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,25 @@ if(SWIFT_SWIFT_PARSER)
3636
-enable-library-evolution;
3737
-emit-module-interface;
3838
-target;${target}>)
39-
40-
target_link_libraries("${library_name}"
41-
PRIVATE
42-
swiftCore
43-
)
39+
40+
# Ensure that we do not link the _StringProcessing module. But we can
41+
# only pass this flag for new-enough compilers that support it.
42+
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift" "")
43+
execute_process(
44+
COMMAND
45+
"${CMAKE_Swift_COMPILER}"
46+
-Xfrontend -disable-implicit-string-processing-module-import
47+
-c - -o /dev/null
48+
INPUT_FILE
49+
"${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift"
50+
OUTPUT_QUIET ERROR_QUIET
51+
RESULT_VARIABLE
52+
SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
53+
if(NOT SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
54+
add_compile_options(
55+
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend>
56+
$<$<COMPILE_LANGUAGE:Swift>:-disable-implicit-string-processing-module-import>)
57+
endif()
4458

4559
swift_install_in_component(TARGETS "${library_name}"
4660
RUNTIME

0 commit comments

Comments
 (0)