Auto merge of #2586 - RalfJung:ffi, r=RalfJung
remove FFI support for macOS We're only testing this on Linux, and `@thomcc` reports that libffi on macOS is a pain, so let's just disable this for now.
This commit is contained in:
commit
ce4620bd43
@ -31,8 +31,10 @@ smallvec = "1.7"
|
||||
rustc-workspace-hack = "1.0.0"
|
||||
measureme = "10.0.0"
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
libffi = "3.0.0"
|
||||
libloading = "0.7"
|
||||
|
||||
|
@ -421,8 +421,10 @@ pub struct MiriMachine<'mir, 'tcx> {
|
||||
pub(crate) basic_block_count: u64,
|
||||
|
||||
/// Handle of the optional shared object file for external functions.
|
||||
#[cfg(unix)]
|
||||
#[cfg(target_os = "linux")]
|
||||
pub external_so_lib: Option<(libloading::Library, std::path::PathBuf)>,
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub external_so_lib: Option<!>,
|
||||
|
||||
/// Run a garbage collector for SbTags every N basic blocks.
|
||||
pub(crate) gc_interval: u32,
|
||||
@ -485,7 +487,7 @@ pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>)
|
||||
report_progress: config.report_progress,
|
||||
basic_block_count: 0,
|
||||
clock: Clock::new(config.isolated_op == IsolatedOp::Allow),
|
||||
#[cfg(unix)]
|
||||
#[cfg(target_os = "linux")]
|
||||
external_so_lib: config.external_so_file.as_ref().map(|lib_file_path| {
|
||||
let target_triple = layout_cx.tcx.sess.opts.target_triple.triple();
|
||||
// Check if host target == the session target.
|
||||
@ -507,6 +509,10 @@ pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>)
|
||||
lib_file_path.clone(),
|
||||
)
|
||||
}),
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
external_so_lib: config.external_so_file.as_ref().map(|_| {
|
||||
panic!("loading external .so files is only supported on Linux")
|
||||
}),
|
||||
gc_interval: config.gc_interval,
|
||||
since_gc: 0,
|
||||
num_cpus: config.num_cpus,
|
||||
@ -648,7 +654,6 @@ fn visit_tags(&self, visit: &mut dyn FnMut(SbTag)) {
|
||||
preemption_rate: _,
|
||||
report_progress: _,
|
||||
basic_block_count: _,
|
||||
#[cfg(unix)]
|
||||
external_so_lib: _,
|
||||
gc_interval: _,
|
||||
since_gc: _,
|
||||
|
@ -183,9 +183,7 @@ fn get_func_ptr_explicitly_from_lib(&mut self, link_name: Symbol) -> Option<Code
|
||||
// from: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#411
|
||||
// using the `libc` crate where this interface is public.
|
||||
// No `libc::dladdr` on windows.
|
||||
#[cfg(unix)]
|
||||
let mut info = std::mem::MaybeUninit::<libc::Dl_info>::uninit();
|
||||
#[cfg(unix)]
|
||||
unsafe {
|
||||
if libc::dladdr(*func.deref() as *const _, info.as_mut_ptr()) != 0 {
|
||||
if std::ffi::CStr::from_ptr(info.assume_init().dli_fname).to_str().unwrap()
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
use super::backtrace::EvalContextExt as _;
|
||||
use crate::helpers::{convert::Truncate, target_os_is_unix};
|
||||
#[cfg(unix)]
|
||||
use crate::shims::ffi_support::EvalContextExt as _;
|
||||
use crate::*;
|
||||
|
||||
/// Returned by `emulate_foreign_item_by_name`.
|
||||
@ -372,8 +370,9 @@ fn emulate_foreign_item_by_name(
|
||||
let this = self.eval_context_mut();
|
||||
|
||||
// First deal with any external C functions in linked .so file.
|
||||
#[cfg(unix)]
|
||||
#[cfg(target_os = "linux")]
|
||||
if this.machine.external_so_lib.as_ref().is_some() {
|
||||
use crate::shims::ffi_support::EvalContextExt as _;
|
||||
// An Ok(false) here means that the function being called was not exported
|
||||
// by the specified `.so` file; we should continue and check if it corresponds to
|
||||
// a provided shim.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(clippy::integer_arithmetic)]
|
||||
|
||||
mod backtrace;
|
||||
#[cfg(unix)]
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod ffi_support;
|
||||
pub mod foreign_items;
|
||||
pub mod intrinsics;
|
||||
|
Loading…
Reference in New Issue
Block a user