diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2023-01-05 21:41:53 -0600 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2023-01-05 21:41:53 -0600 |
| commit | 54be8aad7976b81231f0a71fa2051e0b6528f107 (patch) | |
| tree | b3ad218700123b9007cb633cbd7293a36deb751f /src | |
| parent | e1968dd6120935055e138ab10c6e0a3f3f2288b9 (diff) | |
| download | rust-54be8aad7976b81231f0a71fa2051e0b6528f107.tar.gz rust-54be8aad7976b81231f0a71fa2051e0b6528f107.zip | |
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`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/helpers.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index c11c6104c28..527d31d1f0a 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -943,7 +943,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { link_name: Symbol, ) -> InterpResult<'tcx, ()> { self.check_abi(abi, exp_abi)?; - if let Some((body, _)) = self.eval_context_mut().lookup_exported_symbol(link_name)? { + if let Some((body, instance)) = self.eval_context_mut().lookup_exported_symbol(link_name)? { + // If compiler-builtins is providing the symbol, then don't treat it as a clash. + // We'll use our built-in implementation in `emulate_foreign_item_by_name` for increased + // performance. Note that this means we won't catch any undefined behavior in + // compiler-builtins when running other crates, but Miri can still be run on + // compiler-builtins itself (or any crate that uses it as a normal dependency) + if self.eval_context_ref().tcx.is_compiler_builtins(instance.def_id().krate) { + return Ok(()); + } + throw_machine_stop!(TerminationInfo::SymbolShimClashing { link_name, span: body.span.data(), |
