Skip to content

Conversation

@mlugg
Copy link
Member

@mlugg mlugg commented Jan 1, 2025

Fixes a few bugs with incremental compilation. The first tripped an assert in some cases (although didn't actually affect ReleaseFast compilers in practice AFAICT), while the second was a much more significant bug. The bug in question was that while collecting error bundles, we corrupted the state of Zcu.failed_analysis on the false assumption that we would never use it again. That meant that when future incremental updates tried to remove elements from the map (because the corresponding AnalUnit was undergoing re-analysis), the error wasn't found by the lookup, causing it to persist forever.

@andrewrk, this bug absolutely explains why we have consistently been having issues with incremental compilation when trying to use -Dno-bin -fincremental --watch for e.g. big compiler changesets. Because of std.ArrayHashMapUnmanaged(...).linear_scan_max, this bug did not manifest on small test cases (i.e. every case in test/incremental/!), but did manifest very nastily once you exceeded 8 compile errors. After this is merged, I'd encourage you to give incremental another go!

@mlugg mlugg enabled auto-merge January 1, 2025 13:45
Previously, logic in `Compilation.getAllErrorsAlloc` was corrupting the
`failed_analysis` hashmap. This meant that on updates after the initial
update, attempts to remove entries from this map (because the `AnalUnit`
in question is being re-analyzed) silently failed. This resulted in
compile errors from earlier updates wrongly getting "stuck", i.e. never
being removed.

This commit also adds a few log calls which helped me to find this bug.
@mlugg mlugg force-pushed the incremental-fixes branch from 118b228 to f0d5e0d Compare January 1, 2025 15:49
@mlugg mlugg merged commit 0585ed0 into ziglang:master Jan 1, 2025
10 checks passed
@andrewrk
Copy link
Member

andrewrk commented Jan 1, 2025

Nice, looking forward to trying it out again :)

@mlugg mlugg deleted the incremental-fixes branch May 18, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants