mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Ignore remap-path-prefix in metadata hash.
This commit is contained in:
parent
5a0c31d819
commit
c8a9f88f09
@ -513,10 +513,24 @@ fn compute_metadata<'a, 'cfg>(
|
|||||||
// Throw in the rustflags we're compiling with.
|
// Throw in the rustflags we're compiling with.
|
||||||
// This helps when the target directory is a shared cache for projects with different cargo configs,
|
// 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.
|
// or if the user is experimenting with different rustflags manually.
|
||||||
if unit.mode.is_doc() {
|
let mut flags = if unit.mode.is_doc() {
|
||||||
cx.bcx.rustdocflags_args(unit).hash(&mut hasher);
|
cx.bcx.rustdocflags_args(unit)
|
||||||
} else {
|
} else {
|
||||||
cx.bcx.rustflags_args(unit).hash(&mut hasher);
|
cx.bcx.rustflags_args(unit)
|
||||||
|
}
|
||||||
|
.into_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Artifacts compiled for the host should have a different metadata
|
// Artifacts compiled for the host should have a different metadata
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
//! Target flags (test/bench/for_host/edition) | ✓ |
|
//! Target flags (test/bench/for_host/edition) | ✓ |
|
||||||
//! -C incremental=… flag | ✓ |
|
//! -C incremental=… flag | ✓ |
|
||||||
//! mtime of sources | ✓[^3] |
|
//! mtime of sources | ✓[^3] |
|
||||||
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ |
|
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ | ✓
|
||||||
//!
|
//!
|
||||||
//! [^1]: Build script and bin dependencies are not included.
|
//! [^1]: Build script and bin dependencies are not included.
|
||||||
//!
|
//!
|
||||||
|
@ -1359,3 +1359,28 @@ fn env_rustflags_misspelled_build_script() {
|
|||||||
.with_stderr_contains("[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?")
|
.with_stderr_contains("[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reamp_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();
|
||||||
|
let rlibs = p
|
||||||
|
.glob("target/debug/deps/*.rlib")
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(rlibs.len(), 1);
|
||||||
|
p.cargo("clean").run();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user