Skip to content

Commit 20f9bfc

Browse files
authored
Fix default cargo test experience (rust-lang#397)
Turns out Cargo doesn't automatically set `TARGET` for rustc invocations so carry it forward manually from the build script over to the rustc invocation.
1 parent 56937d2 commit 20f9bfc

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

crates/coresimd/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::env;
2+
3+
fn main() {
4+
println!(
5+
"cargo:rustc-env=TARGET={}",
6+
env::var("TARGET").unwrap()
7+
);
8+
}

crates/simd-test-macro/src/lib.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,8 @@ pub fn simd_test(
6060
name.clone().as_str()
6161
));
6262

63-
let default_target = if cfg!(target_os = "windows") {
64-
Some("x86_64-pc-windows-msvc")
65-
} else if cfg!(target_os = "linux") {
66-
Some("x86_64-unknown-linux-gnu")
67-
} else if cfg!(target_os = "macos") {
68-
Some("x86_64-apple-darwin")
69-
} else {
70-
None
71-
};
72-
73-
let target = env::var("TARGET").unwrap_or_else(|_| {
74-
default_target.expect("TARGET environment variable not set and no default target known for the current target.").to_string()
75-
});
63+
let target = env::var("TARGET")
64+
.expect("TARGET environment variable should be set for rustc");
7665
let mut force_test = false;
7766
let macro_test = match target.split('-').next().expect(&format!(
7867
"target triple contained no \"-\": {}",

0 commit comments

Comments
 (0)