[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.
This commit is contained in:
Rintaro Ishizaki
2023-08-28 19:10:01 +00:00
parent 4ccc866612
commit dc6877334f
4 changed files with 9 additions and 3 deletions

View File

@@ -833,7 +833,7 @@ endmacro()
#
# Usage:
# add_swift_host_tool(name
# [HAS_SWIFT_MODULES]
# [HAS_SWIFT_MODULES | DOES_NOT_USE_SWIFT]
# [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
#
# [BOOTSTRAPPING 0|1]
@@ -847,6 +847,9 @@ endmacro()
# HAS_SWIFT_MODULES
# Whether to link with SwiftCompilerSources library
#
# DOES_NOT_USE_SWIFT
# Do not link with swift runtime
#
# THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
# Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
#
@@ -862,7 +865,7 @@ endmacro()
# source1 ...
# Sources to add into this executable.
function(add_swift_host_tool executable)
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
set(options HAS_SWIFT_MODULES DOES_NOT_USE_SWIFT THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
@@ -918,7 +921,7 @@ function(add_swift_host_tool executable)
endif()
# Once the new Swift parser is linked in, every host tool has Swift modules.
if (SWIFT_SWIFT_PARSER)
if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT)
set(ASHT_HAS_SWIFT_MODULES ON)
endif()

View File

@@ -2,6 +2,7 @@ add_swift_host_tool(swift-compatibility-symbols
swift-compatibility-symbols.cpp
LLVM_LINK_COMPONENTS support
SWIFT_COMPONENT tools
DOES_NOT_USE_SWIFT
)
set(syms_file "${CMAKE_BINARY_DIR}/share/swift/compatibility-symbols")

View File

@@ -1,6 +1,7 @@
add_swift_host_tool(swift-def-to-strings-converter
swift-def-to-strings-converter.cpp
SWIFT_COMPONENT tools
DOES_NOT_USE_SWIFT
)
target_link_libraries(swift-def-to-strings-converter PRIVATE

View File

@@ -1,6 +1,7 @@
add_swift_host_tool(swift-serialize-diagnostics
swift-serialize-diagnostics.cpp
SWIFT_COMPONENT tools
DOES_NOT_USE_SWIFT
)
target_link_libraries(swift-serialize-diagnostics PRIVATE
swiftLocalization)