Skip to content

Commit 25a3b66

Browse files
committed
rename 'extern-so' to 'native-lib'
1 parent d3f4d06 commit 25a3b66

16 files changed

+283
-333
lines changed

Diff for: src/tools/miri/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ tex/*/out
99
perf.data
1010
perf.data.old
1111
flamegraph.svg
12-
tests/extern-so/libtestlib.so
12+
tests/native-lib/libtestlib.so
1313
.auto-*

Diff for: src/tools/miri/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,17 @@ to Miri failing to detect cases of undefined behavior in a program.
374374
this flag is **unsound**.
375375
* `-Zmiri-disable-weak-memory-emulation` disables the emulation of some C++11 weak
376376
memory effects.
377-
* `-Zmiri-extern-so-file=<path to a shared object file>` is an experimental flag for providing support
378-
for FFI calls. Functions not provided by that file are still executed via the usual Miri shims.
379-
**WARNING**: If an invalid/incorrect `.so` file is specified, this can cause undefined behaviour in Miri itself!
380-
And of course, Miri cannot do any checks on the actions taken by the external code.
377+
* `-Zmiri-native-lib=<path to a shared object file>` is an experimental flag for providing support
378+
for calling native functions from inside the interpreter via FFI. Functions not provided by that
379+
file are still executed via the usual Miri shims.
380+
**WARNING**: If an invalid/incorrect `.so` file is specified, this can cause Undefined Behavior in Miri itself!
381+
And of course, Miri cannot do any checks on the actions taken by the native code.
381382
Note that Miri has its own handling of file descriptors, so if you want to replace *some* functions
382383
working on file descriptors, you will have to replace *all* of them, or the two kinds of
383384
file descriptors will be mixed up.
384385
This is **work in progress**; currently, only integer arguments and return values are
385386
supported (and no, pointer/integer casts to work around this limitation will not work;
386-
they will fail horribly). It also only works on unix hosts for now.
387-
Follow [the discussion on supporting other types](https://github.com/rust-lang/miri/issues/2365).
387+
they will fail horribly). It also only works on Linux hosts for now.
388388
* `-Zmiri-measureme=<name>` enables `measureme` profiling for the interpreted program.
389389
This can be used to find which parts of your program are executing slowly under Miri.
390390
The profile is written out to a file inside a directory called `<name>`, and can be processed

Diff for: src/tools/miri/src/bin/miri.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -575,18 +575,15 @@ fn main() {
575575
"full" => BacktraceStyle::Full,
576576
_ => show_error!("-Zmiri-backtrace may only be 0, 1, or full"),
577577
};
578-
} else if let Some(param) = arg.strip_prefix("-Zmiri-extern-so-file=") {
578+
} else if let Some(param) = arg.strip_prefix("-Zmiri-native-lib=") {
579579
let filename = param.to_string();
580580
if std::path::Path::new(&filename).exists() {
581-
if let Some(other_filename) = miri_config.external_so_file {
582-
show_error!(
583-
"-Zmiri-extern-so-file is already set to {}",
584-
other_filename.display()
585-
);
581+
if let Some(other_filename) = miri_config.native_lib {
582+
show_error!("-Zmiri-native-lib is already set to {}", other_filename.display());
586583
}
587-
miri_config.external_so_file = Some(filename.into());
584+
miri_config.native_lib = Some(filename.into());
588585
} else {
589-
show_error!("-Zmiri-extern-so-file `{}` does not exist", filename);
586+
show_error!("-Zmiri-native-lib `{}` does not exist", filename);
590587
}
591588
} else if let Some(param) = arg.strip_prefix("-Zmiri-num-cpus=") {
592589
let num_cpus = param

Diff for: src/tools/miri/src/eval.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub struct MiriConfig {
142142
/// Whether Stacked Borrows and Tree Borrows retagging should recurse into fields of datatypes.
143143
pub retag_fields: RetagFields,
144144
/// The location of a shared object file to load when calling external functions
145-
/// FIXME! consider allowing users to specify paths to multiple SO files, or to a directory
146-
pub external_so_file: Option<PathBuf>,
145+
/// FIXME! consider allowing users to specify paths to multiple files, or to a directory
146+
pub native_lib: Option<PathBuf>,
147147
/// Run a garbage collector for BorTags every N basic blocks.
148148
pub gc_interval: u32,
149149
/// The number of CPUs to be reported by miri.
@@ -188,7 +188,7 @@ impl Default for MiriConfig {
188188
preemption_rate: 0.01, // 1%
189189
report_progress: None,
190190
retag_fields: RetagFields::Yes,
191-
external_so_file: None,
191+
native_lib: None,
192192
gc_interval: 10_000,
193193
num_cpus: 1,
194194
page_size: None,

Diff for: src/tools/miri/src/machine.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ pub struct MiriMachine<'mir, 'tcx> {
535535
// The total number of blocks that have been executed.
536536
pub(crate) basic_block_count: u64,
537537

538-
/// Handle of the optional shared object file for external functions.
538+
/// Handle of the optional shared object file for native functions.
539539
#[cfg(target_os = "linux")]
540-
pub external_so_lib: Option<(libloading::Library, std::path::PathBuf)>,
540+
pub native_lib: Option<(libloading::Library, std::path::PathBuf)>,
541541
#[cfg(not(target_os = "linux"))]
542-
pub external_so_lib: Option<!>,
542+
pub native_lib: Option<!>,
543543

544544
/// Run a garbage collector for BorTags every N basic blocks.
545545
pub(crate) gc_interval: u32,
@@ -665,7 +665,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
665665
basic_block_count: 0,
666666
clock: Clock::new(config.isolated_op == IsolatedOp::Allow),
667667
#[cfg(target_os = "linux")]
668-
external_so_lib: config.external_so_file.as_ref().map(|lib_file_path| {
668+
native_lib: config.native_lib.as_ref().map(|lib_file_path| {
669669
let target_triple = layout_cx.tcx.sess.opts.target_triple.triple();
670670
// Check if host target == the session target.
671671
if env!("TARGET") != target_triple {
@@ -687,7 +687,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
687687
)
688688
}),
689689
#[cfg(not(target_os = "linux"))]
690-
external_so_lib: config.external_so_file.as_ref().map(|_| {
690+
native_lib: config.native_lib.as_ref().map(|_| {
691691
panic!("loading external .so files is only supported on Linux")
692692
}),
693693
gc_interval: config.gc_interval,
@@ -802,7 +802,7 @@ impl VisitProvenance for MiriMachine<'_, '_> {
802802
preemption_rate: _,
803803
report_progress: _,
804804
basic_block_count: _,
805-
external_so_lib: _,
805+
native_lib: _,
806806
gc_interval: _,
807807
since_gc: _,
808808
num_cpus: _,

0 commit comments

Comments
 (0)