Skip to content

Commit bd57eb5

Browse files
borsehuss
authored andcommitted
Auto merge of #8290 - ehuss:fix-lld-freshness, r=alexcrichton
Fix fingerprinting for lld on Windows with dylib. This fixes an issue where if `lld` is used on Windows, dynamic libraries will never be treated as "fresh". This is a regression from #8210 where Cargo is expecting export files to be created, but lld does not create these. The solution is to ignore "Auxiliary" files in fingerprinting, which AFAIK aren't really needed (only the primary output files really matter). Fixes #8284
1 parent 9fcb8c1 commit bd57eb5

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/cargo/core/compiler/fingerprint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
12291229
let outputs = cx
12301230
.outputs(unit)?
12311231
.iter()
1232-
.filter(|output| output.flavor != FileFlavor::DebugInfo)
1232+
.filter(|output| !matches!(output.flavor, FileFlavor::DebugInfo | FileFlavor::Auxiliary))
12331233
.map(|output| output.path.clone())
12341234
.collect();
12351235

tests/testsuite/freshness.rs

+36
Original file line numberDiff line numberDiff line change
@@ -2436,3 +2436,39 @@ fn linking_interrupted() {
24362436
)
24372437
.run();
24382438
}
2439+
2440+
#[cargo_test]
2441+
#[cfg_attr(
2442+
not(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")),
2443+
ignore
2444+
)]
2445+
fn lld_is_fresh() {
2446+
// Check for bug when using lld linker that it remains fresh with dylib.
2447+
let p = project()
2448+
.file(
2449+
".cargo/config",
2450+
r#"
2451+
[target.x86_64-pc-windows-msvc]
2452+
linker = "rust-lld"
2453+
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
2454+
"#,
2455+
)
2456+
.file(
2457+
"Cargo.toml",
2458+
r#"
2459+
[package]
2460+
name = "foo"
2461+
version = "0.1.0"
2462+
2463+
[lib]
2464+
crate-type = ["dylib"]
2465+
"#,
2466+
)
2467+
.file("src/lib.rs", "")
2468+
.build();
2469+
2470+
p.cargo("build").run();
2471+
p.cargo("build -v")
2472+
.with_stderr("[FRESH] foo [..]\n[FINISHED] [..]")
2473+
.run();
2474+
}

0 commit comments

Comments
 (0)