fixed build error and file stdpcm lock

This commit is contained in:
Jorijn van der Graaf 2026-05-30 19:28:06 +02:00
commit 47cd50a7d2
2 changed files with 77 additions and 106 deletions

View file

@ -9,9 +9,10 @@ using namespace Crafter;
// clobber each other's writes to `<cache>/<target>-<march>/std.pcm` and the
// `Crafter.Build-*.pcm` host modules. The loser's clang would then read a
// torn file via -fprebuilt-module-path and die with "malformed or corrupted
// precompiled file: 'can't skip to bit X from Y'". The fix routes every PCM
// write through a per-process temp + atomic rename so a reader always sees
// either the old or the new file, never a half-written one.
// precompiled file: 'can't skip to bit X from Y'". The fix serializes PCM
// (re)builds through an exclusive advisory lock on the cache dir: only one
// builder precompiles while the rest wait and then reuse the finished file, so
// no two writers ever touch the same path and a reader never sees a torn one.
//
// LoadProject() is the right surface to test because it runs the full host
// bootstrap (BuildStdPcm + EnsureCrafterBuildPcms × the Crafter.Build-*