[commit: ghc] master: newTempName: Do not include pid in basename (7a82b77)
git at git.haskell.org
git at git.haskell.org
Tue Jun 2 21:15:33 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/7a82b77691fb90c4af6863673f10e454a449739e/ghc
>---------------------------------------------------------------
commit 7a82b77691fb90c4af6863673f10e454a449739e
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Tue Jun 2 16:12:43 2015 -0500
newTempName: Do not include pid in basename
The filename of temporary files, especially the basename of C files, can
end up in the output in some form, e.g. as part of linker debug
information. In the interest of bit-wise exactly reproducible
compilation (#4012), the basename of the temporary file no longer
contains random information (it used to ontain the process id).
This is ok, as the temporary directory used contains the pid (see
getTempDir).
This patch has been applied to the Debian package (version 7.10.1-5) and
allowed a fully bit-wise reproducible build:
https://reproducible.debian.net/rb-pkg/experimental/amd64/ghc.html
Reviewed By: austin, rwbarton
Differential Revision: https://phabricator.haskell.org/D910
GHC Trac Issues: #4012
>---------------------------------------------------------------
7a82b77691fb90c4af6863673f10e454a449739e
compiler/main/SysTools.hs | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index d47925e..0b9537f 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -1083,8 +1083,7 @@ newTempSuffix dflags = atomicModifyIORef' (nextTempSuffix dflags) $ \n -> (n+1,n
newTempName :: DynFlags -> Suffix -> IO FilePath
newTempName dflags extn
= do d <- getTempDir dflags
- x <- getProcessID
- findTempName (d </> "ghc" ++ show x ++ "_")
+ findTempName (d </> "ghc_") -- See Note [Deterministic base name]
where
findTempName :: FilePath -> IO FilePath
findTempName prefix
@@ -1099,12 +1098,11 @@ newTempName dflags extn
newTempLibName :: DynFlags -> Suffix -> IO (FilePath, FilePath, String)
newTempLibName dflags extn
= do d <- getTempDir dflags
- x <- getProcessID
- findTempName d ("ghc" ++ show x ++ "_")
+ findTempName d ("ghc_")
where
findTempName :: FilePath -> String -> IO (FilePath, FilePath, String)
findTempName dir prefix
- = do n <- newTempSuffix dflags
+ = do n <- newTempSuffix dflags -- See Note [Deterministic base name]
let libname = prefix ++ show n
filename = dir </> "lib" ++ libname <.> extn
b <- doesFileExist filename
@@ -1157,6 +1155,17 @@ getTempDir dflags = do
`catchIO` \e -> if isAlreadyExistsError e
then mkTempDir prefix else ioError e
+-- Note [Deterministic base name]
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+--
+-- The filename of temporary files, especially the basename of C files, can end
+-- up in the output in some form, e.g. as part of linker debug information. In the
+-- interest of bit-wise exactly reproducible compilation (#4012), the basename of
+-- the temporary file no longer contains random information (it used to contain
+-- the process id).
+--
+-- This is ok, as the temporary directory used contains the pid (see getTempDir).
+
addFilesToClean :: DynFlags -> [FilePath] -> IO ()
-- May include wildcards [used by DriverPipeline.run_phase SplitMangle]
addFilesToClean dflags new_files
More information about the ghc-commits
mailing list