[clang] [clang][driver] Add \<executable\>/../include/c++/v1 to include path on Darwin (PR #70817)

Liviu Ionescu via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 17:47:30 PDT 2023


ilg-ul wrote:

> Is there any reason why we don't just use Dir all the time?

That's a good question.

There was a long discussion in #68091, and my understanding is that, for compatibility reasons, the current behaviour must be preserved.

> What's the difference between those two?

`Dir` is the location where the actual executables are installed.
`InstalledDir`, when the compiler is invoked via a link, is the location where the link comes from.

In my use case, and probably in most use cases, the location where the link comes from is a plain folder, not a hierarchy specific to a toolchain.

However, for testing purposes, including several clang tests, such a hierarchy is created, with other headers, and a link is placed there, with the expectation that the compiler will use that environment and not the one where the toolchain is actually installed.

There are many places in the source code where something is searched for first in the `InstalledDir`, and, if not found, it is also searched in `Dir`. 

This patch uses exactly the same strategy for identifying the C++ headers on Darwin. Without the patch, when using links the compiler chooses the SDK headers, which is plainly wrong and damaging.



https://github.com/llvm/llvm-project/pull/70817


More information about the cfe-commits mailing list