Skip to content
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

Add patch for Apple cross compilation on 3.13+ #323

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Conversation

zanieb
Copy link
Collaborator

@zanieb zanieb commented Sep 7, 2024

Following up on #319 — adds a patch to support cross-compilation as we do for previous Python versions.

@zanieb
Copy link
Collaborator Author

zanieb commented Sep 7, 2024

@indygreg could you give me some context on testing this since it's not needed for CI to pass?

Copy link
Owner

@indygreg indygreg left a comment

Choose a reason for hiding this comment

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

You test this by passing --target-triple to ./build-macos.py targeting the non-native target. So from Apple Silicon you want --target-triple x86_64-apple-darwin to cross-compile to x86-64. A working build is almost certainly sign of success.

To test from CI, you could switch the macOS runners to a new/old version to force cross-compiles. PGO and BOLT would stop working. But it otherwise should just work.

@zanieb
Copy link
Collaborator Author

zanieb commented Sep 8, 2024

Ah okay that makes sense — I was wondering why CI didn't cross compile if we were patching for it and thought maybe this was for some other target.

This fails for me:

cpython-3.13> configure: error: cross build not supported for x86_64-apple-darwin

I'll play with the patch some more.

@indygreg
Copy link
Owner

indygreg commented Sep 8, 2024

CPython's build system has historically made some questionable decisions about how to build on/for Apple platforms. e.g. they've historically not supported cross-compiling (unless doing a multi-arch "universal" build) despite cross-compiling for Apple platforms being probably one of the easiest platforms to cross-compile for!

My guess is they tweaked more configure checks in this area (possibly as part of shoring up iOS support) and created more work for us in the process.

We don't need to support cross-compiles anymore. Historically I needed it because GitHub Actions didn't have macOS ARM runners. At the moment we have x86-64 and ARM macOS runners and all is well.

@zanieb
Copy link
Collaborator Author

zanieb commented Sep 8, 2024

It actually is really nice to be able to cross-compile so I can test the x86_64 builds from my laptop. Our builds are also slowed down by GitHub's concurrent macOS job limit (only 5). There are alternative platforms that provide macOS runners that would let us have a higher concurrency limit, but they only support ARM. I'll probably try to fix it slowly.

@zanieb zanieb force-pushed the zb/3.13-apple-cross branch from 030f947 to 99d223e Compare September 8, 2024 13:59
@zanieb
Copy link
Collaborator Author

zanieb commented Sep 8, 2024

Alright turned out to be pretty easy, works locally.

@zanieb zanieb merged commit 523c1ed into main Sep 8, 2024
292 checks passed
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