diff options
author | Alp Mestanogullari <alp@well-typed.com> | 2018-05-12 08:36:19 +0100 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2018-05-12 09:10:26 +0100 |
commit | 37810347dfeda977e7036cf8bc87ba079f094baa (patch) | |
tree | 62d5e8ef0befc1ba699134b0327d6db5630cf39b | |
parent | cb5c2fe875965b7aedbc189012803fc62e48fb3f (diff) | |
download | haskell-37810347dfeda977e7036cf8bc87ba079f094baa.tar.gz |
Expand $tooldir in ghc --info output
Summary:
This requires adding an `sToolDir :: Maybe FilePath` field to Settings, since
compilerInfo is pure and therefore needs to have all the information
available in the DynFlags.
This should fix #15101 and #15107.
Test Plan: ./validate --fast
Reviewers: Phyx, bgamari
Reviewed By: Phyx
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #15101, #15107
Differential Revision: https://phabricator.haskell.org/D4686
-rw-r--r-- | compiler/main/DynFlags.hs | 18 | ||||
-rw-r--r-- | compiler/main/SysTools.hs | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 6bfa8f2955..bd3e2a087a 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -206,7 +206,7 @@ import {-# SOURCE #-} ErrUtils ( Severity(..), MsgDoc, mkLocMessageAnn , getCaretDiagnostic, dumpSDoc ) import Json import SysTools.Terminal ( stderrSupportsAnsiColors ) -import SysTools.BaseDir ( expandTopDir ) +import SysTools.BaseDir ( expandToolDir, expandTopDir ) import System.IO.Unsafe ( unsafePerformIO ) import Data.IORef @@ -1148,10 +1148,11 @@ data LlvmTarget = LlvmTarget type LlvmTargets = [(String, LlvmTarget)] data Settings = Settings { - sTargetPlatform :: Platform, -- Filled in by SysTools - sGhcUsagePath :: FilePath, -- Filled in by SysTools - sGhciUsagePath :: FilePath, -- ditto - sTopDir :: FilePath, + sTargetPlatform :: Platform, -- Filled in by SysTools + sGhcUsagePath :: FilePath, -- ditto + sGhciUsagePath :: FilePath, -- ditto + sToolDir :: Maybe FilePath, -- ditto + sTopDir :: FilePath, -- ditto sTmpDir :: String, -- no trailing '/' sProgramName :: String, sProjectVersion :: String, @@ -1211,6 +1212,8 @@ ghcUsagePath :: DynFlags -> FilePath ghcUsagePath dflags = sGhcUsagePath (settings dflags) ghciUsagePath :: DynFlags -> FilePath ghciUsagePath dflags = sGhciUsagePath (settings dflags) +toolDir :: DynFlags -> Maybe FilePath +toolDir dflags = sToolDir (settings dflags) topDir :: DynFlags -> FilePath topDir dflags = sTopDir (settings dflags) tmpDir :: DynFlags -> String @@ -5301,7 +5304,8 @@ compilerInfo dflags -- Next come the settings, so anything else can be overridden -- in the settings file (as "lookup" uses the first match for the -- key) - : map (fmap $ expandTopDir $ topDir dflags) (rawSettings dflags) + : map (fmap $ expandDirectories (topDir dflags) (toolDir dflags)) + (rawSettings dflags) ++ [("Project version", projectVersion dflags), ("Project Git commit id", cProjectGitCommitId), ("Booter version", cBooterVersion), @@ -5352,6 +5356,8 @@ compilerInfo dflags showBool True = "YES" showBool False = "NO" isWindows = platformOS (targetPlatform dflags) == OSMinGW32 + expandDirectories :: FilePath -> Maybe FilePath -> String -> String + expandDirectories topd mtoold = expandToolDir mtoold . expandTopDir topd -- Produced by deriveConstants #include "GHCConstantsHaskellWrappers.hs" diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index baf70df8a9..619e0b65e7 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -277,6 +277,7 @@ initSysTools mbMinusB sTmpDir = normalise tmpdir, sGhcUsagePath = ghc_usage_msg_path, sGhciUsagePath = ghci_usage_msg_path, + sToolDir = mtool_dir, sTopDir = top_dir, sRawSettings = mySettings, sExtraGccViaCFlags = words myExtraGccViaCFlags, |