diff options
author | Niklas Hambüchen <mail@nh2.me> | 2019-02-17 21:09:29 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-03-05 11:24:38 -0500 |
commit | ced9f3cf781e62d5becdbaf4fc57d65a9eaf1876 (patch) | |
tree | 30e3e603b5fe4945f8e0fc91e631e71bc1843f79 /compiler/main/DriverPipeline.hs | |
parent | c8f857ff01bd573f575a75620f084f64a6c1fa1d (diff) | |
download | haskell-wip/reapply-atomic-writes.tar.gz |
compiler: Refactor: extract `withAtomicRename`wip/reapply-atomic-writes
Diffstat (limited to 'compiler/main/DriverPipeline.hs')
-rw-r--r-- | compiler/main/DriverPipeline.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 3f59ed3bbf..f1ef637037 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1341,7 +1341,10 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags let local_includes = [ SysTools.Option ("-iquote" ++ p) | p <- includePathsQuote cmdline_include_paths ] let runAssembler inputFilename outputFilename - = liftIO $ as_prog dflags + = liftIO $ do + withAtomicRename outputFilename $ \temp_outputFilename -> do + as_prog + dflags (local_includes ++ global_includes -- See Note [-fPIC for assembler] ++ map SysTools.Option pic_c_flags @@ -1371,15 +1374,11 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags , SysTools.Option "-c" , SysTools.FileOption "" inputFilename , SysTools.Option "-o" - , SysTools.FileOption "" outputFilename + , SysTools.FileOption "" temp_outputFilename ]) liftIO $ debugTraceMsg dflags 4 (text "Running the assembler") - - -- 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 + runAssembler input_fn output_fn return (RealPhase next_phase, output_fn) |