From a99188913253c929aa8934d702e82866dfe92121 Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Mon, 16 Oct 2023 06:49:34 +0000 Subject: [PATCH] compiler: allow JSFFI for wasm32 This commit allows the javascript calling convention to be used when the target platform is wasm32. --- compiler/GHC/Tc/Gen/Foreign.hs | 2 +- compiler/GHC/Types/ForeignCall.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/GHC/Tc/Gen/Foreign.hs b/compiler/GHC/Tc/Gen/Foreign.hs index 229dbe821935..84b48b4d2d7c 100644 --- a/compiler/GHC/Tc/Gen/Foreign.hs +++ b/compiler/GHC/Tc/Gen/Foreign.hs @@ -555,7 +555,7 @@ checkCConv decl PrimCallConv = do return PrimCallConv checkCConv decl JavaScriptCallConv = do dflags <- getDynFlags - if platformArch (targetPlatform dflags) == ArchJavaScript + if platformArch (targetPlatform dflags) `elem` [ ArchJavaScript, ArchWasm32 ] then return JavaScriptCallConv else do addErrTc $ TcRnUnsupportedCallConv decl JavaScriptCallConvUnsupported diff --git a/compiler/GHC/Types/ForeignCall.hs b/compiler/GHC/Types/ForeignCall.hs index a7a34776738d..8cfa4805ac2a 100644 --- a/compiler/GHC/Types/ForeignCall.hs +++ b/compiler/GHC/Types/ForeignCall.hs @@ -189,7 +189,7 @@ ccallConvAttribute StdCallConv = text "__attribute__((__stdcall__))" ccallConvAttribute CCallConv = empty ccallConvAttribute CApiConv = empty ccallConvAttribute (PrimCallConv {}) = panic "ccallConvAttribute PrimCallConv" -ccallConvAttribute JavaScriptCallConv = panic "ccallConvAttribute JavaScriptCallConv" +ccallConvAttribute JavaScriptCallConv = empty type CLabelString = FastString -- A C label, completely unencoded -- GitLab