about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-04 12:33:22 +0000
committerbors <bors@rust-lang.org>2024-05-04 12:33:22 +0000
commit3a6faee1e2ff8508f8721d4e1fdfd0fe1775c16e (patch)
tree19fb14685e6e01985a84ee067148ad1c7c2488cc /src
parentfd15dc391bb157648ca472b228a31094568b8ec6 (diff)
parent05e7850d7ad28b163f858361c33d9951258a6bc1 (diff)
downloadrust-3a6faee1e2ff8508f8721d4e1fdfd0fe1775c16e.tar.gz
rust-3a6faee1e2ff8508f8721d4e1fdfd0fe1775c16e.zip
Auto merge of #3554 - RalfJung:freebsd, r=RalfJung
document unofficially supported OSes

Also tweak the freeBSD testing a bit.
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/README.md7
-rwxr-xr-xsrc/tools/miri/ci/ci.sh12
-rw-r--r--src/tools/miri/src/shims/unix/freebsd/foreign_items.rs32
-rw-r--r--src/tools/miri/tests/pass/align_offset_symbolic.rs5
-rw-r--r--src/tools/miri/tests/pass/align_offset_symbolic.stdout1
-rw-r--r--src/tools/miri/tests/pass/concurrency/threadname.rs (renamed from src/tools/miri/tests/pass/concurrency/thread_name.rs)0
-rw-r--r--src/tools/miri/tests/pass/vecdeque.rs4
-rw-r--r--src/tools/miri/tests/pass/vecdeque.stack.stdout2
-rw-r--r--src/tools/miri/tests/pass/vecdeque.tree.stdout2
-rw-r--r--src/tools/miri/tests/pass/vecdeque.tree_uniq.stdout2
10 files changed, 34 insertions, 33 deletions
diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md
index 5b088abcbe6..f92cc088e0f 100644
--- a/src/tools/miri/README.md
+++ b/src/tools/miri/README.md
@@ -224,8 +224,11 @@ degree documented below):
 - `s390x-unknown-linux-gnu` is supported as our "big-endian target of choice".
 - For every other target with OS `linux`, `macos`, or `windows`, Miri should generally work, but we
   make no promises and we don't run tests for such targets.
-- For targets on other operating systems, even basic operations such as printing to the standard
-  output might not work, and Miri might fail before even reaching the `main` function.
+- We have unofficial support (not maintained by the Miri team itself) for some further operating systems.
+  - `freebsd`: **maintainer wanted**. Supports `std::env` and parts of `std::{thread, fs}`, but not `std::sync`.
+  - `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works.
+  - `wasm`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works.
+- For targets on other operating systems, Miri might fail before even reaching the `main` function.
 
 However, even for targets that we do support, the degree of support for accessing platform APIs
 (such as the file system) differs between targets: generally, Linux targets have the best support,
diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh
index 67835960bd7..d3dee0de617 100755
--- a/src/tools/miri/ci/ci.sh
+++ b/src/tools/miri/ci/ci.sh
@@ -141,11 +141,13 @@ case $HOST_TARGET in
     MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
     MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
     # Partially supported targets (tier 2)
-    MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
-    MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
-    MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
-    MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
-    MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm
+    VERY_BASIC="integer vec string btreemap" # common things we test on all of them (if they have std), requires no target-specific shims
+    BASIC="$VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures
+    MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-getentropy libc-getrandom libc-misc fs env num_cpus
+    MIRI_TEST_TARGET=i686-unknown-freebsd   run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-getentropy libc-getrandom libc-misc fs env num_cpus
+    MIRI_TEST_TARGET=aarch64-linux-android  run_tests_minimal $VERY_BASIC hello panic/panic
+    MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal $VERY_BASIC wasm
+    MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm
     MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
     # Custom target JSON file
     MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
diff --git a/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs b/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs
index ffb583123d4..3db9b9c1db5 100644
--- a/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs
+++ b/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs
@@ -47,21 +47,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                     this.read_scalar(len)?,
                 )?;
             }
-            "getrandom" => {
-                let [ptr, len, flags] =
-                    this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
-                let ptr = this.read_pointer(ptr)?;
-                let len = this.read_target_usize(len)?;
-                let _flags = this.read_scalar(flags)?.to_i32()?;
-                // flags on freebsd does not really matter
-                // in practice, GRND_RANDOM does not particularly draw from /dev/random
-                // since it is the same as to /dev/urandom.
-                // GRND_INSECURE is only an alias of GRND_NONBLOCK, which
-                // does not affect the RNG.
-                // https://man.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&n=1
-                this.gen_random(ptr, len)?;
-                this.write_scalar(Scalar::from_target_usize(len, this), dest)?;
-            }
 
             // File related shims
             // For those, we both intercept `func` and `call@FBSD_1.0` symbols cases
@@ -90,7 +75,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 this.write_scalar(result, dest)?;
             }
 
-            // errno
+            // Miscellaneous
+            "getrandom" => {
+                let [ptr, len, flags] =
+                    this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
+                let ptr = this.read_pointer(ptr)?;
+                let len = this.read_target_usize(len)?;
+                let _flags = this.read_scalar(flags)?.to_i32()?;
+                // flags on freebsd does not really matter
+                // in practice, GRND_RANDOM does not particularly draw from /dev/random
+                // since it is the same as to /dev/urandom.
+                // GRND_INSECURE is only an alias of GRND_NONBLOCK, which
+                // does not affect the RNG.
+                // https://man.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&n=1
+                this.gen_random(ptr, len)?;
+                this.write_scalar(Scalar::from_target_usize(len, this), dest)?;
+            }
             "__error" => {
                 let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
                 let errno_place = this.last_error_place()?;
diff --git a/src/tools/miri/tests/pass/align_offset_symbolic.rs b/src/tools/miri/tests/pass/align_offset_symbolic.rs
index c32fa2c8f9b..dec3d779a78 100644
--- a/src/tools/miri/tests/pass/align_offset_symbolic.rs
+++ b/src/tools/miri/tests/pass/align_offset_symbolic.rs
@@ -62,7 +62,10 @@ fn test_from_utf8() {
     const N: usize = 10;
     let vec = vec![0x4141414141414141u64; N];
     let content = unsafe { std::slice::from_raw_parts(vec.as_ptr() as *const u8, 8 * N) };
-    println!("{:?}", std::str::from_utf8(content).unwrap());
+    assert_eq!(
+        std::str::from_utf8(content).unwrap(),
+        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
+    );
 }
 
 fn test_u64_array() {
diff --git a/src/tools/miri/tests/pass/align_offset_symbolic.stdout b/src/tools/miri/tests/pass/align_offset_symbolic.stdout
deleted file mode 100644
index 66d43994815..00000000000
--- a/src/tools/miri/tests/pass/align_offset_symbolic.stdout
+++ /dev/null
@@ -1 +0,0 @@
-"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
diff --git a/src/tools/miri/tests/pass/concurrency/thread_name.rs b/src/tools/miri/tests/pass/concurrency/threadname.rs
index 6dd5f1f5c91..6dd5f1f5c91 100644
--- a/src/tools/miri/tests/pass/concurrency/thread_name.rs
+++ b/src/tools/miri/tests/pass/concurrency/threadname.rs
diff --git a/src/tools/miri/tests/pass/vecdeque.rs b/src/tools/miri/tests/pass/vecdeque.rs
index ccecf3d30a4..77c4ca5a04e 100644
--- a/src/tools/miri/tests/pass/vecdeque.rs
+++ b/src/tools/miri/tests/pass/vecdeque.rs
@@ -31,8 +31,8 @@ fn main() {
     }
 
     // Regression test for Debug impl's
-    println!("{:?} {:?}", dst, dst.iter());
-    println!("{:?}", VecDeque::<u32>::new().iter());
+    format!("{:?} {:?}", dst, dst.iter());
+    format!("{:?}", VecDeque::<u32>::new().iter());
 
     for a in dst {
         assert_eq!(*a, 2);
diff --git a/src/tools/miri/tests/pass/vecdeque.stack.stdout b/src/tools/miri/tests/pass/vecdeque.stack.stdout
deleted file mode 100644
index 63de960ee2b..00000000000
--- a/src/tools/miri/tests/pass/vecdeque.stack.stdout
+++ /dev/null
@@ -1,2 +0,0 @@
-[2, 2] Iter([2, 2], [])
-Iter([], [])
diff --git a/src/tools/miri/tests/pass/vecdeque.tree.stdout b/src/tools/miri/tests/pass/vecdeque.tree.stdout
deleted file mode 100644
index 63de960ee2b..00000000000
--- a/src/tools/miri/tests/pass/vecdeque.tree.stdout
+++ /dev/null
@@ -1,2 +0,0 @@
-[2, 2] Iter([2, 2], [])
-Iter([], [])
diff --git a/src/tools/miri/tests/pass/vecdeque.tree_uniq.stdout b/src/tools/miri/tests/pass/vecdeque.tree_uniq.stdout
deleted file mode 100644
index 63de960ee2b..00000000000
--- a/src/tools/miri/tests/pass/vecdeque.tree_uniq.stdout
+++ /dev/null
@@ -1,2 +0,0 @@
-[2, 2] Iter([2, 2], [])
-Iter([], [])