snowleopard / hadrian

Hadrian: a new build system for the Glasgow Haskell Compiler. Now merged into the GHC tree!
https://gitlab.haskell.org/ghc/ghc/tree/master/hadrian
MIT License
208 stars 37 forks source link

Hadrian does not fail gracefully if it cannot read its state #462

Closed duog closed 6 years ago

duog commented 6 years ago

I accidentally tried to build ghc with a four month old version of hadrian.

Realising my mistake, I updated the source and build again, and was confronted by this error:

Data.Binary.Get.runGet at position 46: Unknown encoding for constructor
CallStack (from HasCallStack):
  error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.5.1:Data.Binary.Get

hadrian/build.sh clean did not fix it. removing _build did fix it.

snowleopard commented 6 years ago

@duog Thanks for the report.

hadrian/build.sh clean did not fix it.

Do you mean Hadrian failed with the same error when run with the clean target? If yes, this looks like a general Shake issue. Shake should be able to deal with an outdated database more gracefully.

@ndmitchell Do you agree this is a Shake issue or is there a simple workaround we can add to Hadrian?

ndmitchell commented 6 years ago

Shake should deal with a corrupted database more gracefully... it might need a seq somewhere to force database reading errors to occur correctly.

ndmitchell commented 6 years ago

I added a seq and a bunch of tests. In particular 397539066a0acd6d4d6558028559147eed5a0e53 fixes the bug, while 7c9b7623eca4a1680b32715d849c13b5b59da102 tests all the places binary serialisation could go wrong, and critically checks that a top-level phony will still run in all cases (so clean works). Will be in the next Shake release, although doesn't seem critical at the moment.

snowleopard commented 6 years ago

Awesome, thanks @ndmitchell!