# Why does it take so long to build and test SwiftPM on the CI?

**URL:** <https://forums.swift.org/t/why-does-it-take-so-long-to-build-and-test-swiftpm-on-the-ci/86898>\
**Category:** Package Manager\
**Tags:** performance, build\
**Created:** [May 23, 2026, 2:58pm UTC](https://forums.swift.org/t/why-does-it-take-so-long-to-build-and-test-swiftpm-on-the-ci/86898 "2026-05-23T14:58:02Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [May 24, 2026, 8:53am UTC](https://forums.swift.org/t/why-does-it-take-so-long-to-build-and-test-swiftpm-on-the-ci/86898/3 "2026-05-24T08:53:41Z")

</div>

> [@Jon\_Shier](#):
>
> Last I looked, the toolchain builds were Ninja and / or Cmake, so I don't think Swift's build system is an issue on CI, just the compiler itself for the Swift bits.

For everything before the Swift package manager is built, you are right, but not when building SwiftPM itself and after, where SwiftPM is mostly used.

In particular, SwiftPM has a bootstrap process, where it [quickly builds a cut-down debug version of SwiftPM called `swift-bootstrap` using CMake/ninja](https://github.com/swiftlang/swift-package-manager/blob/e1ced73eb538fb4e20cbcc28084fce866a9f570c/Utilities/bootstrap#L380), then uses that to build the full SwiftPM, after which that full SwiftPM is favored for all later components in the toolchain build, such as swift-driver and Docc.

I am intimately familiar with how it works because I'm one of the few people who [cross-compile SwiftPM itself, so it runs _on_ Android](https://github.com/swiftlang/swift-package-manager/blob/e1ced73eb538fb4e20cbcc28084fce866a9f570c/Utilities/bootstrap#L943).

> [@Jon\_Shier](#):
>
> While the performance there could be undoubtedly improved, it's not responsible for 13 hour build times.

The issue here isn't the long build times for the full toolchain on the macOS CI, but improving the SwiftPM portion in particular, which in all the CI logs I linked above is one of the slowest toolchain components to build.

Whether this greatly reduces total CI time is not the concern, the focus is on improving SwiftPM build time because it should be _generalizable to all_ Swift package builds, as SwiftPM is primarily built and tested using SwiftPM, even if it's just propagating existing Swift build performance techniques more.

The rest of your post is about lessening total CI time with other techniques, that have little to do with improving the SwiftPM build, so I've put my responses below the fold.

> **Jibber jabber about slow Swift CI generally**
>
> > [@Jon\_Shier](#):
> >
> > Solution here is just more runners, so either more money, or a host that won't gouge you.
> 
> Ironic, as the Swift CI is Apple paying money that ultimately goes back to... Apple. 😉
> 
> > [@Jon\_Shier](#):
> >
> > Apple would really benefit from dog fooding macOS like this, macOS build nodes are actually a huge pain.
> 
> I'm sure they are, but maybe there's a disconnect.
> 
> > [@Jon\_Shier](#):
> >
> > Third, like you said, are the multiple unnecessary rebuilds, and a lack of integration in the pipeline.
> 
> All these points probably apply to the swiftlang pull request CI, which are each run dozens of times on weekdays, but all the CI I linked here are the full toolchain CI, which generate the full snapshot toolchains and are only run once or twice daily, often integrating dozens of pulls from several repos on each CI run. These are tougher to cache between separate toolchain CI runs because of all the changing source, whereas I was talking about caching the multiple SwiftPM builds in a _single_ toolchain CI run above.
> 
> > [@Jon\_Shier](#):
> >
> > I think it's running on an Amazon hosted EC2 x86 macOS runner, which, in reality, is a 2018 Intel Mac mini with a 6 (12 hyper) core 3.2GHz i7, with 32GB of RAM.
> 
> [A native macOS arm64 toolchain CI](https://ci.swift.org/job/oss-swift-package-macos-arm64/) is being spun up now, currently broken.
> 
> > [@Jon\_Shier](#):
> >
> > This machine and its tools are so old it has to build LLVM/clang before it can even start the real build (seems to use Apple clang 16 / Xcode 16) to build the OSS clang 21, which is then used in the build. (Why it does that rather than just installing the precompiled clang 21, I don't know.)
> 
> All builds of the Swift compiler build the corresponding [Swift-forked LLVM and clang from source](https://github.com/swiftlang/llvm-project/) first, to ensure they work well together and because the Swift-forked LLVM is continuously worked on and updated.
> 
> > [@Jon\_Shier](#):
> >
> > If you have build you want me to run locally for comparison, feel free to post it, and we can compare it to an M3 Ultra.
> 
> No need, I regularly build the Swift toolchain on an M4 Mini since late last year, including [in a linux container sometimes](https://forums.swift.org/t/building-a-linux-aarch64-toolchain-on-macos-with-containerization/84347), so I'm well aware of how much faster that is. 😃

This thread is mostly about improving the Swift compiler and package manager, the CI is just an easy environment to look for such gains.

---

_[View the full topic](https://forums.swift.org/t/why-does-it-take-so-long-to-build-and-test-swiftpm-on-the-ci/86898)._
