Skip to content

Commit dc68773

Browse files
committed
[CMake] Stop some exectuable link with swiftCore
swift-compatibility-symbols, swift-def-to-strings-converter, and swift-serialize-diagnostics don't use any Swift modules. But when SWIFT_SWIFT_PARSER was enabled, they are linked with swiftCore. But these binaries can be executed before the runtime is being built. We need to stop them linking with swiftCore.
1 parent 4ccc866 commit dc68773

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ endmacro()
833833
#
834834
# Usage:
835835
# add_swift_host_tool(name
836-
# [HAS_SWIFT_MODULES]
836+
# [HAS_SWIFT_MODULES | DOES_NOT_USE_SWIFT]
837837
# [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
838838
#
839839
# [BOOTSTRAPPING 0|1]
@@ -847,6 +847,9 @@ endmacro()
847847
# HAS_SWIFT_MODULES
848848
# Whether to link with SwiftCompilerSources library
849849
#
850+
# DOES_NOT_USE_SWIFT
851+
# Do not link with swift runtime
852+
#
850853
# THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
851854
# Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
852855
#
@@ -862,7 +865,7 @@ endmacro()
862865
# source1 ...
863866
# Sources to add into this executable.
864867
function(add_swift_host_tool executable)
865-
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
868+
set(options HAS_SWIFT_MODULES DOES_NOT_USE_SWIFT THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
866869
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
867870
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
868871
@@ -918,7 +921,7 @@ function(add_swift_host_tool executable)
918921
endif()
919922
920923
# Once the new Swift parser is linked in, every host tool has Swift modules.
921-
if (SWIFT_SWIFT_PARSER)
924+
if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT)
922925
set(ASHT_HAS_SWIFT_MODULES ON)
923926
endif()
924927

tools/swift-compatibility-symbols/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ add_swift_host_tool(swift-compatibility-symbols
22
swift-compatibility-symbols.cpp
33
LLVM_LINK_COMPONENTS support
44
SWIFT_COMPONENT tools
5+
DOES_NOT_USE_SWIFT
56
)
67

78
set(syms_file "${CMAKE_BINARY_DIR}/share/swift/compatibility-symbols")

tools/swift-def-to-strings-converter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_swift_host_tool(swift-def-to-strings-converter
22
swift-def-to-strings-converter.cpp
33
SWIFT_COMPONENT tools
4+
DOES_NOT_USE_SWIFT
45
)
56

67
target_link_libraries(swift-def-to-strings-converter PRIVATE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_swift_host_tool(swift-serialize-diagnostics
22
swift-serialize-diagnostics.cpp
33
SWIFT_COMPONENT tools
4+
DOES_NOT_USE_SWIFT
45
)
56
target_link_libraries(swift-serialize-diagnostics PRIVATE
67
swiftLocalization)

0 commit comments

Comments
 (0)