summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-01-01 17:31:48 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-07 00:12:46 -0500
commit10499f55166e1906b6bdfd3576b0f3b8c019cc91 (patch)
treed99c4d9f7d53a09269b38beec206d48b0bdc06da
parent1de2050edd8a2647e89a9269278a79b61892b59e (diff)
downloadhaskell-10499f55166e1906b6bdfd3576b0f3b8c019cc91.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.
-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 1dea63982f..8348d0a1fa 100644
--- a/compiler/GHC/HsToCore/Foreign/Decl.hs
+++ b/compiler/GHC/HsToCore/Foreign/Decl.hs
@@ -715,7 +715,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 "()"