Skip to content

Commit

Permalink
Don't hardlink rmeta files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Nov 9, 2018
1 parent 1ffd248 commit 61f9588
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
10 changes: 3 additions & 7 deletions src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
let mut unsupported = Vec::new();
{
if unit.mode.is_check() {
// This is not quite correct for non-lib targets. rustc
// currently does not emit rmeta files, so there is nothing to
// check for! See #3624.
// This may be confusing. rustc outputs a file named `lib*.rmeta`
// for both libraries and binaries.
let path = out_dir.join(format!("lib{}.rmeta", file_stem));
let hardlink = link_stem
.clone()
.map(|(ld, ls)| ld.join(format!("lib{}.rmeta", ls)));
ret.push(OutputFile {
path,
hardlink,
hardlink: None,
flavor: FileFlavor::Linkable,
});
} else {
Expand Down
45 changes: 24 additions & 21 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fmt::{self, Write};

use glob::glob;
use support::install::exe;
use support::is_nightly;
use support::paths::CargoPathExt;
use support::registry::Package;
use support::{basic_manifest, project};
Expand Down Expand Up @@ -573,39 +572,44 @@ fn check_artifacts() {
.file("examples/ex1.rs", "fn main() {}")
.file("benches/b1.rs", "")
.build();

let assert_glob = |path: &str, count: usize| {
assert_eq!(
glob(&p.root().join(path).to_str().unwrap())
.unwrap()
.count(),
count
);
};

p.cargo("check").run();
assert!(p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
assert_glob("target/debug/deps/libfoo-*.rmeta", 2);

p.root().join("target").rm_rf();
p.cargo("check --lib").run();
assert!(p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);

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

p.root().join("target").rm_rf();
p.cargo("check --test t1").run();
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
assert_eq!(
glob(&p.root().join("target/debug/t1-*").to_str().unwrap())
.unwrap()
.count(),
0
);
assert_glob("target/debug/t1-*", 0);
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
assert_glob("target/debug/deps/libt1-*.rmeta", 1);

p.root().join("target").rm_rf();
p.cargo("check --example ex1").run();
Expand All @@ -617,18 +621,17 @@ fn check_artifacts() {
.join(exe("ex1"))
.is_file()
);
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
assert_glob("target/debug/examples/libex1-*.rmeta", 1);

p.root().join("target").rm_rf();
p.cargo("check --bench b1").run();
assert!(!p.root().join("target/debug/libfoo.rmeta").is_file());
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
assert!(!p.root().join("target/debug").join(exe("foo")).is_file());
assert_eq!(
glob(&p.root().join("target/debug/b1-*").to_str().unwrap())
.unwrap()
.count(),
0
);
assert_glob("target/debug/b1-*", 0);
assert_glob("target/debug/deps/libfoo-*.rmeta", 1);
assert_glob("target/debug/deps/libb1-*.rmeta", 1);
}

#[test]
Expand Down

0 comments on commit 61f9588

Please sign in to comment.