Header Search for Linux and Win32

I’ve been maintaining some clang / llvm tutorials that show how to use the basic libraries from clang on github (https://github.com/loarabia/Clang-tutorial). Because of a pull request this week to make the tutorials handle headers on Linux, I noticed that the code has drifted for handling some platforms’ headers.

In a nutshell, header handling of platform headers on Win32 and Linux Targets has moved out of InitHeaderSearch and into the Driver. The comments in the file read that the long term goal is to move all header handling out of InitHeaderSearch.

My question then is, what is the right way for folks using the basic libraries to setup the full toolchain including headers search. Is that a scenario intended to be supported elsewhere?

I can create a component that does basically what the Driver and ToolChain code does together but before I do that, I want to make sure that I am not overlooking the Intended Way ™.


I’ve had the same problem in my Clang-based tools.

I think we should either move all platform-specific include code out of Frontend into a separate library or move the Win32 header search code back into Frontend. Right now we have bits of it into different libraries and it’s confusing and hard to figure out.

Another option would be move most of it into some configuration files (having hardcoded paths in the source for things like MinGW locations does not make much sense going forward).

The way I’ve “solved it” in the meanwhile, was by adding a function to access the Win32 platform headers search code in the driver (see the attached patch).

0001-Expose-function-to-get-Windows-system-include-paths.patch (4.63 KB)