David Eichmann pushed to branch wip/davide/ghc-internal-def at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

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

  • hadrian/src/Rules/Library.hs
    ... ... @@ -9,6 +9,7 @@ import GHC.Toolchain.Target (Target(tgtArchOs))
    9 9
     
    
    10 10
     import Base
    
    11 11
     import Context
    
    12
    +import qualified Data.List as List
    
    12 13
     import Expression hiding (way, package, stage)
    
    13 14
     import Oracles.ModuleFiles
    
    14 15
     import Packages
    
    ... ... @@ -20,6 +21,7 @@ import Utilities
    20 21
     import Data.Time.Clock
    
    21 22
     import Rules.Generate (generatedDependencies)
    
    22 23
     import Oracles.Flag
    
    24
    +import Way.Type (wayToUnits)
    
    23 25
     
    
    24 26
     
    
    25 27
     -- * Library 'Rules'
    
    ... ... @@ -203,13 +205,29 @@ extraObjects context
    203 205
     
    
    204 206
         | package context == rts = do
    
    205 207
               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 ]
    
    208
    +          if not (archOS_OS (tgtArchOs target) == OSMinGW32
    
    209
    +                && Dynamic `wayUnit` way context)
    
    210
    +          then return []
    
    211
    +          else do
    
    212
    +            -- Find the ghc-internal library file name
    
    213
    +            ghcInternalDllName <- takeFileName <$> pkgLibraryFile Context {
    
    214
    +                    stage = stage context,
    
    215
    +                    way = rtsWayToLibraryWay (way context),
    
    216
    +                    iplace = iplace context,
    
    217
    +                    package = ghcInternal
    
    218
    +                }
    
    219
    +
    
    220
    +            builddir <- buildPath context
    
    221
    +            return [ builddir -/- ghcInternalDllName <> ".a"]
    
    210 222
     
    
    211 223
         | otherwise = return []
    
    212 224
     
    
    225
    +-- | The rts is compiled in many different ways, but libraries are only built in
    
    226
    +-- (non)Dynamic and (non)Profiled ways. This function converts the rts way into
    
    227
    +-- compatible library way.
    
    228
    +rtsWayToLibraryWay :: Way -> Way
    
    229
    +rtsWayToLibraryWay = wayFromUnits . List.intersect [Dynamic, Profiling] . wayToUnits
    
    230
    +
    
    213 231
     -- | Return all the object files to be put into the library we're building for
    
    214 232
     -- the given 'Context'.
    
    215 233
     libraryObjects :: Context -> Action [FilePath]
    

  • hadrian/src/Rules/Rts.hs
    ... ... @@ -13,11 +13,19 @@ rtsRules = priority 3 $ do
    13 13
         -- to be linked into the rts dll.
    
    14 14
         forM_ [Stage1, Stage2, Stage3 ] $ \ stage -> do
    
    15 15
             let buildPath = root -/- buildDir (rtsContext stage)
    
    16
    -        buildPath -/- "libHSghc-internal.dll.a" %> buildGhcInternalImportLib
    
    16
    +        buildPath -/- "libHSghc-internal-*.def" %> buildGhcInternalImportDef
    
    17
    +        buildPath -/- "libHSghc-internal-*.dll.a" %> buildGhcInternalImportLib
    
    18
    +
    
    19
    +buildGhcInternalImportDef :: FilePath -> Action ()
    
    20
    +buildGhcInternalImportDef target = do
    
    21
    +    templateIn <- readFile' "rts/win32/libHSghc-internal.def.in"
    
    22
    +    let dllName = (dropExtension (takeFileName target)) <.> "dll"
    
    23
    +        templateOut = replace "@GhcInternalDll@" dllName templateIn
    
    24
    +    writeFile' target templateOut
    
    17 25
     
    
    18 26
     buildGhcInternalImportLib :: FilePath -> Action ()
    
    19 27
     buildGhcInternalImportLib target = do
    
    20
    -    let input  = "rts/win32/libHSghc-internal.def"
    
    28
    +    let input = dropExtensions target <.> "def" -- the .def file
    
    21 29
             output = target -- the .dll.a import lib
    
    22 30
         need [input]
    
    23 31
         runBuilder Dlltool ["-d", input, "-l", output] [input] [output]

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