summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-01-01 17:31:48 -0500
committerBen Gamari <ben@smart-cactus.org>2021-01-11 10:26:27 -0500
commit641a30efcfffefd25f8b5375f636e33f02746153 (patch)
tree800caaefc251f593f6eefdcd76bae1f5c6659f77
parent5b989bcd38cdf836b3820cfc3785a47ca1010e09 (diff)
downloadhaskell-641a30efcfffefd25f8b5375f636e33f02746153.tar.gz
compiler: Initialize ForeignExportsList.n_entries
The refactoring in ed57c3a9eb9286faa222f98e484a9ef3432b2025 failed to initialize this field, resulting in no exports being registered. A very silly bug and yet somehow none of our tests caught it. See #18548. Fixes #19149. (cherry picked from commit 4cd2674fbf1adb1e1d951dcb65e78eda03732484)
-rw-r--r--compiler/GHC/HsToCore/Foreign/Decl.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/GHC/HsToCore/Foreign/Decl.hs b/compiler/GHC/HsToCore/Foreign/Decl.hs
index 58f1b7515f..78eb53cd4d 100644
--- a/compiler/GHC/HsToCore/Foreign/Decl.hs
+++ b/compiler/GHC/HsToCore/Foreign/Decl.hs
@@ -709,7 +709,10 @@ foreignExportsInitialiser mod hs_fns =
-- See Note [Tracking foreign exports] in rts/ForeignExports.c
vcat
[ text "static struct ForeignExportsList" <+> list_symbol <+> equals
- <+> braces (text ".exports = " <+> export_list) <> semi
+ <+> braces (
+ text ".exports = " <+> export_list <> comma <+>
+ text ".n_entries = " <+> ppr (length hs_fns))
+ <> semi
, text "static void " <> ctor_symbol <> text "(void)"
<+> text " __attribute__((constructor));"
, text "static void " <> ctor_symbol <> text "()"