cargo miri: support foreign targets

This commit is contained in:
Ralf Jung
2018-12-10 09:32:54 +01:00
parent c84c1527e2
commit b6eb2cd08e
2 changed files with 18 additions and 6 deletions
+2 -1
View File
@@ -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
View File
@@ -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());