Cheng Shao pushed to branch wip/T26166 at Glasgow Haskell Compiler / GHC Commits: 8f1564dc by Cheng Shao at 2025-10-15T15:14:16+02:00 WIP: fix all remaining wasm regressions for now - - - - - 5 changed files: - libraries/ghc-internal/cbits/RtsIface.c - libraries/ghc-internal/include/RtsIfaceSymbols.h - rts/RtsToHsIface.c - rts/include/rts/RtsToHsIface.h - rts/wasm/JSFFI.c Changes: ===================================== libraries/ghc-internal/cbits/RtsIface.c ===================================== @@ -25,7 +25,7 @@ void init_ghc_hs_iface(void); #define UNDEF_CLOSURE(module, symbol) #define INFO_TBL(module, symbol) \ - extern StgInfoTable ghczminternal_##module##_##symbol; + extern const StgInfoTable ghczminternal_##module##_##symbol; #include "RtsIfaceSymbols.h" @@ -43,7 +43,7 @@ void init_ghc_hs_iface(void); #define INFO_TBL(module, symbol) \ .symbol = &ghczminternal_##module##_##symbol, -static const HsIface the_ghc_hs_iface = { +static HsIface the_ghc_hs_iface = { #include "RtsIfaceSymbols.h" }; ===================================== libraries/ghc-internal/include/RtsIfaceSymbols.h ===================================== @@ -60,7 +60,7 @@ CLOSURE(GHCziInternalziExceptionziType, overflowException_closure) CLOSURE(GHCziInternalziCString, unpackCStringzh_closure) INFO_TBL(GHCziInternalziCString, unpackCStringzh_info) INFO_TBL(GHCziInternalziCString, unpackCStringUtf8zh_info) -#if defined(wasm32_HOST_ARCH) +#if defined(wasm32_HOST_ARCH) && defined(__PIC__) CLOSURE(GHCziInternalziWasmziPrimziImports, raiseJSException_closure) INFO_TBL(GHCziInternalziWasmziPrimziTypes, JSVal_con_info) CLOSURE(GHCziInternalziWasmziPrimziConcziInternal, threadDelay_closure) ===================================== rts/RtsToHsIface.c ===================================== @@ -56,4 +56,4 @@ // This captures the symbols provided by ghc-internal which // are needed by the RTS. -const HsIface *ghc_hs_iface = NULL; +HsIface *ghc_hs_iface = NULL; ===================================== rts/include/rts/RtsToHsIface.h ===================================== @@ -36,36 +36,36 @@ typedef struct { StgClosure *runHandlersPtr_closure; // GHC.Internal.Conc.Signal.runHandlersPtr_closure StgClosure *flushStdHandles_closure; // GHC.Internal.TopHandler.flushStdHandles_closure StgClosure *runMainIO_closure; // GHC.Internal.TopHandler.runMainIO_closure - StgInfoTable *Czh_con_info; // GHC.Internal.Types.Czh_con_info - StgInfoTable *Izh_con_info; // GHC.Internal.Types.Izh_con_info - StgInfoTable *Fzh_con_info; // GHC.Internal.Types.Fzh_con_info - StgInfoTable *Dzh_con_info; // GHC.Internal.Types.Dzh_con_info - StgInfoTable *Wzh_con_info; // GHC.Internal.Types.Wzh_con_info + const StgInfoTable *Czh_con_info; // GHC.Internal.Types.Czh_con_info + const StgInfoTable *Izh_con_info; // GHC.Internal.Types.Izh_con_info + const StgInfoTable *Fzh_con_info; // GHC.Internal.Types.Fzh_con_info + const StgInfoTable *Dzh_con_info; // GHC.Internal.Types.Dzh_con_info + const StgInfoTable *Wzh_con_info; // GHC.Internal.Types.Wzh_con_info StgClosure *absentSumFieldError_closure; // GHC.Internal.Prim.Panic.absentSumFieldError_closure StgClosure *runAllocationLimitHandler_closure; // GHC.Internal.AllocationLimitHandler.runAllocationLimitHandler_closure - StgInfoTable *Ptr_con_info; // GHC.Internal.Ptr.Ptr_con_info - StgInfoTable *FunPtr_con_info; // GHC.Internal.Ptr.FunPtr_con_info - StgInfoTable *I8zh_con_info; // GHC.Internal.Int.I8zh_con_info - StgInfoTable *I16zh_con_info; // GHC.Internal.Int.I16zh_con_info - StgInfoTable *I32zh_con_info; // GHC.Internal.Int.I32zh_con_info - StgInfoTable *I64zh_con_info; // GHC.Internal.Int.I64zh_con_info - StgInfoTable *W8zh_con_info; // GHC.Internal.Word.W8zh_con_info - StgInfoTable *W16zh_con_info; // GHC.Internal.Word.W16zh_con_info - StgInfoTable *W32zh_con_info; // GHC.Internal.Word.W32zh_con_info - StgInfoTable *W64zh_con_info; // GHC.Internal.Word.W64zh_con_info - StgInfoTable *StablePtr_con_info; // GHC.Internal.Stable.StablePtr_con_info + const StgInfoTable *Ptr_con_info; // GHC.Internal.Ptr.Ptr_con_info + const StgInfoTable *FunPtr_con_info; // GHC.Internal.Ptr.FunPtr_con_info + const StgInfoTable *I8zh_con_info; // GHC.Internal.Int.I8zh_con_info + const StgInfoTable *I16zh_con_info; // GHC.Internal.Int.I16zh_con_info + const StgInfoTable *I32zh_con_info; // GHC.Internal.Int.I32zh_con_info + const StgInfoTable *I64zh_con_info; // GHC.Internal.Int.I64zh_con_info + const StgInfoTable *W8zh_con_info; // GHC.Internal.Word.W8zh_con_info + const StgInfoTable *W16zh_con_info; // GHC.Internal.Word.W16zh_con_info + const StgInfoTable *W32zh_con_info; // GHC.Internal.Word.W32zh_con_info + const StgInfoTable *W64zh_con_info; // GHC.Internal.Word.W64zh_con_info + const StgInfoTable *StablePtr_con_info; // GHC.Internal.Stable.StablePtr_con_info StgClosure *StackSnapshot_closure; // GHC.Internal.Stack.CloneStack.StackSnapshot_closure StgClosure *divZZeroException_closure; // GHC.Internal.Exception.Type.divZeroException_closure StgClosure *underflowException_closure; // GHC.Internal.Exception.Type.underflowException_closure StgClosure *overflowException_closure; // GHC.Internal.Exception.Type.overflowException_closure StgClosure *unpackCStringzh_closure; // GHC.Internal.CString.unpackCStringzh_closure - StgInfoTable *unpackCStringzh_info; // GHC.Internal.CString.unpackCStringzh_info - StgInfoTable *unpackCStringUtf8zh_info; // GHC.Internal.CString.unpackCStringUtf8zh_info + const StgInfoTable *unpackCStringzh_info; // GHC.Internal.CString.unpackCStringzh_info + const StgInfoTable *unpackCStringUtf8zh_info; // GHC.Internal.CString.unpackCStringUtf8zh_info #if defined(wasm32_HOST_ARCH) StgClosure *raiseJSException_closure; // GHC.Internal.Wasm.Prim.Imports.raiseJSException_closure - StgInfoTable *JSVal_con_info; // GHC.Internal.Wasm.Prim.Types.JSVal_con_info + const StgInfoTable *JSVal_con_info; // GHC.Internal.Wasm.Prim.Types.JSVal_con_info StgClosure *threadDelay_closure; // GHC.Internal.Wasm.Prim.Conc.Internal.threadDelay_closure #endif } HsIface; -extern const HsIface *ghc_hs_iface; +extern HsIface *ghc_hs_iface; ===================================== rts/wasm/JSFFI.c ===================================== @@ -15,6 +15,22 @@ extern HsStablePtr rts_threadDelay_impl; __attribute__((__weak__)) int __main_argc_argv(int argc, char *argv[]); +#if !defined(__PIC__) +void init_ghc_hs_iface(void); + +extern StgClosure ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure; +extern const StgInfoTable ghczminternal_GHCziInternalziWasmziPrimziTypes_JSVal_con_info; +extern StgClosure ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure; + +__attribute__((constructor(100))) +static void __init_ghc_hs_iface_jsffi(void) { + init_ghc_hs_iface(); + ghc_hs_iface->raiseJSException_closure = &ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure; + ghc_hs_iface->JSVal_con_info = &ghczminternal_GHCziInternalziWasmziPrimziTypes_JSVal_con_info; + ghc_hs_iface->threadDelay_closure = &ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure; +} +#endif + // Note [JSFFI initialization] // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f1564dcba343fd33fe50980015de07b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f1564dcba343fd33fe50980015de07b... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Cheng Shao (@TerrorJack)