Skip to content

[CMake] Add cross-compilation flags for when built as part of the compiler #2509

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
wants to merge 1 commit into from

Conversation

finagolfin
Copy link
Member

The compiler build defines BOOTSTRAPPING_MODE and these other flags, so this will do nothing when they aren't set. Android requires using its patched clang for linking, so use that.

I made sure this won't break a standalone CMake build by running

cmake -GNinja . -DSWIFT_HOST_MODULE_TRIPLE=aarch64-unknown-linux-android
ninja

and everything built fine with this pull natively on Android too. This implements 2. of swiftlang/swift#71507, and I just tested it by cross-compiling a recent trunk compiler for Android and running the resulting Swift 5.11 toolchain on my Android phone.

…piler

The compiler build defines `BOOTSTRAPPING_MODE` and these other flags, so this
will do nothing when they aren't set. Android requires using its patched clang
for linking, so use that.
@@ -97,6 +97,16 @@ function(add_swift_syntax_library name)
$<$<COMPILE_LANGUAGE:Swift>:-color-diagnostics>
)

if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
Copy link
Contributor

Choose a reason for hiding this comment

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

As I've mentioned in the other PRs - the goal is to require a builder toolchain, fully remove BOOTSTRAPPING_MODE, and to properly run multiple CMake invocations. We are moving towards that goal, but adding more references bootstrapping everywhere is opposite to the direction we want to go.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're going to have to clarify what you mean here, as I did on that other pull of yours.

fully remove BOOTSTRAPPING_MODE

You said earlier that you want to remove two of the options for BOOTSTRAPPING_MODE, BOOTSTRAPPING and BOOTSTRAPPING-WITH-HOSTLIBS. When I responded that that was fine but that we'd still need to differentiate between the other three options listed there, you didn't respond.

properly run multiple CMake invocations

No idea what this refers to, as building a cross-compiled toolchain like this already involves dozens of CMake invocations, a couple times for each Swift repo.

adding more references bootstrapping everywhere is opposite to the direction we want to go.

This is a single reference, because this is the build variable that currently exists to do it. Whenever you replace this build variable in the future, we can easily update this to use your new scheme.

@finagolfin
Copy link
Member Author

Alright, I asked Doug directly what the plan is on the forum and he told me that once the bootstrap modes are dropped, he wants to switch to using CMake's new built-in Swift support, rather than rolling our own flags as I'm doing here. I was just following the existing method in the compiler config, but if you guys plan on rolling that new cross-compilation method out, I'm happy to wait and see how that works, then chip in my own changes as needed.

@finagolfin finagolfin closed this Feb 24, 2024
@finagolfin finagolfin deleted the cross branch February 25, 2024 01:52
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.

2 participants