about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-05 20:11:17 +0000
committerbors <bors@rust-lang.org>2024-05-05 20:11:17 +0000
commite43458cf0619bdaeba0e855af1bd4853444ddca4 (patch)
treee6a808f9d6dbb88272119ac517d13e9c03abbeb8 /src
parenta418b2dc70be5ce6e94eb53ed518abbafa4f13c3 (diff)
parentfb8419838715494e950599e55ffa4dbcf0c88f79 (diff)
downloadrust-e43458cf0619bdaeba0e855af1bd4853444ddca4.tar.gz
rust-e43458cf0619bdaeba0e855af1bd4853444ddca4.zip
Auto merge of #3570 - devnexen:solaris_build_fix, r=RalfJung
Solaris: make pre-main code work

Fixes https://github.com/rust-lang/miri/issues/3566
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/README.md2
-rwxr-xr-xsrc/tools/miri/ci/ci.sh3
-rw-r--r--src/tools/miri/src/shims/unix/mem.rs7
-rw-r--r--src/tools/miri/src/shims/unix/solarish/foreign_items.rs19
-rw-r--r--src/tools/miri/tests/pass-dep/shims/libc-misc.rs4
5 files changed, 27 insertions, 8 deletions
diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md
index 5b3e2a588b4..d086987f437 100644
--- a/src/tools/miri/README.md
+++ b/src/tools/miri/README.md
@@ -227,7 +227,7 @@ degree documented below):
 - 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.
-  - `illumos`: maintained by @devnexen. Support very incomplete, but a basic "hello world" works.
+  - `solaris` / `illumos`: maintained by @devnexen. 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.
 
diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh
index 713c97830a5..d1dcacdfdf5 100755
--- a/src/tools/miri/ci/ci.sh
+++ b/src/tools/miri/ci/ci.sh
@@ -146,8 +146,7 @@ case $HOST_TARGET in
     MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-misc libc-random libc-time fs env num_cpus
     MIRI_TEST_TARGET=i686-unknown-freebsd   run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-misc libc-random libc-time fs env num_cpus
     MIRI_TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-misc libc-random
-    # TODO fix solaris stack guard
-    # MIRI_TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic pthread-sync
+    MIRI_TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-misc libc-random
     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
diff --git a/src/tools/miri/src/shims/unix/mem.rs b/src/tools/miri/src/shims/unix/mem.rs
index f52dc23656d..0254735ac13 100644
--- a/src/tools/miri/src/shims/unix/mem.rs
+++ b/src/tools/miri/src/shims/unix/mem.rs
@@ -42,9 +42,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
         let map_shared = this.eval_libc_i32("MAP_SHARED");
         let map_fixed = this.eval_libc_i32("MAP_FIXED");
 
-        // This is a horrible hack, but on MacOS the guard page mechanism uses mmap
+        // This is a horrible hack, but on MacOS and Solaris the guard page mechanism uses mmap
         // in a way we do not support. We just give it the return value it expects.
-        if this.frame_in_std() && this.tcx.sess.target.os == "macos" && (flags & map_fixed) != 0 {
+        if this.frame_in_std()
+            && matches!(&*this.tcx.sess.target.os, "macos" | "solaris")
+            && (flags & map_fixed) != 0
+        {
             return Ok(Scalar::from_maybe_pointer(Pointer::from_addr_invalid(addr), this));
         }
 
diff --git a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
index c01ae0ecb90..c216d8afd77 100644
--- a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
+++ b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
@@ -2,7 +2,6 @@ use rustc_span::Symbol;
 use rustc_target::spec::abi::Abi;
 
 use crate::*;
-use shims::EmulateItemResult;
 
 pub fn is_dyn_sym(_name: &str) -> bool {
     false
@@ -26,6 +25,24 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
                 this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
             }
 
+            "stack_getbounds" => {
+                let [stack] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
+                let stack = this.deref_pointer_as(stack, this.libc_ty_layout("stack_t"))?;
+
+                this.write_int_fields_named(
+                    &[
+                        ("ss_sp", this.machine.stack_addr.into()),
+                        ("ss_size", this.machine.stack_size.into()),
+                        // field set to 0 means not in an alternate signal stack
+                        // https://docs.oracle.com/cd/E86824_01/html/E54766/stack-getbounds-3c.html
+                        ("ss_flags", 0),
+                    ],
+                    &stack,
+                )?;
+
+                this.write_null(dest)?;
+            }
+
             _ => return Ok(EmulateItemResult::NotSupported),
         }
         Ok(EmulateItemResult::NeedsJumping)
diff --git a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs
index 9644920c499..32898d49593 100644
--- a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs
+++ b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs
@@ -136,7 +136,7 @@ fn test_dlsym() {
     assert_eq!(errno, libc::EBADF);
 }
 
-#[cfg(not(any(target_os = "macos", target_os = "illumos")))]
+#[cfg(not(any(target_os = "macos", target_os = "illumos", target_os = "solaris")))]
 fn test_reallocarray() {
     unsafe {
         let mut p = libc::reallocarray(std::ptr::null_mut(), 4096, 2);
@@ -234,7 +234,7 @@ fn main() {
     test_strcpy();
 
     test_memalign();
-    #[cfg(not(any(target_os = "macos", target_os = "illumos")))]
+    #[cfg(not(any(target_os = "macos", target_os = "illumos", target_os = "solaris")))]
     test_reallocarray();
 
     #[cfg(target_os = "linux")]