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

Reproducible builds: Automatically remap $CARGO_HOME and $PWD #5505

Closed
kpcyrd opened this issue May 10, 2018 · 14 comments
Closed

Reproducible builds: Automatically remap $CARGO_HOME and $PWD #5505

kpcyrd opened this issue May 10, 2018 · 14 comments
Labels
A-reproducibility Area: reproducible / deterministic builds S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@kpcyrd
Copy link

kpcyrd commented May 10, 2018

As a followup of rust-lang/rust#41555, I think $CARGO_HOME and $PWD (the location of the project) should be remapped to fixed values automatically.

I found both of those paths inside binaries and I have to add boilerplate to all of my reprotest scripts to normalize them.

The motivation behind this is that alice and bob can both download the same release of a rust project, cargo build --release it and end up with a 100% identical binary, given a sufficiently similar build environment (rustc version and system libraries).

@alexcrichton
Copy link
Member

Thanks for the report! I think this is plausible to do but currently if done naively I think it would break all debugger integrations, so we probably don't want to do this until that's fixed.

@sanxiyn
Copy link
Member

sanxiyn commented May 10, 2018

Maybe we can do this only on release builds?

@alexcrichton
Copy link
Member

If we can solve the debug problem, yes we may be able to do it by default on release builds as well.

@kpcyrd
Copy link
Author

kpcyrd commented May 22, 2018

@alexcrichton debugging in rust depends on debug symbols, correct?

[profile.dev]
debug = true       # include debug information (debug symbols). Equivalent to
                   # `-C debuginfo=2` compiler flag.

couldn't we remap those paths if debug is set to false?

@alexcrichton
Copy link
Member

Perhaps, but I believe they still show up in panic paths

@mfarrugi
Copy link

mfarrugi commented Oct 20, 2018

@alexcrichton Any additional colour on what could/would break wrt debuggers? I am somewhat surprised $PWD makes it into the binaries at all.

Edit:
When I run strings on a 1.29.2 release or debug binary, I don't see $PWD in there at all.

@alexcrichton
Copy link
Member

@mfarrugi debuggers use the paths in debuginfo (which don't show up in strings output) for setting breakpoints and showing code whiel you're stepping through code. Anything which references a registry crate has an absolute path and can be debugged by setting breakpoints on the file and such. Crates in the cwd, if referenced via an absolute path, are also loaded by the debugger and would break as $PWD/foo.rs doesn't actually exist

@infinity0
Copy link
Contributor

The question is what to map the paths to. In Debian we install source code into /usr/share/cargo/registry but other systems might be different. Ideally we'd map it to a virtual path like $CARGO_REGISTRY and put the logic of "where is $CARGO_REGISTRY" into the system debugger itself.

@chemsaf3
Copy link

these also look blocking

rust-lang/rust#40374
rust-lang/rust#40552
rust-lang/rust#75263

@sundeep-kokkonda
Copy link

sundeep-kokkonda commented Oct 7, 2022

I am also facing reproducible issue, reported in rust-lang/rust#102299

I tried adding--remap-path-prefix flag but still the binaries are not reproducible. But, I suspect my change is effective or not, can anyone let me know where exactly I should add this flag?

@sundeep-kokkonda
Copy link

@alexcrichton How can I make rust builds are reproducible? can you let me the procedure that you know or can u guide me?. The reproducible issue I faced is reported here rust-lang/rust#102299

@epage
Copy link
Contributor

epage commented Oct 19, 2023

We also have rust-lang/rust#111540 which might help

@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label Oct 19, 2023
@weihanglo
Copy link
Member

Wonder if we should close this in favor of rust-lang/rust#111540 and #12137?

@ehuss
Copy link
Contributor

ehuss commented Oct 31, 2023

Yea, closing since this is now implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reproducibility Area: reproducible / deterministic builds S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

10 participants