MSBuild incremental builds are broken with LLVM 6 (and beyond)


Starting with LLVM 6, MSBuild incremental builds stopped working. I’ve tracked this down to a CL that modified how file renaming was done on Windows. It appears that FileTracker does not recognize renaming a file with SetFileInformationByHandle.

You can repro this fairly easily by:

  1. Downloading the prebuilt binaries of LLVM 6 or 7 for Windows.
  2. Creating a new C++ project (I just chose the default console application) in VS 2017.
  3. Mess with the project settings to disable all the features clang doesn’t support (Conformance mode, Just my code, etc…)
  4. Build

Every time you build it will rebuild everything.

I’m curious if this is a known issue? (I couldn’t find any open bugs relating to this)
Is MSBuild incremental builds something that is officially supported? Or did it just work in the past by chance?


I had no idea they were broken, that seems like a major regression. Come to think of it, I think someone may have reported this behavior, but it was never root caused, so thanks for that.

However, we spent a lot of time coming up with this particular code pattern to:

  1. (mostly) atomically write the whole output file or nothing at all on failure
  2. not leak temporary files when the compiler crashes

Before our use of SetInformationByFileHandle we leaked temporary object files in build directories like crazy. All you had to do was basically interrupt a build and clang would leave behind files. The linker suffered from similar problems.

So, I would be very careful about going back to our old code patterns. I wonder if Microsoft would accept this as a bug in FileTracker.dll instead.

You mention that you disabled features clang doesn’t support, so I take this to mean you’re using the LLVM VS integration.

If so, what version of the VS integration is being used? Is it the version that’s on the Marketplace and installs from a vsix, or the version that you run a batch file to install?

I was using the VS integration from the Marketplace.

I initially discovered this issue while using my own tool set (based on LLVM) with it’s own VS integration. I only mentioned the LLVM VS integration as I thought it would be easier for somebody else to reproduce, instead of trying to explain my custom setup. You can also reproduce by just calling tracker.exe and invoking Clang directly, completely removing VS integration from the equation.