Skip to content

Commit 2471d70

Browse files
authored
Disable _StringProcessing import in _CompilerPluginSupport (#62042)
Reduce dependencies for rdar://102207474.
1 parent 17d3065 commit 2471d70

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
@@ -57,11 +57,25 @@ if(SWIFT_SWIFT_PARSER)
5757
-emit-module-interface-path;
5858
"${module_interface_file}" ;
5959
-target;${target}>)
60-
61-
target_link_libraries("${library_name}"
62-
PRIVATE
63-
swiftCore
64-
)
60+
61+
# Ensure that we do not link the _StringProcessing module. But we can
62+
# only pass this flag for new-enough compilers that support it.
63+
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift" "")
64+
execute_process(
65+
COMMAND
66+
"${CMAKE_Swift_COMPILER}"
67+
-Xfrontend -disable-implicit-string-processing-module-import
68+
-c - -o /dev/null
69+
INPUT_FILE
70+
"${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift"
71+
OUTPUT_QUIET ERROR_QUIET
72+
RESULT_VARIABLE
73+
SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
74+
if(NOT SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
75+
add_compile_options(
76+
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend>
77+
$<$<COMPILE_LANGUAGE:Swift>:-disable-implicit-string-processing-module-import>)
78+
endif()
6579

6680
swift_install_in_component(TARGETS "${library_name}"
6781
RUNTIME

0 commit comments

Comments
 (0)