Skip to content

Ctrl-c during build produces *some* outputs for a file, and GHC --make fails handling this

This is a minor issue, but after I interrupted and restarted stack build --ghc-options=-j3 (went from stack build to stack build --ghc-options=-j2 to -j3), I ended up with a build that did not complete.

clang: error: no such file or directory: '.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Agda/TypeChecking/SizedTypes.dyn_o'

Doing stack build again did not fix the issue. I assume this is due to the underlying ghc --make.

Apparently, only some of the compiled output files were written, not all (see below), but GHC (I guess) assumes they're created atomically. Worse, the .dyn_hi variant existed but .dyn_o was missing. After removing all of them, restarting the build completed successfully.

Fixes could include creating the files atomically or assuming that might not happen; since creating multiple files together atomically is impossible (the rename trick doesn't handle this, even ignoring its limitations), the 2nd option appears more sensible.

While this was easy for me, most compilers avoid this, and I'm sure some users would be a bit more confused in this scenario—it's easy to imagine this happening to students.

Listing of relevant build products:

$ ls .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Agda/TypeChecking/SizedTypes.*
.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Agda/TypeChecking/SizedTypes.dyn_hi
.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Agda/TypeChecking/SizedTypes.hi
.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Agda/TypeChecking/SizedTypes.o
Trac metadata
Trac field Value
Version 7.10.3
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Driver
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information