From 27697d06aa68ac9322f8d85d5cc305825bf99a09 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sat, 31 Oct 2026 22:59:05 +0100 Subject: [PATCH] fix: recompile the units whose std module was rebuilt in place A .cpp unit's depfile listed its source and headers, never the BMIs it imports: clang's driver adds -module-file-deps to --precompile only. A std module rebuilt in its directory, which happens whenever its source changes under one compiler and one set of flags (a libc++ update, or mingw-w64's under the same prefix), left every object that imports it as it was, and the next build only relinked them. Implementation units are now compiled with -fmodule-file-deps, so the std PCM and the project's own PCMs are prerequisites of their objects like headers. Depfiles written before this lack the edge, so a std module that moves directories still needs VariantId to move with it (StdPcmKey). Co-Authored-By: Claude Opus 5.5 --- implementations/Crafter.Build-Implementation.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/implementations/Crafter.Build-Implementation.cpp b/implementations/Crafter.Build-Implementation.cpp index ca39bac..6f0b355 100644 --- a/implementations/Crafter.Build-Implementation.cpp +++ b/implementations/Crafter.Build-Implementation.cpp @@ -51,8 +51,13 @@ namespace Crafter { return; } - // -MD leaves _impl.o.d beside the object for Check to read. - std::string result = RunBuildCommand(std::format("{0} {1}.cpp -c -MD -MF {2}_impl.o.d -o {2}_impl.o", clang, path.string(), (buildDir/path.filename()).string())); + // -MD leaves _impl.o.d beside the object for Check to read, and + // -fmodule-file-deps puts the BMIs the unit imported in it with the + // headers. The driver adds that for --precompile only, so a std + // module rebuilt in place, for a mingw-w64 or libc++ update under + // the same compiler, left the objects importing it as they were, and + // the next build only relinked them. + std::string result = RunBuildCommand(std::format("{0} {1}.cpp -c -MD -MF {2}_impl.o.d -fmodule-file-deps -o {2}_impl.o", clang, path.string(), (buildDir/path.filename()).string())); bool expected = false; if(!result.empty() && buildCancelled.compare_exchange_strong(expected, true)) {