From 641a30efcfffefd25f8b5375f636e33f02746153 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 1 Jan 2021 17:31:48 -0500 Subject: 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) --- compiler/GHC/HsToCore/Foreign/Decl.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 "()" -- cgit v1.2.1