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

Open
kpcyrd opened this issue May 10, 2018 · 11 comments
Open

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

kpcyrd opened this issue May 10, 2018 · 11 comments
Labels
A-reproducibility Area: reproducible / deterministic builds

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

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
Projects
None yet
Development

No branches or pull requests

8 participants