Skip to content

Move env! to env::var_os for buck determinism#4578

Closed
capickett wants to merge 1 commit intoPyO3:mainfrom
fbsource:env-non-determinism
Closed

Move env! to env::var_os for buck determinism#4578
capickett wants to merge 1 commit intoPyO3:mainfrom
fbsource:env-non-determinism

Conversation

@capickett
Copy link

When building pyo3 with buck2 and remote execution, we're especially sensitive to deterministic builds and being able to compile different rust libraries on different hosts in parallel.

The issue with resolve_cross_compile_config_path was that we were embedding the full path of OUT_DIR into the compiled rlib and we are unable to guarantee the path is identical across all invocations of rustc. The other instances of env!("OUT_DIR") are no issue as they are used as part of the larger expression include_str!(concat!(env!("OUT_DIR"), "/pyo3-build-config-file.txt")); and we are able to guarantee that the contents of those files are deterministic.

By switching to env::var_os("OUT_DIR"), we are able to avoid embedding absolute paths into the compiled rust library and maintain backwards compatibility with the rest of the cargo ecosystem.

@capickett
Copy link
Author

@laudv
Copy link

laudv commented Sep 26, 2024

Related: #4555

@davidhewitt
Copy link
Member

Thanks very much for the PR! I think you're right that there's a problem here, but I worry that this isn't the complete solution. I'll write up my observations in an issue now...

@davidhewitt
Copy link
Member

See #4579

facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Sep 27, 2024
Summary:
PyO3/pyo3#4578

After investigation with JakobDegen, we found that `OUT_DIR` was being embedded in pyo3-build-config. P1610233931

This introduces non-determinism in our builds when I tried to land D63335477

Reviewed By: dtolnay

Differential Revision: D63425591

fbshipit-source-id: ef1ab359e967a8723fddb938d1f5fd6226268f12
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Sep 27, 2024
Summary:
PyO3/pyo3#4578

After investigation with JakobDegen, we found that `OUT_DIR` was being embedded in pyo3-build-config. P1610233931

This introduces non-determinism in our builds when I tried to land D63335477

Reviewed By: dtolnay

Differential Revision: D63425591

fbshipit-source-id: ef1ab359e967a8723fddb938d1f5fd6226268f12
@davidhewitt
Copy link
Member

Given that there's a more complex problem here, which I don't think this solves, I will close this PR. Let's please continue figuring out what to do on #4579.

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.

3 participants