From 18a2e2883ff054fe1ca11d976cc2c2ec660c92e4 Mon Sep 17 00:00:00 2001 From: Debian Haskell Group Date: Fri, 30 Dec 2016 02:30:41 +0000 Subject: [PATCH] reproducible-tmp-names This is an attempt to make GHC build reproducible. The name of .c files may end up in the resulting binary (in the debug section), but not the directory. Instead of using the process id, create a hash from the command line arguments, and assume that is going to be unique. Gbp-Pq: Name reproducible-tmp-names --- compiler/main/SysTools.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index 9423b002..ed44b102 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -65,6 +65,7 @@ import Platform import Util import DynFlags import Exception +import Fingerprint import LlvmCodeGen.Base (llvmVersionStr, supportedLlvmVersion) @@ -1158,8 +1159,8 @@ getTempDir dflags = do mapping <- readIORef dir_ref case Map.lookup tmp_dir mapping of Nothing -> do - pid <- getProcessID - let prefix = tmp_dir "ghc" ++ show pid ++ "_" + pid <- getStableProcessID + let prefix = tmp_dir "ghc" ++ pid ++ "_" mask_ $ mkTempDir prefix Just dir -> return dir where @@ -1575,6 +1576,13 @@ getProcessID :: IO Int getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral #endif +-- Debian-specific hack to get reproducible output, by not using the "random" +-- pid, but rather something determinisic +getStableProcessID :: IO String +getStableProcessID = do + args <- getArgs + return $ take 4 $ show $ fingerprintString $ unwords args + -- Divvy up text stream into lines, taking platform dependent -- line termination into account. linesPlatform :: String -> [String] -- 2.30.2