-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
wasm32-unknown-unknown "C" ABI doesn't use proper ABI adjustments #115666
Copy link
Copy link
Closed
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
rustc has a
PassModeenum to declare how arguments should be passed between functions.PassMode::Directis used for the simple case where we can just generate LLVM IR with an argument type that matches the usual LLVM type for this Rust type. It should only be used for types withScalarorVectorABI; for larger types, Rust will generate LLVM struct/union types and thoserepr(transparent)types.Unfortunately the compiler never had an assertion ensuring that
PassMode::Directis only used withScalar/Vectortypes, and so one target accidentally broke this rule: wasm32-unknown-unknown. Later all wasm targets got anextern "wasm"ABI that has the same issue. We should find some way to fix this target, as the current situation makes life harder for anyone wanting to tweak our Rust-to-LLVM-type-mapping, and for alternative backends that have to match our effective ABI.The issue is that last time @bjorn3 tried to fix this, it lead to #81386 and had to be reverted. It will be basically impossible to do this change without breaking the ABI at least for some cases. I'm not sure how much ABI breakage we can get away with. This might have to be blocked on rust-lang/compiler-team#672 which should help to implement the current effective ABI at least for types that are ABI-stable (i.e.,
repr(C)andrepr(transparent)).Cc #122532