mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Also ignore remap-path-prefix in metadata for cargo rustc
.
This commit is contained in:
parent
705009eb38
commit
d99b7fede7
@ -547,32 +547,36 @@ fn compute_metadata<'a, 'cfg>(
|
||||
// settings like debuginfo and whatnot.
|
||||
unit.profile.hash(&mut hasher);
|
||||
unit.mode.hash(&mut hasher);
|
||||
if let Some(args) = bcx.extra_args_for(unit) {
|
||||
args.hash(&mut hasher);
|
||||
}
|
||||
|
||||
// Throw in the rustflags we're compiling with.
|
||||
// This helps when the target directory is a shared cache for projects with different cargo configs,
|
||||
// or if the user is experimenting with different rustflags manually.
|
||||
let mut flags = if unit.mode.is_doc() {
|
||||
cx.bcx.rustdocflags_args(unit)
|
||||
let mut hash_flags = |flags: &[String]| {
|
||||
// Ignore some flags. These may affect reproducible builds if they affect
|
||||
// the path. The fingerprint will handle recompilation if these change.
|
||||
let mut iter = flags.iter();
|
||||
while let Some(flag) = iter.next() {
|
||||
if flag.starts_with("--remap-path-prefix=") {
|
||||
continue;
|
||||
}
|
||||
if flag == "--remap-path-prefix" {
|
||||
iter.next();
|
||||
continue;
|
||||
}
|
||||
flag.hash(&mut hasher);
|
||||
}
|
||||
};
|
||||
if let Some(args) = bcx.extra_args_for(unit) {
|
||||
// Arguments passed to `cargo rustc`.
|
||||
hash_flags(args);
|
||||
}
|
||||
// Arguments passed in via RUSTFLAGS env var.
|
||||
let flags = if unit.mode.is_doc() {
|
||||
bcx.rustdocflags_args(unit)
|
||||
} else {
|
||||
cx.bcx.rustflags_args(unit)
|
||||
}
|
||||
.iter();
|
||||
|
||||
// Ignore some flags. These may affect reproducible builds if they affect
|
||||
// the path. The fingerprint will handle recompilation if these change.
|
||||
while let Some(flag) = flags.next() {
|
||||
if flag.starts_with("--remap-path-prefix=") {
|
||||
continue;
|
||||
}
|
||||
if flag == "--remap-path-prefix" {
|
||||
flags.next();
|
||||
continue;
|
||||
}
|
||||
flag.hash(&mut hasher);
|
||||
}
|
||||
bcx.rustflags_args(unit)
|
||||
};
|
||||
hash_flags(flags);
|
||||
|
||||
// Artifacts compiled for the host should have a different metadata
|
||||
// piece than those compiled for the target, so make sure we throw in
|
||||
|
@ -1361,7 +1361,7 @@ fn env_rustflags_misspelled_build_script() {
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn reamp_path_prefix_ignored() {
|
||||
fn remap_path_prefix_ignored() {
|
||||
// Ensure that --remap-path-prefix does not affect metadata hash.
|
||||
let p = project().file("src/lib.rs", "").build();
|
||||
p.cargo("build").run();
|
||||
@ -1372,15 +1372,24 @@ fn reamp_path_prefix_ignored() {
|
||||
assert_eq!(rlibs.len(), 1);
|
||||
p.cargo("clean").run();
|
||||
|
||||
let check_metadata_same = || {
|
||||
let rlibs2 = p
|
||||
.glob("target/debug/deps/*.rlib")
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap();
|
||||
assert_eq!(rlibs, rlibs2);
|
||||
};
|
||||
|
||||
p.cargo("build")
|
||||
.env(
|
||||
"RUSTFLAGS",
|
||||
"--remap-path-prefix=/abc=/zoo --remap-path-prefix /spaced=/zoo",
|
||||
)
|
||||
.run();
|
||||
let rlibs2 = p
|
||||
.glob("target/debug/deps/*.rlib")
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap();
|
||||
assert_eq!(rlibs, rlibs2);
|
||||
check_metadata_same();
|
||||
|
||||
p.cargo("clean").run();
|
||||
p.cargo("rustc -- --remap-path-prefix=/abc=/zoo --remap-path-prefix /spaced=/zoo")
|
||||
.run();
|
||||
check_metadata_same();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user