CMake compiler test intermittently fails to generate a .exe

I have a production site that has been chasing a strange issue that I’m running out of ideas for. I’m curious if anyone has seen the same thing or knows what the underlying cause is.

The setup is VS2019 with the clang toolchain. In CI, when CMake does its compiler tests at the very start of the run, the C compiler tests are always fine, but randomly the C++ compiler test fails. And by fail, I mean it doesn’t generate the a.exe, but the source files for it are all there apparently. There’s no virus checker or other security software of note running. No memory or disk space pressures. It’s as though the compiler is crashing, but no output anywhere we’ve seen so far that can point to that. Can’t rule out that CMake isn’t doing something right either.

So far, we haven’t been able to reproduce it locally, only in CI. And this only started happening a month or two ago. I believe we’ve been seeing it with CMake 3.22, if that matters.

I would recommend getting ProcMon to capture logs of when this happens to try and get the originating error. Filtering can probably be used to reduce the log size. I would recommend filtering it to anything under the CI build directory at least.