diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2015-06-02 16:12:43 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-06-02 16:12:56 -0500 |
commit | 7a82b77691fb90c4af6863673f10e454a449739e (patch) | |
tree | 47f60a4b0b76e3149750b1a699cdd8686b2ad442 | |
parent | 942a074ccb441320daae74fadf37b44e636dc102 (diff) | |
download | haskell-7a82b77691fb90c4af6863673f10e454a449739e.tar.gz |
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
-rw-r--r-- | compiler/main/SysTools.hs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index d47925e0c8..0b9537f1a0 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 |