From dc6877334fb7bf33121fac75166313b25eebb600 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Mon, 28 Aug 2023 19:10:01 +0000 Subject: [PATCH] [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. --- cmake/modules/AddSwift.cmake | 9 ++++++--- tools/swift-compatibility-symbols/CMakeLists.txt | 1 + tools/swift-def-to-strings-converter/CMakeLists.txt | 1 + tools/swift-serialize-diagnostics/CMakeLists.txt | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index 744b5e91d88..b31370e4ac5 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -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() diff --git a/tools/swift-compatibility-symbols/CMakeLists.txt b/tools/swift-compatibility-symbols/CMakeLists.txt index e28de9182cf..fff7ad8112a 100644 --- a/tools/swift-compatibility-symbols/CMakeLists.txt +++ b/tools/swift-compatibility-symbols/CMakeLists.txt @@ -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") diff --git a/tools/swift-def-to-strings-converter/CMakeLists.txt b/tools/swift-def-to-strings-converter/CMakeLists.txt index 2bfd9145a5a..fa81fe6ae60 100644 --- a/tools/swift-def-to-strings-converter/CMakeLists.txt +++ b/tools/swift-def-to-strings-converter/CMakeLists.txt @@ -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 diff --git a/tools/swift-serialize-diagnostics/CMakeLists.txt b/tools/swift-serialize-diagnostics/CMakeLists.txt index 4a1ab49b59e..aee14abd2dd 100644 --- a/tools/swift-serialize-diagnostics/CMakeLists.txt +++ b/tools/swift-serialize-diagnostics/CMakeLists.txt @@ -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)