mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(fingerprint): Don't throwaway the cache on RUSTFLAGS changes
Fixes #8716
This commit is contained in:
parent
2bf35daf94
commit
306d515c08
@ -700,6 +700,18 @@ fn compute_metadata(
|
||||
.collect::<Vec<_>>();
|
||||
dep_c_extra_filename_hashes.sort();
|
||||
dep_c_extra_filename_hashes.hash(&mut c_extra_filename_hasher);
|
||||
// Avoid trashing the caches on RUSTFLAGS changing via `c_extra_filename`
|
||||
//
|
||||
// Limited to `c_extra_filename` to help with reproducible build / PGO issues.
|
||||
build_runner
|
||||
.bcx
|
||||
.extra_args_for(unit)
|
||||
.hash(&mut c_extra_filename_hasher);
|
||||
if unit.mode.is_doc() || unit.mode.is_doc_scrape() {
|
||||
unit.rustdocflags.hash(&mut c_extra_filename_hasher);
|
||||
} else {
|
||||
unit.rustflags.hash(&mut c_extra_filename_hasher);
|
||||
}
|
||||
|
||||
let c_metadata = UnitHash(c_metadata_hasher.finish());
|
||||
let c_extra_filename = UnitHash(c_extra_filename_hasher.finish());
|
||||
|
@ -68,7 +68,7 @@
|
||||
//! -------------------------------------------|-------------|---------------------|------------------------|----------
|
||||
//! rustc | ✓ | ✓ | ✓ | ✓
|
||||
//! [`Profile`] | ✓ | ✓ | ✓ | ✓
|
||||
//! `cargo rustc` extra args | ✓ | | |
|
||||
//! `cargo rustc` extra args | ✓ | ✓ | | ✓
|
||||
//! [`CompileMode`] | ✓ | ✓ | ✓ | ✓
|
||||
//! Target Name | ✓ | ✓ | ✓ | ✓
|
||||
//! `TargetKind` (bin/lib/etc.) | ✓ | ✓ | ✓ | ✓
|
||||
@ -83,7 +83,7 @@
|
||||
//! Target flags (test/bench/for_host/edition) | ✓ | | |
|
||||
//! -C incremental=… flag | ✓ | | |
|
||||
//! mtime of sources | ✓[^3] | | |
|
||||
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ | | |
|
||||
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ | ✓ | | ✓
|
||||
//! [`Lto`] flags | ✓ | ✓ | ✓ | ✓
|
||||
//! config settings[^5] | ✓ | | |
|
||||
//! `is_std` | | ✓ | ✓ | ✓
|
||||
|
@ -244,7 +244,6 @@ fn works_with_cli() {
|
||||
p.cargo("check -v -Z config-include")
|
||||
.masquerade_as_nightly_cargo(&["config-include"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-W unsafe-code -W unused`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
@ -1337,7 +1337,6 @@ fn changing_rustflags_is_cached() {
|
||||
p.cargo("build -v")
|
||||
.env("RUSTFLAGS", "-C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
@ -1347,9 +1346,7 @@ fn changing_rustflags_is_cached() {
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..] src/lib.rs [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -1357,9 +1354,7 @@ fn changing_rustflags_is_cached() {
|
||||
p.cargo("build -v")
|
||||
.env("RUSTFLAGS", "-C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -1380,7 +1375,6 @@ fn changing_rustc_extra_flags_is_cached() {
|
||||
.run();
|
||||
p.cargo("rustc -v -- -C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
@ -1390,18 +1384,14 @@ fn changing_rustc_extra_flags_is_cached() {
|
||||
|
||||
p.cargo("rustc -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
p.cargo("rustc -v -- -C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
|
@ -1509,7 +1509,6 @@ fn changing_rustflags_is_cached() {
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.env("RUSTFLAGS", "-C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
@ -1520,9 +1519,7 @@ fn changing_rustflags_is_cached() {
|
||||
p.cargo("build -Zchecksum-freshness -v")
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..] src/lib.rs [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -1531,9 +1528,7 @@ fn changing_rustflags_is_cached() {
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.env("RUSTFLAGS", "-C linker=cc")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -1556,7 +1551,6 @@ fn changing_rustc_extra_flags_is_cached() {
|
||||
p.cargo("rustc -Zchecksum-freshness -v -- -C linker=cc")
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
@ -1567,9 +1561,7 @@ fn changing_rustc_extra_flags_is_cached() {
|
||||
p.cargo("rustc -Zchecksum-freshness -v")
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..] src/lib.rs [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -1577,9 +1569,7 @@ fn changing_rustc_extra_flags_is_cached() {
|
||||
p.cargo("rustc -Zchecksum-freshness -v -- -C linker=cc")
|
||||
.masquerade_as_nightly_cargo(&["checksum-freshness"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.1 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
|
@ -103,7 +103,6 @@ fn pgo_works() {
|
||||
),
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.0.0 ([ROOT]/foo): the rustflags changed
|
||||
[COMPILING] foo v0.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-Cprofile-use=[ROOT]/foo/target/merged.profdata -Cllvm-args=-pgo-warn-missing-function`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
|
@ -616,7 +616,6 @@ fn rustc_fingerprint() {
|
||||
p.cargo("rustc -v")
|
||||
.with_stderr_does_not_contain("-C debug-assertions")
|
||||
.with_stderr_data(str![[r#"
|
||||
[DIRTY] foo v0.5.0 ([ROOT]/foo): the profile configuration changed
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
@ -1592,7 +1592,7 @@ fn rustflags_remap_path_prefix_ignored_for_c_extra_filename() {
|
||||
.run();
|
||||
let second_c_extra_filename = dbg!(get_c_extra_filename(build_output));
|
||||
|
||||
assert_data_eq!(first_c_extra_filename, second_c_extra_filename);
|
||||
assert_ne!(first_c_extra_filename, second_c_extra_filename);
|
||||
}
|
||||
|
||||
// `--remap-path-prefix` is meant to take two different binaries and make them the same but the
|
||||
@ -1613,7 +1613,7 @@ fn rustc_remap_path_prefix_ignored_for_c_extra_filename() {
|
||||
.run();
|
||||
let second_c_extra_filename = dbg!(get_c_extra_filename(build_output));
|
||||
|
||||
assert_data_eq!(first_c_extra_filename, second_c_extra_filename);
|
||||
assert_ne!(first_c_extra_filename, second_c_extra_filename);
|
||||
}
|
||||
|
||||
fn get_c_metadata(output: RawOutput) -> String {
|
||||
|
Loading…
x
Reference in New Issue
Block a user