From 58b960d2af0ebfc37104ec68a4df377a074951dd Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Mon, 19 Jul 2021 16:52:06 +0200 Subject: 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. --- compiler/GHC/Linker/ExtraObj.hs | 4 ++-- compiler/GHC/Linker/Loader.hs | 2 +- compiler/GHC/Linker/Static.hs | 2 +- compiler/GHC/Linker/Windows.hs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler/GHC/Linker') 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" -- cgit v1.2.1