[Pkg-haskell-commits] darcs: ghc: Another stab at making GHC more reproducible: Use a hash of the command line instead of the pid when calculating a "random" directory name.

Joachim Breitner mail at joachim-breitner.de
Sat Jun 27 12:39:59 UTC 2015


Sun Jun  7 14:21:33 UTC 2015  Joachim Breitner <mail at joachim-breitner.de>
  * Another stab at making GHC more reproducible: Use a hash of the command line instead of the pid when calculating a "random" directory name.

    M ./changelog +7
    M ./patches/reproducible-tmp-names -3 +37

Sun Jun  7 14:21:33 UTC 2015  Joachim Breitner <mail at joachim-breitner.de>
  * Another stab at making GHC more reproducible: Use a hash of the command line instead of the pid when calculating a "random" directory name.
diff -rN -u old-ghc/changelog new-ghc/changelog
--- old-ghc/changelog	2015-06-27 12:39:59.617429757 +0000
+++ new-ghc/changelog	2015-06-27 12:39:59.645429761 +0000
@@ -1,3 +1,10 @@
+ghc (7.8.4-9) UNRELEASED; urgency=medium
+
+  * Another stab at making GHC more reproducible: Use a hash of the command
+    line instead of the pid when calculating a "random" directory name.
+
+ -- Joachim Breitner <nomeata at debian.org>  Sun, 07 Jun 2015 16:20:50 +0200
+
 ghc (7.8.4-8) unstable; urgency=medium
 
   * debian/patches/stable-specialization-rule-names: Root out another cause of
diff -rN -u old-ghc/patches/reproducible-tmp-names new-ghc/patches/reproducible-tmp-names
--- old-ghc/patches/reproducible-tmp-names	2015-06-27 12:39:59.617429757 +0000
+++ new-ghc/patches/reproducible-tmp-names	2015-06-27 12:39:59.637429759 +0000
@@ -6,9 +6,17 @@
 
 Index: ghc-7.8.4/compiler/main/SysTools.lhs
 ===================================================================
---- ghc-7.8.4.orig/compiler/main/SysTools.lhs	2015-05-25 11:05:18.028939756 +0200
-+++ ghc-7.8.4/compiler/main/SysTools.lhs	2015-05-25 11:05:18.028939756 +0200
-@@ -1011,8 +1011,7 @@
+--- ghc-7.8.4.orig/compiler/main/SysTools.lhs	2014-12-19 16:35:34.000000000 +0100
++++ ghc-7.8.4/compiler/main/SysTools.lhs	2015-06-07 16:20:31.875021456 +0200
+@@ -58,6 +58,7 @@
+ import Util
+ import DynFlags
+ import Exception
++import Fingerprint
+ 
+ import Data.IORef
+ import Control.Monad
+@@ -1011,8 +1012,7 @@
  newTempName :: DynFlags -> Suffix -> IO FilePath
  newTempName dflags extn
    = do d <- getTempDir dflags
@@ -18,3 +26,29 @@
    where
      findTempName :: FilePath -> IO FilePath
      findTempName prefix
+@@ -1031,8 +1031,8 @@
+     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
+@@ -1347,6 +1347,14 @@
+ 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]




More information about the Pkg-haskell-commits mailing list