Skip to content

Commit 1e7c84a

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. (cherry picked from commit dc68773)
1 parent 3badb3b commit 1e7c84a

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
@@ -830,7 +830,7 @@ endmacro()
830830
#
831831
# Usage:
832832
# add_swift_host_tool(name
833-
# [HAS_SWIFT_MODULES]
833+
# [HAS_SWIFT_MODULES | DOES_NOT_USE_SWIFT]
834834
# [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
835835
#
836836
# [BOOTSTRAPPING 0|1]
@@ -844,6 +844,9 @@ endmacro()
844844
# HAS_SWIFT_MODULES
845845
# Whether to link with SwiftCompilerSources library
846846
#
847+
# DOES_NOT_USE_SWIFT
848+
# Do not link with swift runtime
849+
#
847850
# THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
848851
# Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
849852
#
@@ -859,7 +862,7 @@ endmacro()
859862
# source1 ...
860863
# Sources to add into this executable.
861864
function(add_swift_host_tool executable)
862-
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
865+
set(options HAS_SWIFT_MODULES DOES_NOT_USE_SWIFT THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
863866
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
864867
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
865868

@@ -915,7 +918,7 @@ function(add_swift_host_tool executable)
915918
endif()
916919

917920
# Once the new Swift parser is linked in, every host tool has Swift modules.
918-
if (SWIFT_SWIFT_PARSER)
921+
if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT)
919922
set(ASHT_HAS_SWIFT_MODULES ON)
920923
endif()
921924

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)