Skip to content

Commit 053c92b

Browse files
TerrorJackMarge Bot
authored andcommitted
compiler: ensure ctors have the right priority on wasm32
This commit fixes the priorities of ctors generated by GHC codegen on wasm32, see the referred note for details.
1 parent 8771a53 commit 053c92b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/GHC/CmmToAsm/Wasm/Asm.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ asmTellGlobals ty_word = do
452452
asmTellCtors :: WasmTypeTag w -> [SymName] -> WasmAsmM ()
453453
asmTellCtors _ [] = mempty
454454
asmTellCtors ty_word syms = do
455-
asmTellSectionHeader ".init_array"
455+
-- See Note [JSFFI initialization] for details
456+
asmTellSectionHeader ".init_array.101"
456457
asmTellAlign $ alignmentFromWordType ty_word
457458
for_ syms $ \sym ->
458459
asmTellTabLine $

compiler/GHC/CmmToC.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,5 +1533,8 @@ pprCtorArray platform initOrFini lbls =
15331533
body = vcat [ pprCLabel platform lbl <> text " ();" | lbl <- lbls ]
15341534
decls = vcat [ text "void" <+> pprCLabel platform lbl <> text " (void);" | lbl <- lbls ]
15351535
attribute = case initOrFini of
1536-
IsInitArray -> text "constructor"
1536+
IsInitArray
1537+
-- See Note [JSFFI initialization] for details
1538+
| ArchWasm32 <- platformArch platform -> text "constructor(101)"
1539+
| otherwise -> text "constructor"
15371540
IsFiniArray -> text "destructor"

0 commit comments

Comments
 (0)