Skip to content

Commit

Permalink
Auto merge of #4241 - Keruspe:rust-1.19.0, r=alexcrichton
Browse files Browse the repository at this point in the history
[beta] hash '__CARGO_DEFAULT_LIB_METADATA' in metadata for rustc

This is a backport of #4239 for beta
  • Loading branch information
bors committed Jul 1, 2017
2 parents c9bdd3e + 225aed0 commit bff2d2a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
11 changes: 9 additions & 2 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
// Note, though, that the compiler's build system at least wants
// path dependencies (eg libstd) to have hashes in filenames. To account for
// that we have an extra hack here which reads the
// `__CARGO_DEFAULT_METADATA` environment variable and creates a
// `__CARGO_DEFAULT_LIB_METADATA` environment variable and creates a
// hash in the filename if that's present.
//
// This environment variable should not be relied on! It's
// just here for rustbuild. We need a more principled method
// doing this eventually.
let __cargo_default_lib_metadata = env::var("__CARGO_DEFAULT_LIB_METADATA");
if !unit.profile.test &&
(unit.target.is_dylib() || unit.target.is_cdylib()) &&
unit.pkg.package_id().source_id().is_path() &&
!env::var("__CARGO_DEFAULT_LIB_METADATA").is_ok() {
!__cargo_default_lib_metadata.is_ok() {
return None;
}

Expand Down Expand Up @@ -491,6 +492,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
rustc.verbose_version.hash(&mut hasher);
}

// Seed the contents of __CARGO_DEFAULT_LIB_METADATA to the hasher if present.
// This should be the release channel, to get a different hash for each channel.
if let Ok(ref channel) = __cargo_default_lib_metadata {
channel.hash(&mut hasher);
}

Some(Metadata(hasher.finish()))
}

Expand Down
8 changes: 4 additions & 4 deletions tests/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ fn cargo_bench_failing_test() {
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
thread '[..]' panicked at 'assertion failed: \
`(left == right)` (left: \
`\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:14
[..]
", p.url()))
`(left == right)`[..]", p.url()))
.with_stderr_contains("[..]left: `\"hello\"`[..]")
.with_stderr_contains("[..]right: `\"nope\"`[..]")
.with_stderr_contains("[..]src[/]foo.rs:14")
.with_status(101));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ suffix = env::consts::DLL_SUFFIX,
assert_that(p.cargo("clean"), execs().with_status(0));

// If you set the env-var, then we expect metadata on libbar
assert_that(p.cargo("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "1"),
assert_that(p.cargo("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "stable"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({url}/bar)
[RUNNING] `rustc --crate-name bar bar[/]src[/]lib.rs --crate-type dylib \
Expand Down
9 changes: 5 additions & 4 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ test test_hello ... FAILED
failures:
---- test_hello stdout ----
<tab>thread 'test_hello' panicked at 'assertion failed: \
`(left == right)` (left: \
`\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:12
")
<tab>thread 'test_hello' panicked at 'assertion failed:[..]")
.with_stdout_contains("[..]`(left == right)`[..]")
.with_stdout_contains("[..]left: `\"hello\"`,[..]")
.with_stdout_contains("[..]right: `\"nope\"`[..]")
.with_stdout_contains("[..]src[/]foo.rs:12[..]")
.with_stdout_contains("\
failures:
test_hello
Expand Down

0 comments on commit bff2d2a

Please sign in to comment.