Skip to content

Potential fix for --xcode build on M1. #58957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2022

Conversation

johnno1962
Copy link
Contributor

@johnno1962 johnno1962 commented May 18, 2022

Hi Apple,

I've been having difficulties building the Swift compiler on an M1 for some time now. This small CMake fix seems to resolve the problem and carry relatively little risk of regression. The problem was the generated SwiftInTheCompiler.xcodeproj was silently failing to build the static libraries containing Swift sources used in the bootstrapping process to link them into the compiler. This seems to be a feature of Xcode when the target doesn't contain a "Compile Sources" build phase and only links object files (I have no idea why this would be specific to M1.) By creating a dummy source file and including it in the project this forces Xcode to build the static library and subsequent bootstrapping stages can proceed.

I'm using Xcode 13.4 & 13.2.1, CMake 3.23.1 & 3.20.1

@philipturner
Copy link
Contributor

I have had to manually pass --bootstrapping=off into the compiler for quite a while now, so I'm glad to see the need for that go away. However, I sometimes need to test an older commit in this repository to bisect where a bug originated. Could we add documentation to GettingStarted.md warning users about this flag?

@johnno1962
Copy link
Contributor Author

johnno1962 commented May 18, 2022

I can do that even if perhaps it is better in a separate PR. Can you suggest some wording and where to add it?

@eeckstein
Copy link
Contributor

eeckstein commented May 18, 2022

For local development you should use --bootstrapping=hosttools. This avoids bootstrapping by compiling the swift sources with the installed Xcode. It speeds up the build

@johnno1962
Copy link
Contributor Author

So we're happy leaving the default documented invocation for the build not working on M1?

@philipturner
Copy link
Contributor

I can do that even if perhaps it is better in a separate PR. Can you suggest some wording and where to add it?

I don't think I have the time to do that myself, but I would definitely review a PR made by someone else.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@johnno1962
Copy link
Contributor Author

Thanks @eeckstein

@LucianoPAlmeida
Copy link
Contributor

@swift-ci Please test

@johnno1962
Copy link
Contributor Author

Thanks @LucianoPAlmeida

@LucianoPAlmeida
Copy link
Contributor

Since it got the approval, let's :shipit:

@LucianoPAlmeida LucianoPAlmeida merged commit c9d9226 into swiftlang:main May 21, 2022
@johnno1962
Copy link
Contributor Author

johnno1962 commented May 21, 2022

Terrific, thanks again! Does anybody have any ideas on what the problem with using utils/build-toolchain on an M1 might be? It doesn't seem to have been adapted for bootstrapping even if you turn it off. Pointers welcome as I may take a look at it myself though these days I just download one of the nightlies and symbolically link build products into it to work with Xcode.

@johnno1962
Copy link
Contributor Author

I made some progress getting a toolchain out on an M1 by using "Rosetta2" in the end. #56426 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants