summaryrefslogtreecommitdiff
path: root/rts/Exception.cmm
diff options
context:
space:
mode:
authorCheng Shao <astrohavoc@gmail.com>2022-10-21 13:47:58 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-11 00:26:55 -0500
commit07e92c92673c48db0325f101d07d73134ed79fe9 (patch)
tree26554fec5e7cc1c27108e76b3adbc6b3aefd73ff /rts/Exception.cmm
parent32ae62e61e811bf99def141a388a3f0abc8b7107 (diff)
downloadhaskell-07e92c92673c48db0325f101d07d73134ed79fe9.tar.gz
rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking
Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets.
Diffstat (limited to 'rts/Exception.cmm')
-rw-r--r--rts/Exception.cmm2
1 files changed, 1 insertions, 1 deletions
diff --git a/rts/Exception.cmm b/rts/Exception.cmm
index 6d040b37cd..ff577aace6 100644
--- a/rts/Exception.cmm
+++ b/rts/Exception.cmm
@@ -673,7 +673,7 @@ stg_raiseOverflowzh ()
*/
stg_paniczh (W_ str)
{
- ccall barf(str) never returns;
+ ccall barf(str, NULL) never returns;
}
// See Note [Compiler error functions] in GHC.Prim.Panic