MIRI_TEST_TARGET=i686-unknown-linux-gnu ./miri test
```
+If your target doesn't support libstd, you can run miri with
+
+```
+MIRI_NO_STD=1 MIRI_TEST_TARGET=thumbv7em-none-eabihf ./miri test tests/fail/alloc/no_global_allocator.rs
+MIRI_NO_STD=1 ./miri run tests/pass/no_std.rs --target thumbv7em-none-eabihf
+```
+
+to avoid attempting (and failing) to build libstd. Note that almost no tests will pass
+this way, but you can run individual tests.
+
`./miri test FILTER` only runs those tests that contain `FILTER` in their
filename (including the base directory, e.g. `./miri test fail` will run all
compile-fail tests).
* `MIRI_TEST_TARGET` (recognized by the test suite) indicates which target
architecture to test against. `miri` and `cargo miri` accept the `--target`
flag for the same purpose.
+* `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's
+ sysroot is built without libstd. This allows testing and running no_std programs.
* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files
instead of checking whether the output matches.
* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite) don't check whether the
if !dir.exists() {
fs::create_dir_all(&dir).unwrap();
}
- // The interesting bit: Xargo.toml
- File::create(dir.join("Xargo.toml"))
- .unwrap()
- .write_all(
- br#"
+ let mut xargo_toml = File::create(dir.join("Xargo.toml")).unwrap();
+ if std::env::var_os("MIRI_NO_STD").is_none() {
+ // The interesting bit: Xargo.toml (only needs content if we actually need std)
+ xargo_toml
+ .write_all(
+ br#"
[dependencies.std]
default_features = false
# We support unwinding, so enable that panic runtime.
[dependencies.test]
"#,
- )
- .unwrap();
+ )
+ .unwrap();
+ }
// The boring bits: a dummy project for xargo.
// FIXME: With xargo-check, can we avoid doing this?
File::create(dir.join("Cargo.toml"))
"#,
)
.unwrap();
- File::create(dir.join("lib.rs")).unwrap();
+ File::create(dir.join("lib.rs")).unwrap().write_all(b"#![no_std]").unwrap();
// Determine architectures.
// We always need to set a target so rustc bootstrap can tell apart host from target crates.
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec
+ MIRI_NO_STD=1 ./miri run tests/pass/no_std.rs --target thumbv7em-none-eabihf # no_std embedded architecture minimal test
;;
x86_64-apple-darwin)
MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
--- /dev/null
+#![feature(lang_items, start)]
+#![no_std]
+// windows tls dtors go through libstd right now, thus this test
+// cannot pass. When windows tls dtors go through the special magic
+// windows linker section, we can run this test on windows again.
+// ignore-windows
+
+#[start]
+fn start(_: isize, _: *const *const u8) -> isize {
+ for _ in 0..10 {}
+
+ 0
+}
+
+#[panic_handler]
+fn panic_handler(_: &core::panic::PanicInfo) -> ! {
+ loop {}
+}
+
+#[lang = "eh_personality"]
+fn eh_personality() {}