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

Cargo should provide --remap-path-prefix or not hash it from RUSTFLAGS. #6914

Closed
eddyb opened this issue May 7, 2019 · 2 comments · Fixed by #6966
Closed

Cargo should provide --remap-path-prefix or not hash it from RUSTFLAGS. #6914

eddyb opened this issue May 7, 2019 · 2 comments · Fixed by #6966
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@eddyb
Copy link
Member

eddyb commented May 7, 2019

After #6503, reproducible build setups that were setting RUSTFLAGS="--remap-path-prefix=..." in order to normalize paths in rustc, stopped being reproducible, as Cargo is now hashing the whole RUSTFLAGS value, resulting in different -C metadata values.

This was originally reported in rust-lang/rust#59542, and one of the solutions suggested there was that Cargo should provide its own --remap-path-prefix, which would not be hashed, and that becomes the supported way set this flag.

Another possibility could be Cargo parsing --remap-path-prefix out of RUSTFLAGS, before hashing the rest, but that seems perhaps a bit brittle.

cc @michaelwoerister @Eh2406

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label May 8, 2019
@jhfrontz
Copy link

Can I petition to have this changed from "feature request" to "use-blocking bug"? I mean, it was working fine until it got broken.

@alexcrichton
Copy link
Member

One workaround for this which I've forgotten to mention earlier is something like this:

$ RUSTC=./my-rustc-wrapper.sh cargo build

and the contents of my-rustc-wrapper.sh are:

#!/bin/sh
exec rustc "$@" --remap-path-prefix ...

and that will subvert Cargo's hashing.

bors added a commit that referenced this issue Jun 6, 2019
Ignore remap-path-prefix in metadata hash.

Including this flag in the metadata hash causes problems with reproducible builds.

I spent some time considering the different alternatives (such as providing a config option, or an unhashed RUSTFLAGS alternative), and decided this might be the best option.

- It is a very simple, small change.
- It should be safe.
- It is transparent to the user, they don't need to do anything special.
- It doesn't expand Cargo's interface.

Fixes #6914.
@bors bors closed this as completed in #6966 Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants