Improve error handling for back passes #2597
Merged
+155
−86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All user errors are, by design and definition, only in the front passes so during the last refactoring where those were broken out and run separately from the back passes, actually handling back passes were forgotten. The only errors from back passes are compilers bugs, so we don't pipe them through in such an elaborate way as for the front passes, but I pretty much forgot about them entirely with the consequence that we ended up completely burrying them. Not only that, but we counted any back jobs regardless of actual output result (success / done) as finished and so we moved on to the final zig build even when there were module failues in the back passes. That's fixed now.
We also saw weird failures with truncated files. This comes from an error in CodeGen ( on the solver-next branch ), since Haskell is lazy and CodeGen is the last pass, its output is lazyily streamed - actually pulled out by the file, and so when we encountered the error relatively late, we ended up with truncated output. This was visible both in the .c and with --cgen - we did get slightly different locations for the truncation which I believe is related to buffering by some block size.
Error are now properly surfaced and we don't proceed with futher compilation once we encounter errors in back passes. Files are also written atomically using a temporary file + rename, so we avoid torn files overall (even if the source reason in this case is fixed too).