Skip to content

Commit

Permalink
Auto merge of rust-lang#8290 - ehuss:fix-lld-freshness, r=alexcrichton
Browse files Browse the repository at this point in the history
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 rust-lang#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 rust-lang#8284
  • Loading branch information
bors authored and ehuss committed Jun 5, 2020
1 parent 9fcb8c1 commit bd57eb5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
let outputs = cx
.outputs(unit)?
.iter()
.filter(|output| output.flavor != FileFlavor::DebugInfo)
.filter(|output| !matches!(output.flavor, FileFlavor::DebugInfo | FileFlavor::Auxiliary))
.map(|output| output.path.clone())
.collect();

Expand Down
36 changes: 36 additions & 0 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2436,3 +2436,39 @@ fn linking_interrupted() {
)
.run();
}

#[cargo_test]
#[cfg_attr(
not(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")),
ignore
)]
fn lld_is_fresh() {
// Check for bug when using lld linker that it remains fresh with dylib.
let p = project()
.file(
".cargo/config",
r#"
[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
"#,
)
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[lib]
crate-type = ["dylib"]
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("build").run();
p.cargo("build -v")
.with_stderr("[FRESH] foo [..]\n[FINISHED] [..]")
.run();
}

0 comments on commit bd57eb5

Please sign in to comment.