Is it possible to run IWYU on Windows?

I am trying to run Unreal’s version of IWYU on our Windows Editor target. Up through 5.5, using -Mode=IWYU in UBT was fraught with issues, but things are much better in 5.6. I can get to the end of compiling a given module, and the output tells me it will now start parsing .iwyu files. However, none have been generated. I stepped through the code quite a bit, feeling crazy (everything in IWYUMode and IWYUToolChain looked good), until I realized IWYUToolChain is only used on Linux. Even ClangToolChain isn’t actually used on Windows, it’s all just places in VCToolChain checking Target.WindowsPlatform.Compiler.IsClang(). I’m sure this is obvious to the person answering this question, but I was pretty surprised.

Is there any way I can run IWYUMode and actually have it run include-what-you-use.exe in Windows without essentially re-implementing IYWUToolChain inside VCToolChain? We already have CI that builds Windows MSVC unity and nonunity/no PCH, plus Windows clang unity and nonunity/no PCH, along with keeping IWYUSupport set to IWYUSupport.Full and bWarnAboutMonolithicHeadersIncluded true. But without being able to run IWYU itself, there’s no real way to track down transitive includes and unnecessary includes.

I’ll also mention that building the Editor for Linux is probably out of the question for us. It’s a noble goal, but we don’t use the Editor there, nor ship our game there, so any attempt fails quickly on things like missing middleware platform support that we’ve never needed before. Integrating support from those vendors is possible, as is probably solving any other build problems we’re not aware of yet, but the time and effort spent to do that just for IWYU is probably something we can’t justify. Barring a major issue, making VCToolChain IWYU-aware would probably be the easier task.

So,

  1. Is there anything I’m missing here, and running on Windows is possible?
  2. If not, is Windows support planned?

I feel like we’re so close, with clang support and finally being able to run IWYUMode, that I was quite sad to see at the end, it doesn’t do anything. It will still help us find missing headers that are not transitively included, but that’s all right now.

Hello Matt, I’ll follow up with the dev that maintains IWYUMode and get back to you with his answer tomorrow.

It appears it is working with Windows now as of P4 cl 43630031 (github link) so it will be supported as of UE 5.7. Note we just recently updated the preferred clang compiler so the IWYU executable may still need to be updated to match in that branch, but it will be completed before 5.7 is released.