diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-03-16 08:57:43 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-03-16 19:13:36 -0400 |
commit | 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb (patch) | |
tree | 51b6a9816759451740484cf04fe8794e79a9408d | |
parent | 600a1ac3829c2b216d2cc23a1e8256841ffe6466 (diff) | |
download | haskell-1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb.tar.gz |
compiler: Disable atomic renaming on Windows
As discussed in #16450, this feature regresses CI on Windows, causing
non-deterministic failures due to missing files.
-rw-r--r-- | compiler/utils/Util.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs index 41f63f2246..673088159f 100644 --- a/compiler/utils/Util.hs +++ b/compiler/utils/Util.hs @@ -1314,7 +1314,8 @@ modificationTimeIfExists f = do -- also results in a skip. withAtomicRename :: (MonadIO m) => FilePath -> (FilePath -> m a) -> m a -withAtomicRename targetFile f = do +withAtomicRename targetFile f + | enableAtomicRename = do -- The temp file must be on the same file system (mount) as the target file -- to result in an atomic move on most platforms. -- The standard way to ensure that is to place it into the same directory. @@ -1325,6 +1326,17 @@ withAtomicRename targetFile f = do liftIO $ renameFile temp targetFile return res + | otherwise = f targetFile + where + -- As described in #16450, enabling this causes spurious build failures due + -- to apparently missing files. + enableAtomicRename :: Bool +#if defined(mingw32_BUILD_OS) + enableAtomicRename = False +#else + enableAtomicRename = True +#endif + -- -------------------------------------------------------------- -- split a string at the last character where 'pred' is True, -- returning a pair of strings. The first component holds the string |