Dropping the requirement for C++-only bootstrapping

Dear compiler developers,

I'm happy to announce that from now on "mandatory" parts of the compiler can be implemented in Swift (on the main branch).
So far we only used Swift as an implementation language in parts of the compiler which are not strictly necessary for correct code generation of the standard library, like some optimization passes.
Now, we can use Swift in all parts of the compiler, including the parser, AST, type checker or mandatory SIL passes.

We are dropping the requirement to bootstrap the compiler with a pure C++ host toolchain.
Instead we are requiring that a Swift toolchain must be present to build the compiler.

How to bring the Swift compiler to new platforms where no Swift host toolchain is available, yet?
This can be done by bootstrapping with the 6.4 compiler. The 6.4 compiler is the last release which can be bootstrapped without a Swift host compiler. On the new platform the 6.4 compiler can be built and used as a Swift host toolchain.

34 Likes

This is great news, thanks to all who made is possible!

Does this mean that certain parts of the compiler, like the C++ parser, will be removed soon? Can new changes to the language grammar be implemented only in swift-syntax instead of both parsers as has been the case up until now?

Is there a documented policy for which host compilers will be supported going forward (e.g., "Swift 6.X can be built with a Swift 6.(X – 2) compiler" or something similar)?

2 Likes

Does this mean that certain parts of the compiler, like the C++ parser, will be removed soon?

No, this just means that parts can be replaced :slight_smile:

@Douglas_Gregor may know some details on the parser.

Is there a documented policy for which host compilers will be supported going forward (e.g., "Swift 6.X can be built with a Swift 6.(X – 2) compiler" or something similar)?

not yet
cc @etcwilde

2 Likes

Alternatively, you can cross-compile a bootstrap compiler on one of the well-supported host platforms, then use that on the new platform to build the Swift compiler natively. That is how @networkextension appears to have gotten FreeBSD AArch64 going.

The linux CI builds the trunk Swift toolchain with Swift 5.9.2, ensuring no later Swift features creep into the Swift code used in the Swift compiler itself, but we're currently looking at upping that to Swift 6.2.4.