Commit 0e2d300a authored by Niklas Hambüchen's avatar Niklas Hambüchen Committed by Marge Bot
Browse files

compiler: Write .o files atomically. See #14533

This issue was reproduced with, and the fix confirmed with,
the `hatrace` tool for syscall-based fault injection:

The concrete test case for GHC is at

A previous, nondeterministic reproducer for the issue was provided by
Alexey Kuleshevich in

Signed-off-by: default avatarNiklas Hambüchen <>
Reviewed-by: default avatarAlexey Kuleshevich <>
parent 9db92cf0
......@@ -1375,7 +1375,12 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
liftIO $ debugTraceMsg dflags 4 (text "Running the assembler")
runAssembler input_fn output_fn
-- Atomic write by writing to temp file and then renaming
let temp_output_fn = output_fn <.> "tmp"
runAssembler input_fn temp_output_fn
liftIO $ renameFile temp_output_fn output_fn
return (RealPhase next_phase, output_fn)
  • I am fairly confident that this commit or the following commit regressed on Windows, which now fails during the compiler build with:

    C:\GitLabRunner\builds\28891e3c\0\ghc\ghc\tmp\ghcFD3.o.tmp: renameFile:renamePath:MoveFileEx "\\\\?\\C:\\GitLabRunner\\builds\\28891e3c\\0\\ghc\\ghc\\tmp\\ghcFD3.o.tmp" Just "\\\\?\\C:\\GitLabRunner\\builds\\28891e3c\\0\\ghc\\ghc\\tmp\\ghcFD3.o": does not exist (The system cannot find the file specified.)
    make[1]: *** [utils/hsc2hs/ utils/hsc2hs/dist-install/] Error 1

    I will revert this. @nh2, perhaps you would like to investigate?

    Edited by Ben Gamari
  • mentioned in commit 3533d498

    Toggle commit list
  • Reverting in !479 (closed) .

  • mentioned in commit 1bc298aa

    Toggle commit list
  • mentioned in commit e6ce1743

    Toggle commit list
  • mentioned in issue #14533

    Toggle commit list
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment