David Eichmann pushed to branch wip/davide/windows-dlls at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • compiler/GHC/Cmm.hs
    ... ... @@ -269,6 +269,7 @@ data SectionType
    269 269
       | FiniArray           -- .fini_array on ELF, .dtor on Windows
    
    270 270
       | CString
    
    271 271
       | IPE
    
    272
    +  | Directive           -- .drectve on Windows
    
    272 273
       deriving (Show)
    
    273 274
     
    
    274 275
     data SectionProtection
    
    ... ... @@ -289,6 +290,7 @@ sectionProtection t = case t of
    289 290
         Data                    -> ReadWriteSection
    
    290 291
         UninitialisedData       -> ReadWriteSection
    
    291 292
         IPE                     -> ReadWriteSection
    
    293
    +    Directive               -> ReadOnlySection
    
    292 294
     
    
    293 295
     {-
    
    294 296
     Note [Relocatable Read-Only Data]
    
    ... ... @@ -548,3 +550,4 @@ pprSectionType s = doubleQuotes $ case s of
    548 550
       FiniArray               -> text "finiarray"
    
    549 551
       CString                 -> text "cstring"
    
    550 552
       IPE                     -> text "ipe"
    
    553
    +  Directive               -> text "drectve"

  • compiler/GHC/CmmToAsm/Ppr.hs
    ... ... @@ -243,6 +243,7 @@ pprGNUSectionHeader config t suffix =
    243 243
             | OSMinGW32 <- platformOS platform
    
    244 244
                         -> text ".rdata"
    
    245 245
             | otherwise -> text ".ipe"
    
    246
    +      Directive -> text ".drectve"
    
    246 247
         flags
    
    247 248
           -- See
    
    248 249
           -- https://github.com/llvm/llvm-project/blob/llvmorg-21.1.8/lld/COFF/Chunks.cpp#L54
    
    ... ... @@ -339,8 +340,9 @@ pprDarwinSectionHeader t = case t of
    339 340
       RelocatableReadOnlyData -> text ".const_data"
    
    340 341
       UninitialisedData       -> text ".data"
    
    341 342
       InitArray               -> text ".section\t__DATA,__mod_init_func,mod_init_funcs"
    
    342
    -  FiniArray               -> panic "pprDarwinSectionHeader: fini not supported"
    
    343 343
       CString                 -> text ".section\t__TEXT,__cstring,cstring_literals"
    
    344 344
       IPE                     -> text ".const"
    
    345
    +  FiniArray               -> panic "pprDarwinSectionHeader: fini not supported"
    
    346
    +  Directive               -> panic "pprDarwinSectionHeader: drectve not supported"
    
    345 347
     {-# SPECIALIZE pprDarwinSectionHeader :: SectionType -> SDoc #-}
    
    346 348
     {-# SPECIALIZE pprDarwinSectionHeader :: SectionType -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable

  • compiler/GHC/CmmToAsm/X86/Ppr.hs
    ... ... @@ -133,6 +133,9 @@ pprNatCmmDecl config proc@(CmmProc top_info entry_lbl _ (ListGraph blocks)) =
    133 133
     
    
    134 134
           -- ELF .size directive (size of the entry code function)
    
    135 135
         , pprSizeDecl platform proc_lbl
    
    136
    +
    
    137
    +    , -- Explicite export on windows (see Note [TODO])
    
    138
    +      pprExport config proc_lbl False
    
    136 139
         ]
    
    137 140
     {-# SPECIALIZE pprNatCmmDecl :: NCGConfig -> NatCmmDecl (Alignment, RawCmmStatics) Instr -> SDoc #-}
    
    138 141
     {-# SPECIALIZE pprNatCmmDecl :: NCGConfig -> NatCmmDecl (Alignment, RawCmmStatics) Instr -> HDoc #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable
    
    ... ... @@ -206,11 +209,17 @@ pprDatas config (_, CmmStaticsRaw alias [CmmStaticLit (CmmLabel lbl), CmmStaticL
    206 209
       , not $ platformOS platform == OSMinGW32 && ncgSplitSections config
    
    207 210
       = pprGloblDecl (ncgPlatform config) alias
    
    208 211
         $$ line (text ".equiv" <+> pprAsmLabel (ncgPlatform config) alias <> comma <> pprAsmLabel (ncgPlatform config) ind')
    
    212
    +    $$ pprExport config lbl True
    
    209 213
         where
    
    210 214
           platform = ncgPlatform config
    
    211 215
     
    
    212 216
     pprDatas config (align, (CmmStaticsRaw lbl dats))
    
    213
    - = vcat (pprAlign platform align : pprLabel platform lbl : map (pprData config) dats)
    
    217
    + = vcat $
    
    218
    +    [ pprAlign platform align
    
    219
    +    , pprLabel platform lbl
    
    220
    +    ]
    
    221
    +    ++ (map (pprData config) dats)
    
    222
    +    ++ [pprExport config lbl True]
    
    214 223
        where
    
    215 224
           platform = ncgPlatform config
    
    216 225
     
    
    ... ... @@ -290,6 +299,27 @@ pprLabelType' platform lbl =
    290 299
           isInfoTableLabel lbl && not (isCmmInfoTableLabel lbl) && not (isConInfoTableLabel lbl)
    
    291 300
     
    
    292 301
     
    
    302
    +-- See Note [TODO]
    
    303
    +pprExport :: IsDoc doc => NCGConfig -> CLabel -> Bool -> doc
    
    304
    +pprExport config lbl isCmmData =
    
    305
    +  if platformOS platform == OSMinGW32
    
    306
    +     && platformTablesNextToCode platform
    
    307
    +     && externallyVisibleCLabel lbl
    
    308
    +     then let
    
    309
    +        asData = isCmmData || isInfoTableLabel lbl
    
    310
    +        in
    
    311
    +          pprSectionAlign config (Section Directive lbl) $$
    
    312
    +          line (text ".ascii" <> doubleQuotes (
    
    313
    +              text " -export:"
    
    314
    +              <> pprAsmLabel platform lbl
    
    315
    +              <> if asData then text ",data" else empty
    
    316
    +            ))
    
    317
    +     else empty
    
    318
    +  where
    
    319
    +    platform = ncgPlatform config
    
    320
    +
    
    321
    +
    
    322
    +
    
    293 323
     pprTypeDecl :: IsDoc doc => Platform -> CLabel -> doc
    
    294 324
     pprTypeDecl platform lbl
    
    295 325
         = if osElfTarget (platformOS platform) && externallyVisibleCLabel lbl