-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/
Description
Whenever I try to compile some specific code for wasm32-unknown-unknown
with enabled overflow-checks
and lto
the compiler inserts a function import into the resulting wasm module that looks like this:
(import "env" "_ZN4core9panicking5panic17h80a3410ec4f43255E" (func $_ZN4core9panicking5panic17h80a3410ec4f43255E (type 0))
These are the complete contents of the lib.rs
:
#![no_std]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub fn multer(a: i128, b: i128) -> i128 {
// trigger usage of the __multi3 compiler intrinsic which seems to be necessary
// in order to reproduce the bug
a * b
}
What seems to trigger the bug are the following conditions:
- The
--target
must bewasm32-unknown-unknown
overflow-checks = true
lto = true
- Recompile core libs with cargo xbuild or the std aware cargo
- The call of the panic function originates in some compiler extrinsic
The minimal reproducer repo contains the exact command line that reproduces the bug.
I expected to see this happen:
The resulting wasm module does not import any function from the environment.
Instead, this happened:
The resulting wasm module imports the previously mentioned panic function from the environment.
Meta
rustc +nightly --version --verbose
:
rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-apple-darwin
release: 1.49.0-nightly
LLVM version: 11.0
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/