-
Notifications
You must be signed in to change notification settings - Fork 792
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
pyo3-build-config: fix cross compilation #1648
Conversation
fdcb439
to
55d9581
Compare
@alonblade I just rebased this branch on your other cross-compilation PR. Would you be willing to try this branch out to confirm whether it's now fixed the issues with cross-compilation? Thanks. |
55d9581
to
ab6114a
Compare
Yep - builds with target armhf on host x86_64. |
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.
LGTM.
So it's important to note that pyo3-build-config should only be used in build time dependencies for example build.rs
or proc macro, never intended to be used in the main pyo3
crate. pyo3
should use normal cfg
s.
Yep precisely. I'm planning to add some updates to |
(I'll merge this after I add some more test coverage.) |
b7e192f
to
6b6b312
Compare
6b6b312
to
5cc1e0f
Compare
I've pushed the coverage much higher. The job is still failing but I'm not sure it's worth doing further (only just slightly under the target), so proceeding to merge. |
Glad you merged it. Btw, somewhat related, I wanted to take the CI for cross builds ticket (I have a setup with bitbucket that works for my pyo3 using project for aarch64 & armhf) but I got stuck on the "I don't grok the yml of github yet" problem. I could just through my current bitbucket CI or even just a docker one using a simplified project, would that help? @davidhewitt |
@alonblade I've done a lot of cross compilation jobs with GitHub Actions, so I've opened #1700 |
@messense sweet. |
This fixes cross-compilation with the new
pyo3-build-config
crate.The problem is that
CARGO_CFG_TARGET_OS
(and similar) environment variables are set to the host OS when running thebuild.rs
inpyo3-build-config
, becausepyo3-build-config
is used inbuild-dependencies
.The best way I can see to fix this is to evaluate the build configuration in the
build.rs
of the first runtime dependency we control - PyO3'sbuild.rs
.Before:
build.rs
inpyo3-build-config
runs (incorrectly) and generates config information, which gets baked into thepyo3-build-config
cratepyo3
,pyo3-build-config
) use this baked-in configurationThis PR:
build.rs
inpyo3-build-config
creates an emptyOUT_DIR
build.rs
inpyo3
writes the correct config to thatOUT_DIR
build.rs
pyo3-macros-backend
can load this configuration at macro runtime and check itcc @birkenfeld this will slightly change how to check for
METH_FASTCALL
support in #1619 - instead of usingcfg!
, it's now necessary to usepyo3_build_config::get()
and check the configuration directly. This is necessary becausepyo3-macros-backend
is built beforepyo3
, so the configuration hasn't yet been written whenpyo3-macros-backend
is built.