Skip to content

Exception handling instructions emitted on wasm even when exception-handling feature is disabled #140293

Open
@bjorn3

Description

@bjorn3

I tried this code:

pub extern "C-unwind" fn gzgetc() -> i32 {
    42
}

pub extern "C-unwind" fn gzgetc_() -> i32 {
    gzgetc()
}

fn main() {
    for gzgetc_fn in [gzgetc, gzgetc_] {
        // gzgetc on a null file handle should return -1.
        assert_eq!(gzgetc_fn(), -1);
    }
}

compiled for wasm32-wasip1 or wasm32-unknown-unknown without -Ctarget-feature=exception-handling.

I expected to see this happen: No exception handling instructions emitted

Instead, this happened: catch_call is emitted for gzgetc_fn() when opt-level < 2.

Meta

rustc --version --verbose: Both 1.86 and nightly

This is causing failure to run on Wasmtime in some cases: trifectatechfoundation/zlib-rs#352 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-bugCategory: This is a bug.F-c_unwind`#![feature(c_unwind)]`O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions