Nothing -> empty
Just hs_fn -> text "extern StgClosure " <> ppr hs_fn <> text "_closure" <> semi
+ -- the only reason for making the mingw32 (anything targetting PE, really) stick
+ -- out here is that the GHCi linker isn't capable of handling .ctors sections
+ useStaticConstructors
+#if defined(mingw32_HOST_OS)
+ = False
+#else
+ = True
+#endif
+
+ initialiser
+ = case maybe_target of
+ Nothing -> empty
+ Just hs_fn
+ | not useStaticConstructors -> empty
+ | otherwise ->
+ vcat
+ [ text "static void stginit_export_" <> ppr hs_fn
+ <> text "() __attribute__((constructor));"
+ , text "static void stginit_export_" <> ppr hs_fn <> text "()"
+ , braces (text "getStablePtr"
+ <> parens (text "(StgPtr) &" <> ppr hs_fn <> text "_closure")
+ <> semi)
+ ]
+
-- finally, the whole darn thing
c_bits =
space $$
, if res_hty_is_unit then empty
else text "return cret;"
, rbrace
- ]
+ ] $$
+ initialiser
-- NB. the calculation here isn't strictly speaking correct.
-- We have a primitive Haskell type (eg. Int#, Double#), and