From ee544b1719d9d88228dfbb9e818d20bace712fea Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 30 Jan 2025 22:33:40 -0800 Subject: [PATCH 1/2] build: synchronise dependencies with reality This adjusts the dependency graph to match the reality of the sources. --- Package.swift | 5 ++++- Sources/CoreCommands/CMakeLists.txt | 2 ++ Sources/swift-package/CMakeLists.txt | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 9c85ed07d0d..ec6965ded4b 100644 --- a/Package.swift +++ b/Package.swift @@ -489,6 +489,7 @@ let package = Package( name: "CoreCommands", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), + .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), "Basics", "Build", "PackageLoading", @@ -509,9 +510,11 @@ let package = Package( dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "OrderedCollections", package: "swift-collections"), + .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), "Basics", "Build", "CoreCommands", + "LLBuildManifest", "PackageGraph", "PackageModelSyntax", "SourceControl", @@ -594,7 +597,7 @@ let package = Package( .executableTarget( /** The main executable provided by SwiftPM */ name: "swift-package", - dependencies: ["Basics", "Commands"], + dependencies: ["Commands"], exclude: ["CMakeLists.txt"] ), .executableTarget( diff --git a/Sources/CoreCommands/CMakeLists.txt b/Sources/CoreCommands/CMakeLists.txt index d7ec0cbb632..eeccc9c5d6e 100644 --- a/Sources/CoreCommands/CMakeLists.txt +++ b/Sources/CoreCommands/CMakeLists.txt @@ -16,6 +16,8 @@ target_link_libraries(CoreCommands PUBLIC Basics Build PackageGraph + PackageModel + PackageLoading TSCBasic TSCUtility Workspace diff --git a/Sources/swift-package/CMakeLists.txt b/Sources/swift-package/CMakeLists.txt index 3468bdefcdc..3ff57252e80 100644 --- a/Sources/swift-package/CMakeLists.txt +++ b/Sources/swift-package/CMakeLists.txt @@ -9,8 +9,7 @@ add_executable(swift-package Entrypoint.swift) target_link_libraries(swift-package PRIVATE - Commands - TSCBasic) + Commands) target_compile_options(swift-package PRIVATE -parse-as-library) From 5b5f06f60326dc7ac73c0f1b368f741985ff5d40 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 30 Jan 2025 22:34:29 -0800 Subject: [PATCH 2/2] build: selectively apply some static linking Convert a few libraries to static linking. This results in a net size reduction for the toolchain as a whole while also reducing the distributed DLLs. PackageModelSyntax Conversion: ~~~ Before: 6621696 sourcekit-lsp.exe 3844608 Commands.dll 144384 PackageModelSyntax.dll ------- 10610688 After: 6712320 sourcekit-lsp.exe 3950592 Commands.dll -------- 10662912 ~~~ Savings: 52,224 bytes SwiftSDKCommand Conversion: ~~~ Before: 23552 swift-sdk.exe 267776 SwiftSDKCommand.dll ------ 291328 After: 265728 swift-sdk.exe ~~~ Savings: 25,600 bytes CoreCommands Conversion: ~~~ Before: 3844608 Commands.dll 1065472 CoreCommands.dll 265728 swift-sdk.exe ------- 5175808 After: 4202496 Commands.dll 649728 swift-sdk.exe ------- 4852224 ~~~ Savings: 323,584 bytes DriverSupport Conversion: ~~~ Before: 945152 Build.dll 4202496 Commands.dll 49152 DriverSupport.dll 649728 swift-sdk.exe ------- 5846528 After: 958976 Build.dll 4217856 Commands.dll 669184 swift-sdk.exe ------- 5846016 ~~~ Savings: 512 bytes Net Savings: 401,920 bytes --- Sources/CoreCommands/CMakeLists.txt | 7 +------ Sources/DriverSupport/CMakeLists.txt | 8 +------- Sources/PackageModelSyntax/CMakeLists.txt | 6 +----- Sources/SwiftSDKCommand/CMakeLists.txt | 7 +------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Sources/CoreCommands/CMakeLists.txt b/Sources/CoreCommands/CMakeLists.txt index eeccc9c5d6e..9a2b16aa134 100644 --- a/Sources/CoreCommands/CMakeLists.txt +++ b/Sources/CoreCommands/CMakeLists.txt @@ -6,7 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors -add_library(CoreCommands +add_library(CoreCommands STATIC BuildSystemSupport.swift SwiftCommandState.swift SwiftCommandObservabilityHandler.swift @@ -28,8 +28,3 @@ target_link_libraries(CoreCommands PRIVATE # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(CoreCommands PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - -install(TARGETS CoreCommands - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) diff --git a/Sources/DriverSupport/CMakeLists.txt b/Sources/DriverSupport/CMakeLists.txt index 1044df0e906..a9930bcf0b0 100644 --- a/Sources/DriverSupport/CMakeLists.txt +++ b/Sources/DriverSupport/CMakeLists.txt @@ -6,7 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors -add_library(DriverSupport +add_library(DriverSupport STATIC DriverSupportUtils.swift SPMSwiftDriverExecutor.swift) # NOTE(compnerd) workaround for CMake not setting up include flags yet @@ -16,9 +16,3 @@ target_link_libraries(DriverSupport PUBLIC Basics PackageModel SwiftDriver) - -install(TARGETS DriverSupport - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -set_property(GLOBAL APPEND PROPERTY SwiftPM_EXPORTS DriverSupport) diff --git a/Sources/PackageModelSyntax/CMakeLists.txt b/Sources/PackageModelSyntax/CMakeLists.txt index c034d8d1705..919e808d0f0 100644 --- a/Sources/PackageModelSyntax/CMakeLists.txt +++ b/Sources/PackageModelSyntax/CMakeLists.txt @@ -6,7 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors -add_library(PackageModelSyntax +add_library(PackageModelSyntax STATIC AddPackageDependency.swift AddProduct.swift AddTarget.swift @@ -37,8 +37,4 @@ target_link_libraries(PackageModelSyntax PUBLIC set_target_properties(PackageModelSyntax PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) -install(TARGETS PackageModelSyntax - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) set_property(GLOBAL APPEND PROPERTY SwiftPM_EXPORTS PackageModelSyntax) diff --git a/Sources/SwiftSDKCommand/CMakeLists.txt b/Sources/SwiftSDKCommand/CMakeLists.txt index 4dcfa36a2af..fd63f7512d3 100644 --- a/Sources/SwiftSDKCommand/CMakeLists.txt +++ b/Sources/SwiftSDKCommand/CMakeLists.txt @@ -6,7 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors -add_library(SwiftSDKCommand +add_library(SwiftSDKCommand STATIC Configuration/ConfigurationSubcommand.swift Configuration/DeprecatedSwiftSDKConfigurationCommand.swift Configuration/ResetConfiguration.swift @@ -27,8 +27,3 @@ target_link_libraries(SwiftSDKCommand PUBLIC # NOTE(compnerd) workaround for CMake not setting up include flags yet set_target_properties(SwiftSDKCommand PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - -install(TARGETS SwiftSDKCommand - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin)