2021-04-07 20:46:20 +08:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
#[cfg(miri)]
|
|
|
|
compile_error!("`miri` cfg should not be set in build script");
|
|
|
|
|
2019-08-28 09:15:31 +02:00
|
|
|
fn not_in_miri() -> i32 {
|
|
|
|
// Inline assembly definitely does not work in Miri.
|
2021-08-16 17:34:48 +02:00
|
|
|
let mut dummy = 42;
|
2019-08-28 09:15:31 +02:00
|
|
|
unsafe {
|
2021-12-15 18:58:28 +01:00
|
|
|
std::arch::asm!("/* {} */", in(reg) &mut dummy);
|
2019-08-28 09:15:31 +02:00
|
|
|
}
|
|
|
|
return dummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
not_in_miri();
|
2021-04-07 20:46:20 +08:00
|
|
|
// Cargo calls `miri --print=cfg` to populate the `CARGO_CFG_*` env vars.
|
|
|
|
// Make sure that the "miri" flag is set.
|
2022-06-26 12:31:53 -04:00
|
|
|
assert!(env::var_os("CARGO_CFG_MIRI").is_some(), "cargo failed to tell us about `--cfg miri`");
|
2019-08-28 09:15:31 +02:00
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
2020-09-12 13:10:23 +02:00
|
|
|
println!("cargo:rerun-if-env-changed=MIRITESTVAR");
|
|
|
|
println!("cargo:rustc-env=MIRITESTVAR=testval");
|
2019-08-28 09:15:31 +02:00
|
|
|
}
|