Skip to content

Commit 61f9588

Browse files
committed
Don't hardlink rmeta files.
1 parent 1ffd248 commit 61f9588

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
245245
let mut unsupported = Vec::new();
246246
{
247247
if unit.mode.is_check() {
248-
// This is not quite correct for non-lib targets. rustc
249-
// currently does not emit rmeta files, so there is nothing to
250-
// check for! See #3624.
248+
// This may be confusing. rustc outputs a file named `lib*.rmeta`
249+
// for both libraries and binaries.
251250
let path = out_dir.join(format!("lib{}.rmeta", file_stem));
252-
let hardlink = link_stem
253-
.clone()
254-
.map(|(ld, ls)| ld.join(format!("lib{}.rmeta", ls)));
255251
ret.push(OutputFile {
256252
path,
257-
hardlink,
253+
hardlink: None,
258254
flavor: FileFlavor::Linkable,
259255
});
260256
} else {

tests/testsuite/check.rs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::fmt::{self, Write};
22

33
use glob::glob;
44
use support::install::exe;
5-
use support::is_nightly;
65
use support::paths::CargoPathExt;
76
use support::registry::Package;
87
use support::{basic_manifest, project};
@@ -573,39 +572,44 @@ fn check_artifacts() {
573572
.file("examples/ex1.rs", "fn main() {}")
574573
.file("benches/b1.rs", "")
575574
.build();
575+
576+
let assert_glob = |path: &str, count: usize| {
577+
assert_eq!(
578+
glob(&p.root().join(path).to_str().unwrap())
579+
.unwrap()
580+
.count(),
581+
count
582+
);
583+
};
584+
576585
p.cargo("check").run();
577-
assert!(p.root().join("target/debug/libfoo.rmeta").is_file());
586+
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
578587
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
579588
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
589+
assert_glob("target/debug/deps/libfoo-*.rmeta", 2);
580590

581591
p.root().join("target").rm_rf();
582592
p.cargo("check --lib").run();
583-
assert!(p.root().join("target/debug/libfoo.rmeta").is_file());
593+
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
584594
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
585595
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
596+
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
586597

587598
p.root().join("target").rm_rf();
588599
p.cargo("check --bin foo").run();
589-
if is_nightly() {
590-
// The nightly check can be removed once 1.27 is stable.
591-
// Bins now generate `rmeta` files.
592-
// See: https://github.com/rust-lang/rust/pull/49289
593-
assert!(p.root().join("target/debug/libfoo.rmeta").is_file());
594-
}
600+
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
595601
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
596602
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
603+
assert_glob("target/debug/deps/libfoo-*.rmeta", 2);
597604

598605
p.root().join("target").rm_rf();
599606
p.cargo("check --test t1").run();
600607
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
601608
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
602609
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
603-
assert_eq!(
604-
glob(&p.root().join("target/debug/t1-*").to_str().unwrap())
605-
.unwrap()
606-
.count(),
607-
0
608-
);
610+
assert_glob("target/debug/t1-*", 0);
611+
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
612+
assert_glob("target/debug/deps/libt1-*.rmeta", 1);
609613

610614
p.root().join("target").rm_rf();
611615
p.cargo("check --example ex1").run();
@@ -617,18 +621,17 @@ fn check_artifacts() {
617621
.join(exe("ex1"))
618622
.is_file()
619623
);
624+
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
625+
assert_glob("target/debug/examples/libex1-*.rmeta", 1);
620626

621627
p.root().join("target").rm_rf();
622628
p.cargo("check --bench b1").run();
623629
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
624630
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
625631
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
626-
assert_eq!(
627-
glob(&p.root().join("target/debug/b1-*").to_str().unwrap())
628-
.unwrap()
629-
.count(),
630-
0
631-
);
632+
assert_glob("target/debug/b1-*", 0);
633+
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
634+
assert_glob("target/debug/deps/libb1-*.rmeta", 1);
632635
}
633636

634637
#[test]

0 commit comments

Comments
 (0)