summaryrefslogtreecommitdiff
path: root/compiler/GHC/Linker
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-07-19 16:52:06 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-19 19:38:59 -0400
commit58b960d2af0ebfc37104ec68a4df377a074951dd (patch)
treef0fc5bf672f76ec4f032a07d8d292fb1a6eaddb1 /compiler/GHC/Linker
parent535123e4f6505a148ccaa536c21282a87c42669c (diff)
downloadhaskell-58b960d2af0ebfc37104ec68a4df377a074951dd.tar.gz
Make TmpFs independent of DynFlags
This is small step towards #19877. We want to make the Loader/Linker interface more abstract to be easily reused (i.e. don't pass it DynFlags) but the system linker uses TmpFs which required a DynFlags value to get its temp directory. We explicitly pass the temp directory now. Similarly TmpFs was consulting the DynFlags to decide whether to clean or: this is now done by the caller in the driver code.
Diffstat (limited to 'compiler/GHC/Linker')
-rw-r--r--compiler/GHC/Linker/ExtraObj.hs4
-rw-r--r--compiler/GHC/Linker/Loader.hs2
-rw-r--r--compiler/GHC/Linker/Static.hs2
-rw-r--r--compiler/GHC/Linker/Windows.hs4
4 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/Linker/ExtraObj.hs b/compiler/GHC/Linker/ExtraObj.hs
index 1bc4f4234b..163bccf3fe 100644
--- a/compiler/GHC/Linker/ExtraObj.hs
+++ b/compiler/GHC/Linker/ExtraObj.hs
@@ -49,8 +49,8 @@ import Data.Maybe
mkExtraObj :: Logger -> TmpFs -> DynFlags -> UnitState -> Suffix -> String -> IO FilePath
mkExtraObj logger tmpfs dflags unit_state extn xs
- = do cFile <- newTempName logger tmpfs dflags TFL_CurrentModule extn
- oFile <- newTempName logger tmpfs dflags TFL_GhcSession "o"
+ = do cFile <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule extn
+ oFile <- newTempName logger tmpfs (tmpDir dflags) TFL_GhcSession "o"
writeFile cFile xs
ccInfo <- liftIO $ getCompilerInfo logger dflags
runCc Nothing logger tmpfs dflags
diff --git a/compiler/GHC/Linker/Loader.hs b/compiler/GHC/Linker/Loader.hs
index 832d2b0cfd..68484eb288 100644
--- a/compiler/GHC/Linker/Loader.hs
+++ b/compiler/GHC/Linker/Loader.hs
@@ -952,7 +952,7 @@ dynLoadObjs interp hsc_env pls@LoaderState{..} objs = do
let minus_ls = [ lib | Option ('-':'l':lib) <- ldInputs dflags ]
let minus_big_ls = [ lib | Option ('-':'L':lib) <- ldInputs dflags ]
(soFile, libPath , libName) <-
- newTempLibName logger tmpfs dflags TFL_CurrentModule (platformSOExt platform)
+ newTempLibName logger tmpfs (tmpDir dflags) TFL_CurrentModule (platformSOExt platform)
let
dflags2 = dflags {
-- We don't want the original ldInputs in
diff --git a/compiler/GHC/Linker/Static.hs b/compiler/GHC/Linker/Static.hs
index cfb83f0575..ae7a334f98 100644
--- a/compiler/GHC/Linker/Static.hs
+++ b/compiler/GHC/Linker/Static.hs
@@ -123,7 +123,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
if gopt Opt_SingleLibFolder dflags
then do
libs <- getLibs dflags unit_env dep_units
- tmpDir <- newTempDir logger tmpfs dflags
+ tmpDir <- newTempDir logger tmpfs (tmpDir dflags)
sequence_ [ copyFile lib (tmpDir </> basename)
| (lib, basename) <- libs]
return [ "-L" ++ tmpDir ]
diff --git a/compiler/GHC/Linker/Windows.hs b/compiler/GHC/Linker/Windows.hs
index 8be0802002..a791cdf007 100644
--- a/compiler/GHC/Linker/Windows.hs
+++ b/compiler/GHC/Linker/Windows.hs
@@ -45,9 +45,9 @@ maybeCreateManifest logger tmpfs dflags exe_filename = do
if not (gopt Opt_EmbedManifest dflags)
then return []
else do
- rc_filename <- newTempName logger tmpfs dflags TFL_CurrentModule "rc"
+ rc_filename <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "rc"
rc_obj_filename <-
- newTempName logger tmpfs dflags TFL_GhcSession (objectSuf dflags)
+ newTempName logger tmpfs (tmpDir dflags) TFL_GhcSession (objectSuf dflags)
writeFile rc_filename $
"1 24 MOVEABLE PURE " ++ show manifest_filename ++ "\n"