Sven Tennie pushed to branch wip/supersven/libDir-setting at Glasgow Haskell Compiler / GHC

Commits:

7 changed files:

Changes:

  • compiler/GHC/Driver/Config/Interpreter.hs
    ... ... @@ -17,8 +17,8 @@ import System.Directory
    17 17
     
    
    18 18
     initInterpOpts :: DynFlags -> IO InterpOpts
    
    19 19
     initInterpOpts dflags = do
    
    20
    -  wasm_dyld <- makeAbsolute $ topDir dflags </> "dyld.mjs"
    
    21
    -  js_interp <- makeAbsolute $ topDir dflags </> "ghc-interp.js"
    
    20
    +  wasm_dyld <- makeAbsolute $ libDir dflags </> "dyld.mjs"
    
    21
    +  js_interp <- makeAbsolute $ libDir dflags </> "ghc-interp.js"
    
    22 22
       pure $ InterpOpts
    
    23 23
         { interpExternal = gopt Opt_ExternalInterpreter dflags
    
    24 24
         , interpProg = pgm_i dflags
    

  • compiler/GHC/Driver/DynFlags.hs
    ... ... @@ -60,7 +60,7 @@ module GHC.Driver.DynFlags (
    60 60
     
    
    61 61
             -- ** System tool settings and locations
    
    62 62
             programName, projectVersion,
    
    63
    -        ghcUsagePath, ghciUsagePath, topDir, toolDir,
    
    63
    +        ghcUsagePath, ghciUsagePath, topDir, libDir, toolDir,
    
    64 64
             versionedAppDir, versionedFilePath,
    
    65 65
             extraGccViaCFlags, globalPackageDatabasePath,
    
    66 66
     
    
    ... ... @@ -1508,6 +1508,8 @@ ghciUsagePath :: DynFlags -> FilePath
    1508 1508
     ghciUsagePath dflags = fileSettings_ghciUsagePath $ fileSettings dflags
    
    1509 1509
     topDir                :: DynFlags -> FilePath
    
    1510 1510
     topDir dflags = fileSettings_topDir $ fileSettings dflags
    
    1511
    +libDir                :: DynFlags -> FilePath
    
    1512
    +libDir dflags = fileSettings_libDir $ fileSettings dflags
    
    1511 1513
     toolDir               :: DynFlags -> Maybe FilePath
    
    1512 1514
     toolDir dflags = fileSettings_toolDir $ fileSettings dflags
    
    1513 1515
     extraGccViaCFlags     :: DynFlags -> [String]
    

  • compiler/GHC/Driver/Session.hs
    ... ... @@ -3650,7 +3650,6 @@ compilerInfo dflags
    3650 3650
            -- Whether or not GHC was compiled using -prof
    
    3651 3651
            ("GHC Profiled",                showBool hostIsProfiled),
    
    3652 3652
            ("Debug on",                    showBool debugIsOn),
    
    3653
    -       ("LibDir",                      topDir dflags),
    
    3654 3653
            -- This is always an absolute path, unlike "Relative Global Package DB" which is
    
    3655 3654
            -- in the settings file.
    
    3656 3655
            ("Global Package DB",           globalPackageDatabasePath dflags)
    

  • compiler/GHC/Settings.hs
    ... ... @@ -184,6 +184,7 @@ data FileSettings = FileSettings
    184 184
       , fileSettings_toolDir               :: Maybe FilePath -- ditto
    
    185 185
       , fileSettings_topDir                :: FilePath       -- ditto
    
    186 186
       , fileSettings_globalPackageDatabase :: FilePath
    
    187
    +  , fileSettings_libDir                :: FilePath
    
    187 188
       }
    
    188 189
     
    
    189 190
     
    

  • compiler/GHC/Settings/IO.hs
    ... ... @@ -148,6 +148,8 @@ initSettings top_dir = do
    148 148
     
    
    149 149
       baseUnitId <- getSetting_raw "base unit-id"
    
    150 150
     
    
    151
    +  lib_dir <- getSetting "LibDir"
    
    152
    +
    
    151 153
       return $ Settings
    
    152 154
         { sGhcNameVersion = GhcNameVersion
    
    153 155
           { ghcNameVersion_programName = "ghc"
    
    ... ... @@ -159,6 +161,7 @@ initSettings top_dir = do
    159 161
           , fileSettings_ghciUsagePath  = ghci_usage_msg_path
    
    160 162
           , fileSettings_toolDir        = mtool_dir
    
    161 163
           , fileSettings_topDir         = top_dir
    
    164
    +      , fileSettings_libDir         = lib_dir
    
    162 165
           , fileSettings_globalPackageDatabase = globalpkgdb_path
    
    163 166
           }
    
    164 167
     
    

  • hadrian/bindist/Makefile
    ... ... @@ -90,6 +90,7 @@ lib/settings : config.mk
    90 90
     	@echo ',("RTS ways", "$(GhcRTSWays)")' >> $@
    
    91 91
     	@echo ',("Relative Global Package DB", "package.conf.d")' >> $@
    
    92 92
     	@echo ',("base unit-id", "$(BaseUnitId)")' >> $@
    
    93
    +	@echo ',("LibDir", "$$topdir")' >> $@
    
    93 94
     	@echo "]" >> $@
    
    94 95
     
    
    95 96
     lib/targets/default.target : config.mk default.target
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -25,6 +25,7 @@ import Utilities
    25 25
     import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp))
    
    26 26
     import GHC.Platform.ArchOS
    
    27 27
     import Settings.Program (ghcWithInterpreter)
    
    28
    +import Hadrian.Oracles.Path
    
    28 29
     
    
    29 30
     -- | Track this file to rebuild generated files whenever it changes.
    
    30 31
     trackGenerateHs :: Expr ()
    
    ... ... @@ -476,6 +477,16 @@ generateSettings settingsFile = do
    476 477
             Stage3 -> pkgUnitId Stage2 base
    
    477 478
     
    
    478 479
         let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path
    
    480
    +        make_absolute rel_path = do
    
    481
    +          abs_path <- liftIO (makeAbsolute rel_path)
    
    482
    +          fixAbsolutePathOnWindows abs_path
    
    483
    +
    
    484
    +        -- E.g. the Stage2 compiler lives in _build/stage1
    
    485
    +        -- So, we need to decrement the stage to get the correct directory
    
    486
    +        stage_dir_stage = predStage stage
    
    487
    +
    
    488
    +    rel_lib_topDir :: FilePath <- expr $ stageLibPath stage_dir_stage
    
    489
    +    lib_topDir :: FilePath <- expr $ make_absolute rel_lib_topDir
    
    479 490
     
    
    480 491
         settings <- traverse sequence $
    
    481 492
             [ ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
    
    ... ... @@ -483,6 +494,7 @@ generateSettings settingsFile = do
    483 494
             , ("RTS ways", escapeArgs . map show . Set.toList <$> getRtsWays)
    
    484 495
             , ("Relative Global Package DB", pure rel_pkg_db)
    
    485 496
             , ("base unit-id", pure base_unit_id)
    
    497
    +        , ("LibDir", pure lib_topDir)
    
    486 498
             ]
    
    487 499
         let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")"
    
    488 500
         pure $ case settings of