Skip to content

Commit

Permalink
Add -Z binary-dep-depinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jul 26, 2019
1 parent 51a8206 commit c6e626b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ fn rustc<'a, 'cfg>(
let dep_info_loc = fingerprint::dep_info_loc(cx, unit);

rustc.args(cx.bcx.rustflags_args(unit));
if cx.bcx.config.cli_unstable().binary_dep_depinfo {
rustc.arg("-Zbinary-dep-depinfo");
}
let mut output_options = OutputOptions::new(cx, unit);
let package_id = unit.pkg.package_id();
let target = unit.target.clone();
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ pub struct CliUnstable {
pub mtime_on_use: bool,
pub install_upgrade: bool,
pub cache_messages: bool,
pub binary_dep_depinfo: bool,
}

impl CliUnstable {
Expand Down Expand Up @@ -378,6 +379,7 @@ impl CliUnstable {
"mtime-on-use" => self.mtime_on_use = true,
"install-upgrade" => self.install_upgrade = true,
"cache-messages" => self.cache_messages = true,
"binary-dep-depinfo" => self.binary_dep_depinfo = true,
_ => failure::bail!("unknown `-Z` flag specified: {}", k),
}

Expand Down
45 changes: 30 additions & 15 deletions tests/testsuite/dep_info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::support::paths::{self, CargoPathExt};
use crate::support::registry::Package;
use crate::support::{basic_bin_manifest, basic_manifest, main_file, project, rustc_host, Project};
use crate::support::{
basic_bin_manifest, basic_manifest, is_nightly, main_file, project, rustc_host, Project,
};
use filetime::FileTime;
use std::fs;
use std::path::Path;
Expand Down Expand Up @@ -166,10 +168,12 @@ fn no_rewrite_if_no_change() {
}

#[cargo_test]
// Remove once https://github.com/rust-lang/rust/pull/61727 lands, and switch
// to a `nightly` check.
#[ignore]
fn relative_depinfo_paths_ws() {
if !is_nightly() {
// See https://github.com/rust-lang/rust/issues/63012
return;
}

// Test relative dep-info paths in a workspace with --target with
// proc-macros and other dependency kinds.
Package::new("regdep", "0.1.0")
Expand Down Expand Up @@ -257,8 +261,9 @@ fn relative_depinfo_paths_ws() {
.build();

let host = rustc_host();
p.cargo("build --target")
p.cargo("build -Z binary-dep-depinfo --target")
.arg(&host)
.masquerade_as_nightly_cargo()
.with_stderr_contains("[COMPILING] foo [..]")
.run();

Expand Down Expand Up @@ -293,17 +298,20 @@ fn relative_depinfo_paths_ws() {
);

// Make sure it stays fresh.
p.cargo("build --target")
p.cargo("build -Z binary-dep-depinfo --target")
.arg(&host)
.masquerade_as_nightly_cargo()
.with_stderr("[FINISHED] dev [..]")
.run();
}

#[cargo_test]
// Remove once https://github.com/rust-lang/rust/pull/61727 lands, and switch
// to a `nightly` check.
#[ignore]
fn relative_depinfo_paths_no_ws() {
if !is_nightly() {
// See https://github.com/rust-lang/rust/issues/63012
return;
}

// Test relative dep-info paths without a workspace with proc-macros and
// other dependency kinds.
Package::new("regdep", "0.1.0")
Expand Down Expand Up @@ -382,7 +390,8 @@ fn relative_depinfo_paths_no_ws() {
.file("bar/src/lib.rs", "pub fn f() {}")
.build();

p.cargo("build")
p.cargo("build -Z binary-dep-depinfo")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[COMPILING] foo [..]")
.run();

Expand Down Expand Up @@ -417,7 +426,10 @@ fn relative_depinfo_paths_no_ws() {
);

// Make sure it stays fresh.
p.cargo("build").with_stderr("[FINISHED] dev [..]").run();
p.cargo("build -Z binary-dep-depinfo")
.masquerade_as_nightly_cargo()
.with_stderr("[FINISHED] dev [..]")
.run();
}

#[cargo_test]
Expand Down Expand Up @@ -461,10 +473,11 @@ fn reg_dep_source_not_tracked() {
}

#[cargo_test]
// Remove once https://github.com/rust-lang/rust/pull/61727 lands, and switch
// to a `nightly` check.
#[ignore]
fn canonical_path() {
if !is_nightly() {
// See https://github.com/rust-lang/rust/issues/63012
return;
}
if !crate::support::symlink_supported() {
return;
}
Expand All @@ -491,7 +504,9 @@ fn canonical_path() {
real.mkdir_p();
p.symlink(real, "target");

p.cargo("build").run();
p.cargo("build -Z binary-dep-depinfo")
.masquerade_as_nightly_cargo()
.run();

assert_deps_contains(
&p,
Expand Down

0 comments on commit c6e626b

Please sign in to comment.