Skip to content

Commit 44a8f9c

Browse files
author
Ellen Arteca
committed
ralfs comments
1 parent 6134df8 commit 44a8f9c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/machine.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ pub struct Evaluator<'mir, 'tcx> {
363363

364364
impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
365365
pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Self {
366+
let target_triple = &layout_cx.tcx.sess.opts.target_triple.to_string();
366367
let local_crates = helpers::get_local_crates(layout_cx.tcx);
367368
let layouts =
368369
PrimitiveLayouts::new(layout_cx).expect("Couldn't get layouts of primitive types");
@@ -414,6 +415,12 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
414415
report_progress: config.report_progress,
415416
since_progress_report: 0,
416417
external_so_lib: config.external_so_file.as_ref().map(|lib_file_path| {
418+
// Check if host target == the session target.
419+
if option_env!("TARGET") == Some(target_triple) {
420+
panic!(
421+
"calling external C functions in linked .so file requires target and host to be the same"
422+
);
423+
}
417424
// Note: it is the user's responsibility to provide a correct SO file.
418425
// WATCH OUT: If an invalid/incorrect SO file is specified, this can cause
419426
// undefined behaviour in Miri itself!

src/shims/ffi_support.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
221221

222222
let this = self.eval_context_mut();
223223

224-
// Check if host target == the session target.
225-
// This check needs to happen _after_ we check if the shared object file does not
226-
// export the function: we don't want to throw an error if we are just going to use
227-
// one of the shims.
228-
if option_env!("TARGET") == Some(&this.tcx.sess.opts.target_triple.to_string()) {
229-
throw_ub_format!(
230-
"calling external C functions in linked .so file requires target and host to be the same"
231-
);
232-
}
233-
234224
// Get the function arguments, and convert them to `libffi`-compatible form.
235225
let mut libffi_args = Vec::<CArg>::with_capacity(args.len());
236226
for cur_arg in args.iter() {

0 commit comments

Comments
 (0)