mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Fix build-std collisions.
This commit is contained in:
parent
972b9f55a7
commit
ebba7a3739
@ -587,5 +587,15 @@ fn compute_metadata<'a, 'cfg>(
|
|||||||
if let Ok(ref channel) = __cargo_default_lib_metadata {
|
if let Ok(ref channel) = __cargo_default_lib_metadata {
|
||||||
channel.hash(&mut hasher);
|
channel.hash(&mut hasher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std units need to be kept separate from user dependencies. std crates
|
||||||
|
// are differentiated in the Unit with `is_std` (for things like
|
||||||
|
// `-Zforce-unstable-if-unmarked`), so they are always built separately.
|
||||||
|
// This isn't strictly necessary for build dependencies which probably
|
||||||
|
// don't need unstable support. A future experiment might be to set
|
||||||
|
// `is_std` to false for build dependencies so that they can be shared
|
||||||
|
// with user dependencies.
|
||||||
|
unit.is_std.hash(&mut hasher);
|
||||||
|
|
||||||
Some(Metadata(hasher.finish()))
|
Some(Metadata(hasher.finish()))
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
//! -C incremental=… flag | ✓ |
|
//! -C incremental=… flag | ✓ |
|
||||||
//! mtime of sources | ✓[^3] |
|
//! mtime of sources | ✓[^3] |
|
||||||
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ |
|
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ |
|
||||||
|
//! is_std | | ✓
|
||||||
//!
|
//!
|
||||||
//! [^1]: Build script and bin dependencies are not included.
|
//! [^1]: Build script and bin dependencies are not included.
|
||||||
//!
|
//!
|
||||||
|
@ -211,3 +211,59 @@ fn custom_test_framework() {
|
|||||||
.build_std_arg("core")
|
.build_std_arg("core")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test(build_std)]
|
||||||
|
fn common_crate_collision() {
|
||||||
|
// Check for collision with `cc` crate in build dependencies.
|
||||||
|
// This needs to be a full test since we need to use the real `cc` crate.
|
||||||
|
// This is a bit fragile, since it assumes `cc` is used in libstd,
|
||||||
|
// and that we are selecting the same features.
|
||||||
|
|
||||||
|
// Determine the version of CC used in the real std so that we use the
|
||||||
|
// exact same version.
|
||||||
|
let sysroot = paths::sysroot();
|
||||||
|
let sysroot = Path::new(&sysroot);
|
||||||
|
let contents =
|
||||||
|
std::fs::read_to_string(sysroot.join("lib/rustlib/src/rust/Cargo.lock")).unwrap();
|
||||||
|
let lock: toml::Value = toml::from_str(&contents).unwrap();
|
||||||
|
let mut packages = lock["package"].as_array().unwrap().iter();
|
||||||
|
let cc = packages
|
||||||
|
.find(|p| p["name"].as_str().unwrap() == "cc")
|
||||||
|
.unwrap();
|
||||||
|
// Make sure there is only one `cc`.
|
||||||
|
assert!(packages
|
||||||
|
.find(|p| p["name"].as_str().unwrap() == "cc")
|
||||||
|
.is_none());
|
||||||
|
let cc_version = cc["version"].as_str().unwrap();
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
&format!(
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
cc = "={}"
|
||||||
|
"#,
|
||||||
|
cc_version
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.file("build.rs", "extern crate cc; fn main() {}")
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build -v")
|
||||||
|
.build_std()
|
||||||
|
.target_host()
|
||||||
|
.with_stderr_contains(
|
||||||
|
"[RUNNING] `rustc --crate-name cc [..]-Zforce-unstable-if-unmarked[..]",
|
||||||
|
)
|
||||||
|
.with_stderr_line_without(
|
||||||
|
&["[RUNNING] `rustc --crate-name cc"],
|
||||||
|
&["-Zforce-unstable-if-unmarked"],
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user