Skip to content

Commit 4bf0d2d

Browse files
committed
Ignore symbol shim clash when symbol is provided by compiler_builtins
When this happens, we ignore the symbol from `compiler_builtins` in favor of Miri's builtin support. This allows Miri to target platforms like wasm32-unknown-unknown, where functions like `memcmp` are provided by `compiler_builtins`.
1 parent f9fb398 commit 4bf0d2d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/helpers.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
943943
link_name: Symbol,
944944
) -> InterpResult<'tcx, ()> {
945945
self.check_abi(abi, exp_abi)?;
946-
if let Some((body, _)) = self.eval_context_mut().lookup_exported_symbol(link_name)? {
946+
if let Some((body, instance)) = self.eval_context_mut().lookup_exported_symbol(link_name)? {
947+
// If compiler-builtins is providing the symbol, then don't treat it as a clash.
948+
// We'll use our built-in implementation in `emulate_foreign_item_by_name` for increased
949+
// performance. Note that this means we won't catch any undefined behavior in
950+
// compiler-builtins when running other crates, but Miri can still be run on
951+
// compiler-builtins itself (or any crate that uses it as a normal dependency)
952+
if self.eval_context_ref().tcx.is_compiler_builtins(instance.def_id().krate) {
953+
return Ok(());
954+
}
955+
947956
throw_machine_stop!(TerminationInfo::SymbolShimClashing {
948957
link_name,
949958
span: body.span.data(),

0 commit comments

Comments
 (0)