diff --git a/implementations/Crafter.Build-Clang.cpp b/implementations/Crafter.Build-Clang.cpp index e7e04a1..254a4e5 100644 --- a/implementations/Crafter.Build-Clang.cpp +++ b/implementations/Crafter.Build-Clang.cpp @@ -1142,12 +1142,14 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map fs::last_write_time(objPath))) { + // nvcc writes the depfile clang writes for a C source (-MD -MF): the + // .cu and every header it read, the toolkit's and the system's among + // them, as a Make rule NewestPrerequisite reads as it reads clang's, + // although nvcc puts a space before the colon. Without it, a .cu + // whose header changed kept its old object. cfg.cudaArch needs no + // check: it is part of VariantId, so another one builds in another + // directory. + if (!fs::exists(objPath) || (fs::exists(srcPath) && fs::last_write_time(srcPath) > fs::last_write_time(objPath)) || NewestPrerequisite(std::format("{}.d", objPath)) > fs::last_write_time(objPath)) { const Toolchain& toolchain = GetToolchain(); if (toolchain.nvcc.empty()) { bool expected = false; @@ -1160,7 +1162,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map