-
Notifications
You must be signed in to change notification settings - Fork 1.4k
A small step toward building a toolchain on M1 Mac #3500
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not going to work when other cross-compilation targets are added, such as in my Android pull #3403. As I said, this is a hack that should not be merged: the real fix is upstream in the Swift compiler repo where this flag is incorrectly passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I wonder if we're conflating two concepts here: compile for a different platform vs. compile for all the architectures for a platform. For example, in general it's not going to be possible (I believe) to build for more than one platform at a time, while it's possible to build for as many architectures as that one platform will support.
When you say that the Swift compiler repo is incorrectly passing this flag: would it work to have a different flag that causes all the architectures to be built? It seems to me that that's what's needed when building toolchains on a particular platform, whether it's Darwin or something else: the distributable builds should have all the architectures supported by that platform (whereas debug builds might not, for performance reasons).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me begin by saying that this line that is being replaced was a hack too, as it was added just a month before the 5.3 release in 6306663 then merged back to master in 242e733. It only cross-compiles one-way, from macOS Intel to arm64 as you noticed too, which made sense as there wasn't much Apple Silicon (AS) hardware at the time. It will need to be cleaned up now that there is more AS hardware out there, but this pull is the wrong way to do it.
I suggest that one of you talk to Mishal and find out if he really wants
build-toolchain
to build both toolchains by default, as that is the command prescribed to even new Swift devs. I suspect he did not intend that and just meant to test this cross-compilation on the CI. Depending on what he says, you can work out how best to rework this. Note that if you really know what you're doing and usebuild-script
instead, you will not hit this issue: this is only a problem with that preset andbuild-toolchain
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional observations @buttaface — I didn't realize that the desktop build instructions for Swift involves a universal build. That seems suboptimal.
@shahmishal Can we fix this so that:
build-toolchain
(or whatever script we tell people to use on the desktop) only builds the host architecture by defaultbootstrap
script to let it be built universally regardless of what architecture it's currently being built onI can take care of the SwiftPM changes but it sounds as if there are other changes needed to the Swift build scripts, and I'm not at all familiar with them. What other things need to happen to fix this?
What I'd like to end up with from SwiftPM's perspective is that running
bootstrap
with no options should only build for the host (as it does today), but that there should be a single standard option (e.g.--build-universal
) that builds for all the architectures (currently x86_64 and arm64 on Darwin, but possibly other combinations on other platforms) regardless of the host architecture.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a flag to
build-toolchain
to all for user to build universal or host specific toolchain.Agree, we should continue to build universal for nightly and release toolchains.
This should be based on the argument provided by
build-script
to avoid building missing arch in swiftpm. I wonder if we can look up which arch swift was built with and build matching arch. (lipo -info
)