mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 21:16:27 +03:00
cargo miri: support foreign targets
This commit is contained in:
+2
-1
@@ -36,6 +36,7 @@ required-features = ["rustc_tests"]
|
||||
byteorder = { version = "1.1", features = ["i128"]}
|
||||
cargo_metadata = { version = "0.6", optional = true }
|
||||
directories = { version = "1.0", optional = true }
|
||||
rustc_version = { version = "0.2.3", optional = true }
|
||||
env_logger = "0.5"
|
||||
log = "0.4"
|
||||
|
||||
@@ -44,7 +45,7 @@ vergen = "3"
|
||||
|
||||
[features]
|
||||
default = ["cargo_miri"]
|
||||
cargo_miri = ["cargo_metadata", "directories"]
|
||||
cargo_miri = ["cargo_metadata", "directories", "rustc_version"]
|
||||
rustc_tests = []
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
+16
-5
@@ -190,17 +190,28 @@ fn setup(ask_user: bool) {
|
||||
"#).unwrap();
|
||||
File::create(dir.join("lib.rs")).unwrap();
|
||||
// Run xargo
|
||||
if !Command::new("xargo").arg("build").arg("-q")
|
||||
let target = get_arg_flag_value("--target");
|
||||
let mut command = Command::new("xargo");
|
||||
command.arg("build").arg("-q")
|
||||
.current_dir(&dir)
|
||||
.env("RUSTFLAGS", miri::miri_default_args().join(" "))
|
||||
.env("XARGO_HOME", dir.to_str().unwrap())
|
||||
.status().unwrap().success()
|
||||
.env("XARGO_HOME", dir.to_str().unwrap());
|
||||
if let Some(ref target) = target {
|
||||
command.arg("--target").arg(&target);
|
||||
}
|
||||
if !command.status().unwrap().success()
|
||||
{
|
||||
show_error(format!("Failed to run xargo"));
|
||||
}
|
||||
|
||||
// That should be it!
|
||||
let sysroot = dir.join("HOST");
|
||||
// That should be it! But we need to figure out where xargo built stuff.
|
||||
// Unfortunately, it puts things into a different directory when the
|
||||
// architecture matches the host.
|
||||
let is_host = match target {
|
||||
None => true,
|
||||
Some(target) => target == rustc_version::version_meta().unwrap().host,
|
||||
};
|
||||
let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) };
|
||||
std::env::set_var("MIRI_SYSROOT", &sysroot);
|
||||
if !ask_user {
|
||||
println!("A libstd for miri is now available in `{}`", sysroot.display());
|
||||
|
||||
Reference in New Issue
Block a user