[clang] [clang] Match -isysroot behaviour with system compiler on Darwin (PR #80524)

Daniel Rodríguez Troitiño via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 10:47:31 PST 2024


drodriguez wrote:

> But after taking a quick look, my impression is that this change reverses the bug fixed in #70817.
> 
> To recap, that PR preferred the C++ headers available in the toolchain distribution over the SDK headers, when the compiler was launched via a symbolic link to the executable (a behaviour common to the npm/xpm ecosystem).
> 
> If I understand this proposal right (please correct me if I'm wrong), it will move the SDK headers to the top of the list.
> 
> If this will happen only when an explicit `-isysroot` is passed on the compiler command line, it might be ok, but if it will happen for all cases, this will simply bring us back to the pre 70817 case, when builds on old macOS-es (like 10.13) with a new clang (like 17.x) will fail, due to the out of sync old headers from the SDK with the new library from the toolchain. I wasted quite a lot of time to diagnose this subtle issue by that time.

Yes. What I think Dmitry and I are trying to explain is that it is very weird that providing an explicit `-isysroot` in the command line is ignored for the C++ headers (and only for them). One can start using `-nostdinc` and friends, but that mean rebuilding the header search paths manually, which is not great.

At least in my testing preferring the sysroot only happens when providing an explicit `-isysroot` in the command line, but also might be affected by the presence of `SDKROOT` in the environment (tools like `xcrun` set this value). If one is careful and avoid those two, the headers by the `clang` binary should be preferred.

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


More information about the cfe-commits mailing list