David Eichmann pushed to branch wip/dcoutts/windows-rts-dll at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -377,6 +377,7 @@ templateRules = do
    377 377
         , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1
    
    378 378
         , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2
    
    379 379
         ]
    
    380
    +  templateRule "rts/win32/libHSghc-internal.def" projectVersion
    
    380 381
       templateRule "docs/index.html" $ packageUnitIds Stage1
    
    381 382
       templateRule "docs/users_guide/ghc_config.py" $ mconcat
    
    382 383
         [ projectVersion
    

  • hadrian/src/Rules/Library.hs
    ... ... @@ -4,6 +4,8 @@ import Hadrian.BuildPath
    4 4
     import Hadrian.Haskell.Cabal
    
    5 5
     import Hadrian.Haskell.Cabal.Type
    
    6 6
     import qualified Text.Parsec      as Parsec
    
    7
    +import GHC.Platform.ArchOS (ArchOS(archOS_OS), OS(..))
    
    8
    +import GHC.Toolchain.Target (Target(tgtArchOs))
    
    7 9
     
    
    8 10
     import Base
    
    9 11
     import Context
    
    ... ... @@ -185,9 +187,13 @@ jsObjects context = do
    185 187
       srcs <- interpretInContext context (getContextData jsSrcs)
    
    186 188
       mapM (objectPath context) srcs
    
    187 189
     
    
    188
    --- | Return extra object files needed to build the given library context. The
    
    189
    --- resulting list is currently non-empty only when the package from the
    
    190
    --- 'Context' is @ghc-internal@ built with in-tree GMP backend.
    
    190
    +-- | Return extra object files needed to build the given library context.
    
    191
    +--
    
    192
    +-- This is non-empty for:
    
    193
    +--
    
    194
    +-- * @ghc-internal@ when built with in-tree GMP backend
    
    195
    +-- * @rts@ on Windows when linking dynamically
    
    196
    +--
    
    191 197
     extraObjects :: Context -> Action [FilePath]
    
    192 198
     extraObjects context
    
    193 199
         | package context == ghcInternal = do
    
    ... ... @@ -195,6 +201,13 @@ extraObjects context
    195 201
                 "gmp" -> gmpObjects (stage context)
    
    196 202
                 _     -> return []
    
    197 203
     
    
    204
    +    | package context == rts = do
    
    205
    +          target   <- interpretInContext context getStagedTarget
    
    206
    +          builddir <- buildPath context
    
    207
    +          return [ builddir -/- "libHSghc-internal.dll.a"
    
    208
    +                 | archOS_OS (tgtArchOs target) == OSMinGW32
    
    209
    +                 , Dynamic `wayUnit` way context ]
    
    210
    +
    
    198 211
         | otherwise = return []
    
    199 212
     
    
    200 213
     -- | Return all the object files to be put into the library we're building for
    

  • hadrian/src/Rules/Rts.hs
    ... ... @@ -24,6 +24,20 @@ rtsRules = priority 3 $ do
    24 24
                 (addRtsDummyVersion $ takeFileName rtsLibFilePath')
    
    25 25
                 rtsLibFilePath'
    
    26 26
     
    
    27
    +    -- Solve the recursive dependency between the rts and ghc-internal
    
    28
    +    -- on Windows by creating an import lib for the ghc-internal dll,
    
    29
    +    -- to be linked into the rts dll.
    
    30
    +    forM_ [Stage1, Stage2, Stage3 ] $ \ stage -> do
    
    31
    +        let buildPath = root -/- buildDir (rtsContext stage)
    
    32
    +        buildPath -/- "libHSghc-internal.dll.a" %> buildGhcInternalImportLib
    
    33
    +
    
    34
    +buildGhcInternalImportLib :: FilePath -> Action ()
    
    35
    +buildGhcInternalImportLib target = do
    
    36
    +    let input  = "rts/win32/libHSghc-internal.def"
    
    37
    +        output = target -- the .dll.a import lib
    
    38
    +    need [input]
    
    39
    +    runBuilder Dlltool ["-d", input, "-l", output] [input] [output]
    
    40
    +
    
    27 41
     -- Need symlinks generated by rtsRules.
    
    28 42
     needRtsSymLinks :: Stage -> Set.Set Way -> Action ()
    
    29 43
     needRtsSymLinks stage rtsWays
    

  • rts/.gitignore
    ... ... @@ -20,3 +20,4 @@
    20 20
     /ghcautoconf.h.autoconf.in
    
    21 21
     /ghcautoconf.h.autoconf
    
    22 22
     /include/ghcautoconf.h
    
    23
    +/win32/libHSghc-internal.def

  • rts/win32/libHSghc-internal.def.in
    1
    +LIBRARY libHSghc-internal-@ProjectVersionForLib@.0-ghc@ProjectVersion@.dll
    
    2
    +
    
    3
    +EXPORTS
    
    4
    +    init_ghc_hs_iface