What is the status of bootstrapping, and what is its roadmap?

Hi, I've been playing around with changes to the Swift compiler, but I have to turn off bootstrapping because it's an M1 Mac. I'm curious how different my build is from the one shipped in Xcode.
What does bootstrapping change right now, exactly? Are there parts of the compiler, such as optimization passes, that are currently written in Swift and which are silently disabled when turning bootstrapping off? I also see that swift-driver is included as a sibling directory swift, does that mean that the swift-driver is currently used if bootstrapping is enabled? What is the timeline of moving the Swift compiler into Swift, e.g. with swift-driver? What is the timeline of getting arm64 Macs to build the project with bootstrapping turned on? Does the Swift compiler shipped with Xcode currently have bootstrapping turned on? Does performance typically differ between the C++ and Swift version of each piece? Thanks.

1 Like

but I have to turn off bootstrapping because it's an M1 Mac

Bootstrapping should work with apple silicon macs. Can you provide more details of the problem you are seeing?

Are there parts of the compiler, such as optimization passes, that are currently written in Swift and which are silently disabled when turning bootstrapping off?

Exactly. With bootstrapping turned off some optimization passes do not run.

does that mean that the swift-driver is currently used if bootstrapping is enabled?

"Bootstrapping" only refers to parts of the swift-frontend which are implemented in swift. It's not related to the swift driver.

2 Likes

What error are you seeing? I had issues building on my M2 last week, but the ultimate issue turned out to be that i had an x86 python3 sitting around in my PATH from when i transferred from an Intel Mac. When i properly installed an ARM Python and made sure it was what was used by build-script, i could build just fine with the default bootstrapping argument.

1 Like

When I run without --bootstrapping=off, I get the following error:

Ld /Users/meisel/projects/swift-project-5-7-1/build/Xcode-RelWithDebInfo/swift-macosx-arm64/bootstrapping1/RelWithDebInfo/bin/swift-frontend normal (in target 'swift-frontend-bootstrapping1' from project 'Swift')
...
clang: error: no such file or directory: '/Users/meisel/projects/swift-project-5-7-1/build/Xcode-RelWithDebInfo/swift-macosx-arm64/lib/RelWithDebInfo/libswiftCompilerModules-bootstrapping1.a'
Command Ld failed with a nonzero exit code

The last part of the build log is here. I also see that in the docs, it tells you to add --bootstrapping=off for arm Macs.

It looks like you are building with Xcode. That's broken.
Building with ninja should work. The way to develop with Xcode and build with ninja is described here: https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#using-ninja-with-xcode

I also see that in the docs , it tells you to add --bootstrapping=off for arm Macs.

This comment is wrong. I'll remove it.

does that mean that the swift-driver is currently used if bootstrapping is enabled?

The swift-driver is now a separate executable written in Swift and is separate from the bootstrapping effort in the main swift-frontend executable, which is still mostly C++.

What is the timeline of moving the Swift compiler into Swift, e.g. with swift-driver? What is the timeline of getting arm64 Macs to build the project with bootstrapping turned on?

When it's done? I've never seen a timeline for any internal compiler efforts.

Does the Swift compiler shipped with Xcode currently have bootstrapping turned on?

You can check this for yourself, as I did for linux, by seeing if the macOS compiler links against the Swift stdlib.

Does performance typically differ between the C++ and Swift version of each piece?

I think they said the Swift version was 10-30% slower? Just a vague impression I have from some forum post.

This comment is wrong. I'll remove it.

@Erik_Eckstein, @anthonylatsis put that in a couple months ago because of this issue.

1 Like

See docs: fix info about bootstrapping by eeckstein · Pull Request #63381 · apple/swift · GitHub and my comment in Bootstrapping broken for Ninja builds on Apple silicon Macs (arm64) · Issue #62017 · apple/swift · GitHub

Could you share the build-script invocation that caused this error?