Skip to content

Commit 4e017b5

Browse files
committed
fix host/target check for extern-so
1 parent 515038e commit 4e017b5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ fn main() {
22
// Re-export the TARGET environment variable so it can
33
// be accessed by miri.
44
let target = std::env::var("TARGET").unwrap();
5-
println!("cargo:rustc-env=TARGET={:?}", target);
5+
println!("cargo:rustc-env=TARGET={}", target);
66
}

src/machine.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,11 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
418418
since_progress_report: 0,
419419
external_so_lib: config.external_so_file.as_ref().map(|lib_file_path| {
420420
// Check if host target == the session target.
421-
if option_env!("TARGET") == Some(target_triple) {
421+
if env!("TARGET") != target_triple {
422422
panic!(
423-
"calling external C functions in linked .so file requires target and host to be the same"
423+
"calling external C functions in linked .so file requires host and target to be the same: host={}, target={}",
424+
env!("TARGET"),
425+
target_triple,
424426
);
425427
}
426428
// Note: it is the user's responsibility to provide a correct SO file.

src/shims/foreign_items.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
370370
) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> {
371371
let this = self.eval_context_mut();
372372

373-
// First deal with any external C functions in linked .so file
374-
// (if any SO file is specified, and if the host target == the session target)
373+
// First deal with any external C functions in linked .so file.
375374
if this.machine.external_so_lib.as_ref().is_some() {
376375
// An Ok(false) here means that the function being called was not exported
377-
// by the specified SO file; we should continue and check if it corresponds to
376+
// by the specified `.so` file; we should continue and check if it corresponds to
378377
// a provided shim.
379378
if this.call_external_c_fct(link_name, dest, args)? {
380379
return Ok(EmulateByNameResult::NeedsJumping);

0 commit comments

Comments
 (0)