fix(incremental): relink when a C or CUDA object is rebuilt

The C compile loop sets no repack flag, and the "is any object newer than
the archive" sweep only walked interfaces and implementations. So editing
a .c recompiled its object and then linked nothing: the archive and the
executable kept the previous one. Surfaced by the header-change test,
where a rebuilt counter.c produced a binary still printing the old value.
This commit is contained in:
catbot 2026-07-31 11:11:44 +00:00
commit f66120a8eb

View file

@ -1109,6 +1109,21 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
}
}
}
// C and CUDA objects are archive members too, and their compile
// loop above is the only thing that knows it rebuilt one — it
// sets no repack flag, so without this a .c edit recompiled the
// object and then linked nothing.
if (!buildResult.repack) {
auto sourceObjNewer = [&](const std::vector<fs::path>& sources) {
for (const fs::path& source : sources) {
if (objNewer(buildDir / std::format("{}_source.o", source.filename().string()))) return true;
}
return false;
};
if (sourceObjNewer(config.cFiles) || sourceObjNewer(config.cuda)) {
buildResult.repack = true;
}
}
}
}
}