Skip to content

Don't hardlink rmeta files. #6292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2018
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
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