Skip to content

Commit e7a6466

Browse files
author
Ellen Arteca
committed
PR edits requested by @RalfJung: main changes are removing the use of hir types, some refactoring/renaming of functions, and edits to the related test file hierarchy
1 parent 41fd802 commit e7a6466

26 files changed

+383
-427
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ environment variable. We first document the most relevant and most commonly used
285285
`TERM` environment variable is excluded by default to [speed up the test
286286
harness](https://github.com/rust-lang/miri/issues/1702). This has no effect unless
287287
`-Zmiri-disable-isolation` is also set.
288+
* `-Zmiri-extern-so-file=<path to a shared object file>` is an experimental flag for providing support
289+
for FFI calls.
290+
**WARNING**: If an invalid/incorrect SO file is specified, this can cause undefined behaviour in Miri itself!
291+
This is [work in progress](https://github.com/rust-lang/miri/pull/2363);
292+
current support is for functions with integer arguments/returns.
293+
Follow [the discussion on supporting other types](https://github.com/rust-lang/miri/issues/2365).
288294
* `-Zmiri-env-forward=<var>` forwards the `var` environment variable to the interpreted program. Can
289295
be used multiple times to forward several variables. This takes precedence over
290296
`-Zmiri-env-exclude`: if a variable is both forwarded and exluced, it *will* get forwarded. This

miri

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,6 @@ test|bless)
156156
# First build and get a sysroot.
157157
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
158158
find_sysroot
159-
# if we're on linux
160-
if [[ $OSTYPE == 'linux'* ]]; then
161-
# rebuild the C test shared object file if it's not there
162-
if [ ! -f "tests/external_C/libtestlib.so" ]; then
163-
$CC -shared -o tests/external_C/libtestlib.so tests/external_C/test.c
164-
fi
165-
fi
166159
if [ "$COMMAND" = "bless" ]; then
167160
export MIRI_BLESS="Gesundheit"
168161
fi

src/bin/miri.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,18 @@ fn main() {
487487
"full" => BacktraceStyle::Full,
488488
_ => panic!("-Zmiri-backtrace may only be 0, 1, or full"),
489489
};
490-
} else if let Some(param) = arg.strip_prefix("-Zmiri-external_c_so_file=") {
490+
} else if let Some(param) = arg.strip_prefix("-Zmiri-extern-so-file=") {
491491
let filename = param.to_string();
492492
if std::path::Path::new(&filename).exists() {
493-
if let Some(other_filename) = miri_config.external_c_so_file {
493+
if let Some(other_filename) = miri_config.external_so_file {
494494
panic!(
495-
"-Zmiri-external_so_file external SO file is already set to {}",
495+
"-Zmiri-extern-so-file external SO file is already set to {}",
496496
other_filename.display()
497497
);
498498
}
499-
miri_config.external_c_so_file = Some(filename.into());
499+
miri_config.external_so_file = Some(filename.into());
500500
} else {
501-
panic!("-Zmiri-external_c_so_file path {} does not exist", filename);
501+
panic!("-Zmiri-extern-so-file path {} does not exist", filename);
502502
}
503503
} else {
504504
// Forward to rustc.

src/c_ffi_support.rs

Lines changed: 0 additions & 302 deletions
This file was deleted.

src/eval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ pub struct MiriConfig {
127127
pub report_progress: Option<u32>,
128128
/// Whether Stacked Borrows retagging should recurse into fields of datatypes.
129129
pub retag_fields: bool,
130-
/// The location of a shared object file to load when calling external C functions
130+
/// The location of a shared object file to load when calling external functions
131131
/// TODO! consider allowing users to specify paths to multiple SO files, or to a directory
132-
pub external_c_so_file: Option<PathBuf>,
132+
pub external_so_file: Option<PathBuf>,
133133
}
134134

135135
impl Default for MiriConfig {
@@ -161,7 +161,7 @@ impl Default for MiriConfig {
161161
preemption_rate: 0.01, // 1%
162162
report_progress: None,
163163
retag_fields: false,
164-
external_c_so_file: None,
164+
external_so_file: None,
165165
}
166166
}
167167
}

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern crate rustc_session;
3737
extern crate rustc_span;
3838
extern crate rustc_target;
3939

40-
mod c_ffi_support;
4140
mod concurrency;
4241
mod diagnostics;
4342
mod eval;
@@ -70,8 +69,6 @@ pub use crate::shims::time::EvalContextExt as _;
7069
pub use crate::shims::tls::{EvalContextExt as _, TlsData};
7170
pub use crate::shims::EvalContextExt as _;
7271

73-
pub use crate::c_ffi_support::EvalContextExt as CFFIEvalContextExt;
74-
7572
pub use crate::concurrency::data_race::{
7673
AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd,
7774
EvalContextExt as DataRaceEvalContextExt,

0 commit comments

Comments
 (0)