]> git.lizzy.rs Git - rust.git/blob - test-cargo-miri/build.rs
Don't `unwrap()` in `in_std()`
[rust.git] / test-cargo-miri / build.rs
1 #![feature(llvm_asm)]
2
3 use std::env;
4
5 #[cfg(miri)]
6 compile_error!("`miri` cfg should not be set in build script");
7
8 fn not_in_miri() -> i32 {
9     // Inline assembly definitely does not work in Miri.
10     let dummy = 42;
11     unsafe {
12         llvm_asm!("" : : "r"(&dummy));
13     }
14     return dummy;
15 }
16
17 fn main() {
18     not_in_miri();
19     // Cargo calls `miri --print=cfg` to populate the `CARGO_CFG_*` env vars.
20     // Make sure that the "miri" flag is set.
21     assert!(env::var_os("CARGO_CFG_MIRI").is_some());
22     println!("cargo:rerun-if-changed=build.rs");
23     println!("cargo:rerun-if-env-changed=MIRITESTVAR");
24     println!("cargo:rustc-env=MIRITESTVAR=testval");
25 }