summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-08-03 11:21:06 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-08-03 17:21:07 -0400
commit4f6726779fa3cbbfe97de49b1d26d5a665c74840 (patch)
tree56da11f35cbc1dc155863b81bd29d49a25158467
parent6ad25367fbd44579591e3c287ea88db618d57891 (diff)
downloadhaskell-4f6726779fa3cbbfe97de49b1d26d5a665c74840.tar.gz
Don't store tmpDir in Settings
There was no point in doing this as indicated by the TODO.
-rw-r--r--compiler/GHC/Driver/Session.hs16
-rw-r--r--compiler/GHC/Settings.hs4
-rw-r--r--compiler/GHC/Settings/IO.hs7
3 files changed, 9 insertions, 18 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index ffb9108723..33c0fbe4cc 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -83,7 +83,6 @@ module GHC.Driver.Session (
sGhciUsagePath,
sToolDir,
sTopDir,
- sTmpDir,
sGlobalPackageDatabasePath,
sLdSupportsCompactUnwind,
sLdSupportsBuildId,
@@ -133,7 +132,7 @@ module GHC.Driver.Session (
PlatformMisc(..),
settings,
programName, projectVersion,
- ghcUsagePath, ghciUsagePath, topDir, tmpDir,
+ ghcUsagePath, ghciUsagePath, topDir,
versionedAppDir, versionedFilePath,
extraGccViaCFlags, globalPackageDatabasePath,
pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T,
@@ -444,6 +443,7 @@ data DynFlags = DynFlags {
toolSettings :: {-# UNPACK #-} !ToolSettings,
platformMisc :: {-# UNPACK #-} !PlatformMisc,
rawSettings :: [(String, String)],
+ tmpDir :: TempDir,
llvmConfig :: LlvmConfig,
-- ^ N.B. It's important that this field is lazy since we load the LLVM
@@ -792,8 +792,6 @@ toolDir :: DynFlags -> Maybe FilePath
toolDir dflags = fileSettings_toolDir $ fileSettings dflags
topDir :: DynFlags -> FilePath
topDir dflags = fileSettings_topDir $ fileSettings dflags
-tmpDir :: DynFlags -> TempDir
-tmpDir dflags = TempDir (fileSettings_tmpDir $ fileSettings dflags)
extraGccViaCFlags :: DynFlags -> [String]
extraGccViaCFlags dflags = toolSettings_extraGccViaCFlags $ toolSettings dflags
globalPackageDatabasePath :: DynFlags -> FilePath
@@ -1096,6 +1094,7 @@ initDynFlags dflags = do
let (useColor', colScheme') =
(adjustCols maybeGhcColoursEnv . adjustCols maybeGhcColorsEnv)
(useColor dflags, colScheme dflags)
+ tmp_dir <- normalise <$> getTemporaryDirectory
return dflags{
dynamicTooFailed = refDynamicTooFailed,
useUnicode = useUnicode',
@@ -1104,7 +1103,8 @@ initDynFlags dflags = do
colScheme = colScheme',
rtldInfo = refRtldInfo,
rtccInfo = refRtccInfo,
- rtasmInfo = refRtasmInfo
+ rtasmInfo = refRtasmInfo,
+ tmpDir = TempDir tmp_dir
}
-- | The normal 'DynFlags'. Note that they are not suitable for use in this form
@@ -1212,6 +1212,8 @@ defaultDynFlags mySettings llvmConfig =
platformMisc = sPlatformMisc mySettings,
rawSettings = sRawSettings mySettings,
+ tmpDir = panic "defaultDynFlags: uninitialized tmpDir",
+
-- See Note [LLVM configuration].
llvmConfig = llvmConfig,
@@ -4117,8 +4119,6 @@ unSetExtensionFlag' f dflags = xopt_unset dflags f
-- (except for -fno-glasgow-exts, which is treated specially)
--------------------------
-alterFileSettings :: (FileSettings -> FileSettings) -> DynFlags -> DynFlags
-alterFileSettings f dynFlags = dynFlags { fileSettings = f (fileSettings dynFlags) }
alterToolSettings :: (ToolSettings -> ToolSettings) -> DynFlags -> DynFlags
alterToolSettings f dynFlags = dynFlags { toolSettings = f (toolSettings dynFlags) }
@@ -4412,7 +4412,7 @@ splitPathList s = filter notNull (splitUp s)
-- tmpDir, where we store temporary files.
setTmpDir :: FilePath -> DynFlags -> DynFlags
-setTmpDir dir = alterFileSettings $ \s -> s { fileSettings_tmpDir = normalise dir }
+setTmpDir dir d = d { tmpDir = TempDir (normalise dir) }
-- we used to fix /cygdrive/c/.. on Windows, but this doesn't
-- seem necessary now --SDM 7/2/2008
diff --git a/compiler/GHC/Settings.hs b/compiler/GHC/Settings.hs
index c7c98e1755..f86fd9641d 100644
--- a/compiler/GHC/Settings.hs
+++ b/compiler/GHC/Settings.hs
@@ -16,7 +16,6 @@ module GHC.Settings
, sGhciUsagePath
, sToolDir
, sTopDir
- , sTmpDir
, sGlobalPackageDatabasePath
, sLdSupportsCompactUnwind
, sLdSupportsBuildId
@@ -151,7 +150,6 @@ data FileSettings = FileSettings
, fileSettings_ghciUsagePath :: FilePath -- ditto
, fileSettings_toolDir :: Maybe FilePath -- ditto
, fileSettings_topDir :: FilePath -- ditto
- , fileSettings_tmpDir :: String -- no trailing '/'
, fileSettings_globalPackageDatabase :: FilePath
}
@@ -182,8 +180,6 @@ sToolDir :: Settings -> Maybe FilePath
sToolDir = fileSettings_toolDir . sFileSettings
sTopDir :: Settings -> FilePath
sTopDir = fileSettings_topDir . sFileSettings
-sTmpDir :: Settings -> String
-sTmpDir = fileSettings_tmpDir . sFileSettings
sGlobalPackageDatabasePath :: Settings -> FilePath
sGlobalPackageDatabasePath = fileSettings_globalPackageDatabase . sFileSettings
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs
index a6af6ae58c..3c4e012675 100644
--- a/compiler/GHC/Settings/IO.hs
+++ b/compiler/GHC/Settings/IO.hs
@@ -111,10 +111,6 @@ initSettings top_dir = do
install_name_tool_path <- getToolSetting "install_name_tool command"
ranlib_path <- getToolSetting "ranlib command"
- -- TODO this side-effect doesn't belong here. Reading and parsing the settings
- -- should be idempotent and accumulate no resources.
- tmpdir <- liftIO $ getTemporaryDirectory
-
touch_path <- getToolSetting "touch command"
mkdll_prog <- getToolSetting "dllwrap command"
@@ -156,8 +152,7 @@ initSettings top_dir = do
}
, sFileSettings = FileSettings
- { fileSettings_tmpDir = normalise tmpdir
- , fileSettings_ghcUsagePath = ghc_usage_msg_path
+ { fileSettings_ghcUsagePath = ghc_usage_msg_path
, fileSettings_ghciUsagePath = ghci_usage_msg_path
, fileSettings_toolDir = mtool_dir
, fileSettings_topDir = top_dir