Incremental build with Ninja takes 14 minutes

I tried to closely follow [Preformatted text](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md):

utils/build-script --release-debuginfo --skip-early-swift-driver \
  --skip-early-swiftsyntax --sccache

Editing lib/Basic/Version.cpp and then firing up an incremental build with ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/ bin/swift-frontend takes around 14 minutes. Is this expected? Output below. I'm on Ubuntu 22.10 with GCC 12 on a 12 core machine.

ninja: Entering directory `../build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/'
[2/18] Building swift module _CompilerRegexParser
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
[3/18] Building swift module Parse
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[4/18] Building swift module SIL
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::pair' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[5/18] Building swift module Optimizer
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::pair' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[8/18] Generating /home/gonsolo/src/apple/build/Ninja-RelWithDebInfoAsser...g1/lib/swift/linux/Swift.swiftmodule/x86_64-unknown-linux-gnu.swiftmodule
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Decodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Encodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Hashable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
[9/18] Compiling /home/gonsolo/src/apple/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping1/stdlib/public/core/LINUX/x86_64/Swift.o
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Decodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Encodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
/home/gonsolo/src/apple/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Hashable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
                ^
[11/18] Building swift module Basic
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::pair' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[12/18] Building swift module AST
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[13/18] Building swift module _CompilerRegexParser
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
[14/18] Building swift module Parse
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[15/18] Building swift module SIL
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::pair' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[16/18] Building swift module Optimizer
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
<unknown>:0: warning: template instantiation for 'std::reverse_iterator' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::initializer_list' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::pair' not imported: too many instantiations
<unknown>:0: warning: template instantiation for 'std::__type_identity' not imported: too many instantiations
[18/18] Linking CXX executable bin/swift-frontend

1 Like

What you're seeing is the impact of bootstrapping — we've changed the compiler, so the build system wants to rebuild the parts of the compiler that are written in Swift, which means it also needs to rebuild the standard library with the new compiler so it can be used to rebuild the parts of the compiler that are written in Swift. If you want immediate turnaround on incremental builds, you'll need to disable bootstrapping in build-script.

2 Likes

Only now am I seeing the note about that at https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md (of course). Thanks.

I added -bootstrapping=off to the build script invocation and I'm down to 20 seconds from 14 minutes. FYI, using mold --run gets it down to 3 seconds. That is after changing a cpp file. Editing a header is another story.

2 Likes