2020-04-20 03:38:38 -05:00
|
|
|
#![feature(llvm_asm)]
|
2019-08-28 02:15:31 -05:00
|
|
|
|
2021-04-07 07:46:20 -05:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
#[cfg(miri)]
|
|
|
|
compile_error!("`miri` cfg should not be set in build script");
|
|
|
|
|
2019-08-28 02:15:31 -05:00
|
|
|
fn not_in_miri() -> i32 {
|
|
|
|
// Inline assembly definitely does not work in Miri.
|
|
|
|
let dummy = 42;
|
|
|
|
unsafe {
|
2020-04-20 03:38:38 -05:00
|
|
|
llvm_asm!("" : : "r"(&dummy));
|
2019-08-28 02:15:31 -05:00
|
|
|
}
|
|
|
|
return dummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
not_in_miri();
|
2021-04-07 07:46:20 -05:00
|
|
|
// Cargo calls `miri --print=cfg` to populate the `CARGO_CFG_*` env vars.
|
|
|
|
// Make sure that the "miri" flag is set.
|
|
|
|
assert!(env::var_os("CARGO_CFG_MIRI").is_some());
|
2019-08-28 02:15:31 -05:00
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
2020-09-12 06:10:23 -05:00
|
|
|
println!("cargo:rerun-if-env-changed=MIRITESTVAR");
|
|
|
|
println!("cargo:rustc-env=MIRITESTVAR=testval");
|
2019-08-28 02:15:31 -05:00
|
|
|
}
|