From 5ec25359ff620c6f7371c55b4fa778c9127f9be8 Mon Sep 17 00:00:00 2001 From: InfRandomness Date: Fri, 1 Jul 2022 21:24:24 +0200 Subject: [PATCH 1/2] Add `environ` extern implementation to freebsd Signed-off-by: InfRandomness --- src/machine.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/machine.rs b/src/machine.rs index 86b174182c1f..1b7fc4ffb963 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -442,6 +442,14 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { Self::add_extern_static(this, name, place.ptr); } } + "freebsd" => { + // "environ" + Self::add_extern_static( + this, + "environ", + this.machine.env_vars.environ.unwrap().ptr, + ); + } "windows" => { // "_tls_used" // This is some obscure hack that is part of the Windows TLS story. It's a `u8`. From a26be7ea5f353a3db9bc7684029b57f8e2c41259 Mon Sep 17 00:00:00 2001 From: InfRandomness Date: Fri, 1 Jul 2022 21:28:45 +0200 Subject: [PATCH 2/2] Enable env test on freebsd Signed-off-by: InfRandomness --- ci.sh | 2 +- tests/fail/environ-gets-deallocated.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci.sh b/ci.sh index 5c7ab545f958..b914477d44a8 100755 --- a/ci.sh +++ b/ci.sh @@ -60,7 +60,7 @@ case $HOST_TARGET in MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests 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 current_dir data_race + MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec current_dir data_race env MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture ;; x86_64-apple-darwin) diff --git a/tests/fail/environ-gets-deallocated.rs b/tests/fail/environ-gets-deallocated.rs index 4df9be2bf24d..f50a66e2c766 100644 --- a/tests/fail/environ-gets-deallocated.rs +++ b/tests/fail/environ-gets-deallocated.rs @@ -1,6 +1,6 @@ // ignore-windows: Windows does not have a global environ list that the program can access directly -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "freebsd"))] fn get_environ() -> *const *const u8 { extern "C" { static mut environ: *const *const u8;