test(cuda): a changed header compiles the .cu again
CudaCompile's .cu includes a header of its own now. After the unchanged build, the test makes the header newer than the object and builds once more, which has to run nvcc again. Before nvcc wrote a depfile, it did not, and the object built from the old header stayed.
This commit is contained in:
parent
c2338d1122
commit
6b2da3b1d6
3 changed files with 21 additions and 4 deletions
|
|
@ -18,9 +18,11 @@ using namespace Crafter;
|
|||
// executable from a C++ unit and a .cu: with the default architecture, which
|
||||
// is native, then with another one, which compiles the unchanged .cu again in
|
||||
// a directory of its own, then once more with nothing changed, which compiles
|
||||
// nothing. Where nvcc is looked for is ToolchainResolve's to check; this is
|
||||
// the build that uses it. Skips without a CUDA toolkit, which CI does not
|
||||
// have.
|
||||
// nothing, and once its header is newer than its object, which compiles it
|
||||
// again: nvcc's depfile is the record of what the .cu includes, and before
|
||||
// nvcc wrote one, a changed header left the old object in place. Where nvcc
|
||||
// is looked for is ToolchainResolve's to check; this is the build that uses
|
||||
// it. Skips without a CUDA toolkit, which CI does not have.
|
||||
namespace {
|
||||
std::int32_t Failures = 0;
|
||||
|
||||
|
|
@ -124,6 +126,12 @@ int main() {
|
|||
const auto [again, againBinary] = build("sm_86");
|
||||
Check(again.empty() && Lines(log).size() == 2, std::format("an unchanged build compiles nothing (ran: {})", Joined(Lines(log))));
|
||||
|
||||
fs::last_write_time(project / "kernel.h", fs::file_time_type::clock::now());
|
||||
const auto [touched, touchedBinary] = build("sm_86");
|
||||
Check(touched.empty(), std::format("the build after the header changed succeeds: {}", touched));
|
||||
runs = Lines(log);
|
||||
Check(runs.size() == 3 && runs.back().contains("-arch=sm_86"), std::format("a changed header compiles the .cu again (ran: {})", Joined(runs)));
|
||||
|
||||
fs::remove_all(scratch, ec);
|
||||
return Failures == 0 ? 0 : 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue