I'm waiting for Sigbjorn to give the nod on this one, but it's fine by
me.  The -u __stginit_Prelude looks like a relic.

Cheers,
        Simon

On 15 May 2005 06:07, Wolfgang Thaller wrote:

> Hi,
> 
> would it be OK to commit this change to the PE linker, to ignore
> constructor sections like the ELF and Mach-O linkers do:
> 
> Index: ghc/rts/Linker.c
> ===================================================================
> RCS file: /home/cvs/root/fptools/ghc/rts/Linker.c,v
> retrieving revision 1.193
> diff -u -r1.193 Linker.c
> --- ghc/rts/Linker.c    11 May 2005 00:31:11 -0000    1.193
> +++ ghc/rts/Linker.c    15 May 2005 03:34:23 -0000
> @@ -1982,6 +1983,8 @@
>                information. */
>             && 0 != strcmp(".stab", sectab_i->Name)
>             && 0 != strcmp(".stabstr", sectab_i->Name)
> +          /* ignore constructor section for now */
> +          && 0 != strcmp(".ctors", sectab_i->Name)
>            ) {
>            errorBelch("Unknown PEi386 section name `%s' (while
> processing: %s)", sectab_i->Name, oc->fileName);
>            return 0;
> 
> It's untested, but I can't see what can possibly go wrong - famous
> last words ;-).
> We could then remove the mingw32 special case for stginit functions
> (patches below).
> A note on ghc/rts/package.conf.in: I don't think the -u
> __stginit_Prelude is needed any
> more in any case (I don't see why it should be necessary at all, and
> my Mac OS build works
> happily without it even with stginit functions).
> 
> Cheers,
> 
> Wolfgang
> 
> 
> Index: ghc/compiler/codeGen/CodeGen.lhs
> ===================================================================
> RCS file: /home/cvs/root/fptools/ghc/compiler/codeGen/CodeGen.lhs,v
> retrieving revision 1.71
> diff -u -r1.71 CodeGen.lhs
> --- ghc/compiler/codeGen/CodeGen.lhs    15 May 2005 03:20:29 -0000
> 1.71
> +++ ghc/compiler/codeGen/CodeGen.lhs    15 May 2005 03:34:16 -0000
> @@ -150,7 +150,7 @@
>       -> Code
> mkModuleInit dflags way cost_centre_info this_mod mb_main_mod
> foreign_stubs imported_mods
>     = do    {
> -        if need_init_code
> +        if opt_SccProfilingOn
>               then do { -- Allocate the static boolean that records
> if this
>                         -- module has been registered already
>                     emitData Data [CmmDataLabel moduleRegdLabel,
> @@ -204,10 +204,6 @@
>         stmtC (CmmStore (mkLblExpr moduleRegdLabel) (CmmLit
> (mkIntCLit 1)))
>           -- Now do local stuff
> -#if defined(mingw32_HOST_OS)
> -        -- ... until the GHCi Linker can load files with constructor
> functions:
> -        ; registerForeignExports foreign_stubs
> -#endif
>       ; initCostCentres cost_centre_info
>       ; mapCs (registerModuleImport dflags way)
>           (imported_mods++extra_imported_mods)
> @@ -218,12 +214,6 @@
>       ret_code = stmtsC [ CmmAssign spReg (cmmRegOffW spReg 1)
>                         , CmmJump (CmmLoad (cmmRegOffW spReg (-1))
> wordRep) [] ]
> -#if defined(mingw32_HOST_OS)
> -    need_init_code = True
> -#else
> -    need_init_code = opt_SccProfilingOn
> -#endif
> -
> -----------------------
> registerModuleImport :: DynFlags -> String -> Module -> Code
> registerModuleImport dflags way mod
> @@ -232,18 +222,6 @@
>     | otherwise     -- Push the init procedure onto the work stack
>     = stmtsC [ CmmAssign spReg (cmmRegOffW spReg (-1))
>          , CmmStore (CmmReg spReg) (mkLblExpr (mkModuleInitLabel
> dflags mod way)) ]
> -
> ------------------------
> -registerForeignExports :: ForeignStubs -> Code
> -registerForeignExports NoStubs
> -  = nopC
> -registerForeignExports (ForeignStubs _ _ _ fe_bndrs)
> -  = mapM_ mk_export_register fe_bndrs
> -  where
> -    mk_export_register bndr
> -      = emitRtsCall SLIT("getStablePtr")
> -        [ (CmmLit (CmmLabel (mkLocalClosureLabel (idName bndr))),
> -           PtrHint) ]
> \end{code}
> Index: ghc/compiler/deSugar/DsForeign.lhs
> ===================================================================
> RCS file: /home/cvs/root/fptools/ghc/compiler/deSugar/DsForeign.lhs,v
> retrieving revision 1.91
> diff -u -r1.91 DsForeign.lhs
> --- ghc/compiler/deSugar/DsForeign.lhs    15 May 2005 03:20:29
> -0000    1.91
> +++ ghc/compiler/deSugar/DsForeign.lhs    15 May 2005 03:34:17 -0000
> @@ -540,21 +540,10 @@
>      -- the program.
>      -- (this is bad for big umbrella modules like
> Graphics.Rendering.OpenGL)
> -   -- 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 ->
> +          Just hs_fn ->
>               vcat
>                [ text "static void stginit_export_" <> ppr hs_fn
>                     <> text "() __attribute__((constructor));"
> Index: ghc/rts/package.conf.in
> ===================================================================
> RCS file: /home/cvs/root/fptools/ghc/rts/package.conf.in,v
> retrieving revision 1.15
> diff -u -r1.15 package.conf.in
> --- ghc/rts/package.conf.in    22 Apr 2005 16:53:48 -0000    1.15
> +++ ghc/rts/package.conf.in    15 May 2005 03:34:24 -0000
> @@ -99,9 +99,6 @@
>            , "-u", "_GHCziIOBase_BlockedIndefinitely_closure"
>            , "-u", "_GHCziIOBase_Deadlock_closure"
>            , "-u", "_GHCziWeak_runFinalizzerBatch_closure"
> -#if defined(mingw32_HOST_OS)
> -         , "-u", "__stginit_Prelude"
> -#endif
> #else
>              "-u", "GHCziBase_Izh_static_info"
>            , "-u", "GHCziBase_Czh_static_info"
> @@ -135,9 +132,6 @@
>            , "-u", "GHCziIOBase_BlockedIndefinitely_closure"
>            , "-u", "GHCziIOBase_Deadlock_closure"
>            , "-u", "GHCziWeak_runFinalizzerBatch_closure"
> -#if defined(mingw32_HOST_OS)
> -         , "-u", "__stginit_Prelude"
> -#endif
> #endif
> framework-dirs:
> 
> _______________________________________________
> Cvs-ghc mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/cvs-ghc

_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to