summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-01-01 17:31:48 -0500
committerBen Gamari <ben@well-typed.com>2021-01-06 13:39:52 -0500
commitb37c21ab60bcd9e4ddeea60890d9da6ed1b5a356 (patch)
treecb63da1078ec476e7ae98b031941454876a9b27d
parent441bb6852eba98ad4376a6f44f9fca66e3ec5fad (diff)
downloadhaskell-b37c21ab60bcd9e4ddeea60890d9da6ed1b5a356.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/deSugar/DsForeign.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/deSugar/DsForeign.hs b/compiler/deSugar/DsForeign.hs
index 03b2256e2e..6a6a2eece8 100644
--- a/compiler/deSugar/DsForeign.hs
+++ b/compiler/deSugar/DsForeign.hs
@@ -682,7 +682,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 "()"