Skip to content

Conversation

@cbarrete
Copy link

See the commit message for context.

Note that it I am not 100% confident about what impact this has on cross compilation, because there are no tests/examples for it.

Because of the usage of `env!`, we were baking paths to generated files
in `lib.rs`. In setups where the build can be executed remotely (e.g.
when building with Buck2), those paths would be different depending on
whether the build ran locally or remotely.

This difference propagates to `pyo3-macros`. Because Buck2 runs the
metadata and codegen builds separately (for increased parallelism), they
can have different contents due to the above, causing rustc to find two
versions of the crate, and erroring out. This is not observable with
Cargo because it runs both builds with the same rustc invocation.

See facebook/buck2#1206 and
rwf2/Rocket#2797 for more context.

This commit fixes the issue by simply reading `OUT_DIR` at run-time,
rather than compile-time, so that the content of `lib.rs` is fixed.

Closes facebook/buck2#1206

Many thanks to https://github.com/cormacrelf for pointing out the root
of the issue.
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.

1 participant