newTempName: instead of bumping the processId until we find a name
that isn't used, add an integer suffix to the processId. This should
prevent temp-file conflicts that appear to have been affecting our
nightly builds and occasionally make -j.
The right way to allocate a temporary file is to create it straight
away, but I'm not sure of the implications of passing existing
temporary files to the various sub-processes that GHC executes, hence
this fix instead.
newTempName :: DynFlags -> Suffix -> IO FilePath
newTempName DynFlags{tmpDir=tmp_dir} extn
= do x <- getProcessID
- findTempName tmp_dir x
+ findTempName (tmp_dir ++ "/ghc" ++ show x ++ "_") 0
where
- findTempName tmp_dir x
- = do let filename = tmp_dir ++ "/ghc" ++ show x ++ '.':extn
+ findTempName prefix x
+ = do let filename = prefix ++ show x ++ '.':extn
b <- doesFileExist filename
- if b then findTempName tmp_dir (x+1)
+ if b then findTempName prefix (x+1)
else do consIORef v_FilesToClean filename -- clean it up later
return filename