This has been bothering me lately, as it now takes the same amount of time to build, test, and install SwiftPM as to build, test, and install the Swift compiler itself, just over an hour on linux. Here are the latest numbers from Fedora 41 x86_64 building the Swift 6.3 toolchain:
[2026-05-23T05:42:08.762Z] Total Duration: 13859.84 seconds (3h 50m 59s)
[2026-05-23T05:42:09.019Z] --- Build Script Analyzer ---
[2026-05-23T05:42:09.019Z] Build Script Log: /home/build-user/build/.build_script_log
[2026-05-23T05:42:09.019Z] Build Percentage Build Duration (sec) Build Phase
[2026-05-23T05:42:09.019Z] ================ ==================== ===========
[2026-05-23T05:42:09.019Z] 16.1% 2226.39 Running tests for swiftpm
[2026-05-23T05:42:09.019Z] 9.2% 1268.92 linux-x86_64-swift-build
[2026-05-23T05:42:09.019Z] 9.0% 1240.51 linux-x86_64-swift-test
[2026-05-23T05:42:09.019Z] 8.5% 1173.86 Building llvm
[2026-05-23T05:42:09.019Z] 6.0% 833.61 Building swiftpm
[2026-05-23T05:42:09.019Z] 4.7% 649.72 Building wasmswiftsdk
[2026-05-23T05:42:09.019Z] 4.6% 638.81 Installing swiftpm
[2026-05-23T05:42:09.019Z] 4.0% 550.0 linux-x86_64-foundation-build
[2026-05-23T05:42:09.019Z] 3.5% 490.55 Building swiftformat
[2026-05-23T05:42:09.019Z] 3.0% 422.25 Building sourcekitlsp
[2026-05-23T05:42:09.019Z] 2.6% 367.07 Running tests for swiftdriver
[2026-05-23T05:42:09.019Z] 2.6% 360.29 Building wasmstdlib
[2026-05-23T05:42:09.019Z] 2.6% 357.47 Building wasmthreadsstdlib
[2026-05-23T05:42:09.019Z] 2.5% 341.55 Running tests for wasmstdlib
[2026-05-23T05:42:09.019Z] 2.1% 285.74 Installing swiftdocc
[2026-05-23T05:42:09.019Z] 2.0% 278.38 Running tests for foundationtests
[2026-05-23T05:42:09.019Z] 1.9% 257.76 linux-x86_64-lldb-build
[2026-05-23T05:42:09.019Z] 1.6% 227.6 Running tests for sourcekitlsp
[2026-05-23T05:42:09.019Z] 1.6% 226.04 linux-x86_64-package
[2026-05-23T05:42:09.019Z] 1.3% 181.15 Running tests for swiftfoundationtests
[2026-05-23T05:42:09.019Z] 1.3% 173.7 linux-x86_64-lldb-test
[2026-05-23T05:42:09.019Z] 1.2% 163.74 Building swiftdriver
[2026-05-23T05:42:09.019Z] 1.0% 138.23 Installing swiftdriver
[2026-05-23T05:42:09.019Z] 0.9% 122.69 Building earlyswiftdriver
[2026-05-23T05:42:09.019Z] 0.8% 110.99 Building swiftdocc
[2026-05-23T05:42:09.019Z] 0.8% 106.49 Building benchmarks
[2026-05-23T05:42:09.019Z] 0.6% 85.76 Installing sourcekitlsp
Building and testing the 6.3 compiler takes 4X the time as for SwiftPM on macOS x86_64, but that SwiftPM time could probably be shaved down also. Note that these are timings for Swift 6.3, ie before swift-build was made the default build system in SwiftPM, but the trunk compiler:SwiftPM CI time ratios on linux and mac are pretty much the same, ie after switching to swift-build.
There are two main issues here:
- The Swift compiler is still mostly written in C++, whereas SwiftPM is mostly in Swift. Not a good sign that our build times are worse than notoriously slow C++, but build time is a constant complaint from Swift devs.
- The Swift CI invokes SwiftPM three separate times to build, test, and install with slightly different flags, which kicks off rebuilds of the same SwiftPM source. We could do a better job of build caching or making sure the flags don't do that. For example, the 10+ minutes to install SwiftPM, most of which is wasted on an unnecessary rebuild of the same source, needs to be cut way down.
Seems like improving the SwiftPM build would be a good way to dogfood improving Swift build times for everyone, either by applying existing techniques it isn't using yet or coming up with new ones.