Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,15 @@ fn calculate_normal(
if let Some(allow_features) = &build_runner.bcx.gctx.cli_unstable().allow_features {
allow_features.hash(&mut config);
}
// -Zno-embed-metadata changes how all units are compiled, and it also changes how we tell
// rustc to link to deps using `--extern`. If it changes, we should rebuild everything.
build_runner
.bcx
.gctx
.cli_unstable()
.no_embed_metadata
.hash(&mut config);

let compile_kind = unit.kind.fingerprint_hash();
let mut declared_features = unit.pkg.summary().features().keys().collect::<Vec<_>>();
declared_features.sort(); // to avoid useless rebuild if the user orders it's features
Expand Down
58 changes: 54 additions & 4 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6338,8 +6338,8 @@ fn renamed_uplifted_artifact_remains_unmodified_after_rebuild() {
assert!(not_the_same, "renamed uplifted artifact must be unmodified");
}

#[cargo_test(nightly, reason = "-Zembed-metadata is nightly only")]
fn embed_metadata() {
#[cargo_test(nightly, reason = "-Zno-embed-metadata is nightly only")]
fn no_embed_metadata() {
let p = project()
.file(
"Cargo.toml",
Expand Down Expand Up @@ -6378,8 +6378,8 @@ fn embed_metadata() {

// Make sure that cargo passes --extern=<dep>.rmeta even if <dep>
// is compiled as a dylib.
#[cargo_test(nightly, reason = "-Zembed-metadata is nightly only")]
fn embed_metadata_dylib_dep() {
#[cargo_test(nightly, reason = "-Zno-embed-metadata is nightly only")]
fn no_embed_metadata_dylib_dep() {
let p = project()
.file(
"Cargo.toml",
Expand Down Expand Up @@ -6425,3 +6425,53 @@ fn embed_metadata_dylib_dep() {
)
.run();
}

#[cargo_test(nightly, reason = "-Zno-embed-metadata is nightly only")]
fn no_embed_metadata_invalidate() {
// Invalidate all deps when -Zno-embed-metadata is toggled
let p = project()
.file(
"Cargo.toml",
r#"
[package]

name = "foo"
version = "0.5.0"
edition = "2015"

[dependencies.bar]
path = "bar"
"#,
)
.file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &[]))
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
.file(
"bar/src/bar.rs",
r#"
pub fn gimme() -> &'static str {
"test passed"
}
"#,
)
.build();

p.cargo("build -Z no-embed-metadata")
.masquerade_as_nightly_cargo(&["-Z no-embed-metadata"])
.with_stderr_data(str![[r#"
[LOCKING] 1 package to latest compatible version
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
p.cargo("build")
.masquerade_as_nightly_cargo(&["-Z no-embed-metadata"])
.with_stderr_data(str![[r#"
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]])
.run();
}