diff --git a/Cargo.toml b/Cargo.toml index 976bd08086..9923b94de1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,6 @@ features = ['unprefixed_malloc_on_supported_platforms'] [target.'cfg(unix)'.dependencies] libc = "0.2" - -[target.'cfg(target_os = "linux")'.dependencies] libffi = "3.2.0" libloading = "0.8" diff --git a/README.md b/README.md index 208a8b9ee6..55a0aa8ad9 100644 --- a/README.md +++ b/README.md @@ -384,7 +384,7 @@ to Miri failing to detect cases of undefined behavior in a program. file descriptors will be mixed up. This is **work in progress**; currently, only integer arguments and return values are supported (and no, pointer/integer casts to work around this limitation will not work; - they will fail horribly). It also only works on Linux hosts for now. + they will fail horribly). It also only works on Unix hosts for now. * `-Zmiri-measureme=` enables `measureme` profiling for the interpreted program. This can be used to find which parts of your program are executing slowly under Miri. The profile is written out to a file inside a directory called ``, and can be processed diff --git a/src/machine.rs b/src/machine.rs index 8854b18528..e4a9326d61 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -536,9 +536,9 @@ pub struct MiriMachine<'mir, 'tcx> { pub(crate) basic_block_count: u64, /// Handle of the optional shared object file for native functions. - #[cfg(target_os = "linux")] + #[cfg(unix)] pub native_lib: Option<(libloading::Library, std::path::PathBuf)>, - #[cfg(not(target_os = "linux"))] + #[cfg(not(unix))] pub native_lib: Option, /// Run a garbage collector for BorTags every N basic blocks. @@ -664,7 +664,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { report_progress: config.report_progress, basic_block_count: 0, clock: Clock::new(config.isolated_op == IsolatedOp::Allow), - #[cfg(target_os = "linux")] + #[cfg(unix)] native_lib: config.native_lib.as_ref().map(|lib_file_path| { let target_triple = layout_cx.tcx.sess.opts.target_triple.triple(); // Check if host target == the session target. @@ -686,9 +686,9 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { lib_file_path.clone(), ) }), - #[cfg(not(target_os = "linux"))] + #[cfg(not(unix))] native_lib: config.native_lib.as_ref().map(|_| { - panic!("loading external .so files is only supported on Linux") + panic!("loading external .so files is only supported on Unix") }), gc_interval: config.gc_interval, since_gc: 0, diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 1185d440ec..dcc51ea851 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -210,7 +210,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let this = self.eval_context_mut(); // First deal with any external C functions in linked .so file. - #[cfg(target_os = "linux")] + #[cfg(unix)] if this.machine.native_lib.as_ref().is_some() { use crate::shims::native_lib::EvalContextExt as _; // An Ok(false) here means that the function being called was not exported diff --git a/src/shims/mod.rs b/src/shims/mod.rs index aaa3c69b92..52565fb8b6 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -3,7 +3,7 @@ mod alloc; mod backtrace; pub mod foreign_items; -#[cfg(target_os = "linux")] +#[cfg(unix)] pub mod native_lib; pub mod unix; pub mod windows; diff --git a/tests/ui.rs b/tests/ui.rs index 1a7c472450..282142ce5f 100644 --- a/tests/ui.rs +++ b/tests/ui.rs @@ -291,7 +291,7 @@ fn main() -> Result<()> { WithDependencies, tmpdir.path(), )?; - if cfg!(target_os = "linux") { + if cfg!(unix) { ui(Mode::Pass, "tests/native-lib/pass", &target, WithoutDependencies, tmpdir.path())?; ui( Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },