cd ~/src/swift-project/swift
./utils/update-checkout --clone-with-ssh --clean
sccache --start-server
utils/build-script --skip-build-benchmarks \
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
--sccache --release-debuginfo --swift-disable-dead-stripping \
--bootstrapping=hosttools --clean
^^ give this 60+ minutes for a from-start build on an M1 Macbook Pro:
Build Percentage Build Duration (sec) Build Phase
================ ==================== ===========
60.1% 2297.32 Building llvm
37.4% 1429.24 macosx-arm64-swift-build
2.2% 85.63 Building earlyswiftdriver
0.2% 8.33 Building cmark
0.0% 0.07 macosx-arm64-swift-test
0.0% 0.06 macosx-arm64-swift-install
0.0% 0.04 merged-hosts-lipo-core
0.0% 0.04 macosx-arm64-extractsymbols
0.0% 0.04 macosx-arm64-package
0.0% 0.04 merged-hosts-lipo
cd ~/src/swift-project
export platform=$([[ $(uname) == Darwin ]] && echo macosx || echo linux)
ninja -C build/Ninja-RelWithDebInfoAssert/swift-${platform}-$(uname -m) bin/swift-frontend
cd ~/src/swift-project
export platform=$([[ $(uname) == Darwin ]] && echo macosx || echo linux)
ninja -C build/Ninja-RelWithDebInfoAssert/swift-${platform}-$(uname -m)
- Clone and run update-checkout.
- Run swift/utils/build-script --release-debuginfo --xcode. [Add a --debug-swift to get better debugging info for the compiler itself. Other dependencies like LLVM will have debug info but will have more optimizations applied with --release-debuginfo.]. This will create an xcodeproj under build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64.
- Open the Xcode project and under schemes, do "Manually manage schemes" and select ALL_BUILD as well as swift (this list is very long so you'll have to scroll a bit).
- Build normal using Cmd+B inside Xcode to double-check that it works.
- Check out a new branch and make your changes.
- Run tests using lit on the commandline. I recommend using something like llvm-project/llvm/utils/lit/lit.py -s -vv build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64 --filter "myTestName". There are some test targets which you can run from inside Xcode, but I usually use lit because you can change the flags. I highly recommend using -vv, regardless of what you do, so that you get to see which line in a multi-line test failed.
- Your test passes yay! Now remove the --filter and make sure you didn't break anything else.
- Submit a PR and @ someone, probably someone who is helping you make the change.
utils/build-script --skip-build-benchmarks \
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
--sccache --release-debuginfo --swift-disable-dead-stripping \
--bootstrapping=hosttools --clean
^^ roughly 10 minutes of setup time to enable this (with sccache enabled)
project at: ~/src/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Swift.xcodeproj https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#using-ninja-with-xcode
cd ~/src/swift-project/swift
utils/build-script --skip-build-benchmarks \
--skip-ios --skip-watchos --skip-tvos \
--swift-darwin-supported-archs "$(uname -m)" \
--sccache --release-debuginfo \
--swift-disable-dead-stripping \
--xcode