about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-21 12:49:24 +0000
committerbors <bors@rust-lang.org>2022-09-21 12:49:24 +0000
commit351afbbe1c1998b051c1ba52d76f24d51a50eb46 (patch)
tree0a34204ec6bd3f47c29708a6a4295c29704b9a49
parenteb84c8b6211c540bb88f4a5f279988725021f486 (diff)
parent4f357956b868cd5d6c1a9ff0608dfcd7d5bbe2a3 (diff)
downloadrust-351afbbe1c1998b051c1ba52d76f24d51a50eb46.tar.gz
rust-351afbbe1c1998b051c1ba52d76f24d51a50eb46.zip
Auto merge of #2555 - oli-obk:libffi-is-unhappy, r=RalfJung
Only support libffi on unix for now
-rw-r--r--Cargo.toml6
-rw-r--r--README.md2
-rw-r--r--src/bin/miri.rs1
-rw-r--r--src/concurrency/sync.rs2
-rw-r--r--src/machine.rs4
-rw-r--r--src/shims/foreign_items.rs2
-rw-r--r--src/shims/mod.rs1
-rw-r--r--src/shims/unix/fs.rs2
8 files changed, 11 insertions, 9 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 0a3dfc2a84e..0c547d585d1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,8 +20,6 @@ doctest = false # and no doc tests
 [dependencies]
 getrandom = { version = "0.2", features = ["std"] }
 env_logger = "0.9"
-libffi = "3.0.0"
-libloading = "0.7"
 log = "0.4"
 shell-escape = "0.1.4"
 rand = "0.8"
@@ -33,10 +31,10 @@ smallvec = "1.7"
 rustc-workspace-hack = "1.0.0"
 measureme = "10.0.0"
 
-# Enable some feature flags that dev-dependencies need but dependencies
-# do not.  This makes `./miri install` after `./miri build` faster.
 [target."cfg(unix)".dependencies]
 libc = "0.2"
+libffi = "3.0.0"
+libloading = "0.7"
 
 [dev-dependencies]
 colored = "2"
diff --git a/README.md b/README.md
index 72081f45499..1f4c52d5b85 100644
--- a/README.md
+++ b/README.md
@@ -360,7 +360,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).
+  they will fail horribly). It also only works on unix hosts for now.
   Follow [the discussion on supporting other types](https://github.com/rust-lang/miri/issues/2365). 
 * `-Zmiri-measureme=<name>` enables `measureme` profiling for the interpreted program.
    This can be used to find which parts of your program are executing slowly under Miri.
diff --git a/src/bin/miri.rs b/src/bin/miri.rs
index 644a8129eee..7d32ee42573 100644
--- a/src/bin/miri.rs
+++ b/src/bin/miri.rs
@@ -7,7 +7,6 @@
 
 extern crate rustc_data_structures;
 extern crate rustc_driver;
-extern crate rustc_errors;
 extern crate rustc_hir;
 extern crate rustc_interface;
 extern crate rustc_metadata;
diff --git a/src/concurrency/sync.rs b/src/concurrency/sync.rs
index d301ced8511..464f452ca76 100644
--- a/src/concurrency/sync.rs
+++ b/src/concurrency/sync.rs
@@ -44,7 +44,7 @@ macro_rules! declare_id {
         }
 
         impl $name {
-            pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Provenance> {
+            pub fn to_u32_scalar(&self) -> Scalar<Provenance> {
                 Scalar::from_u32(self.0.get())
             }
         }
diff --git a/src/machine.rs b/src/machine.rs
index 8db546463c2..f11771911fa 100644
--- a/src/machine.rs
+++ b/src/machine.rs
@@ -400,6 +400,7 @@ pub struct MiriMachine<'mir, 'tcx> {
     pub(crate) basic_block_count: u64,
 
     /// Handle of the optional shared object file for external functions.
+    #[cfg(unix)]
     pub external_so_lib: Option<(libloading::Library, std::path::PathBuf)>,
 
     /// Run a garbage collector for SbTags every N basic blocks.
@@ -410,7 +411,6 @@ pub struct MiriMachine<'mir, 'tcx> {
 
 impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
     pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Self {
-        let target_triple = &layout_cx.tcx.sess.opts.target_triple.to_string();
         let local_crates = helpers::get_local_crates(layout_cx.tcx);
         let layouts =
             PrimitiveLayouts::new(layout_cx).expect("Couldn't get layouts of primitive types");
@@ -462,7 +462,9 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
             report_progress: config.report_progress,
             basic_block_count: 0,
             clock: Clock::new(config.isolated_op == IsolatedOp::Allow),
+            #[cfg(unix)]
             external_so_lib: config.external_so_file.as_ref().map(|lib_file_path| {
+                let target_triple = &layout_cx.tcx.sess.opts.target_triple.to_string();
                 // Check if host target == the session target.
                 if env!("TARGET") != target_triple {
                     panic!(
diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs
index 6d052083d37..bb62a2a7ec1 100644
--- a/src/shims/foreign_items.rs
+++ b/src/shims/foreign_items.rs
@@ -23,6 +23,7 @@ use rustc_target::{
 
 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::*;
 
@@ -371,6 +372,7 @@ pub trait EvalContextExt<'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(unix)]
         if this.machine.external_so_lib.as_ref().is_some() {
             // 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
diff --git a/src/shims/mod.rs b/src/shims/mod.rs
index 93083b486bf..8cb648e5173 100644
--- a/src/shims/mod.rs
+++ b/src/shims/mod.rs
@@ -1,6 +1,7 @@
 #![warn(clippy::integer_arithmetic)]
 
 mod backtrace;
+#[cfg(unix)]
 pub mod ffi_support;
 pub mod foreign_items;
 pub mod intrinsics;
diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs
index edeb2001f93..8464c4589ed 100644
--- a/src/shims/unix/fs.rs
+++ b/src/shims/unix/fs.rs
@@ -246,7 +246,7 @@ impl FileDescriptor for DummyOutput {
         Ok(Ok(bytes.len()))
     }
 
-    fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
+    fn dup(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
         Ok(Box::new(DummyOutput))
     }
 }