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

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 12:02:24 PST 2024


ldionne wrote:

@dmpolukhin 

Replying to https://reviews.llvm.org/D157283#4648445:

> @ldionne thank you for the reply. Unfortunately current behaviour makes problems for clang-tools like clang-tidy and clangd that read CDBs from compile_commands.json. They start looking headers relative to compiler path specified in CDB but it is better to use path specified in -isysroot (it is what user expects when they specify the option). What is the rationale behind ignoring -isysroot specified in command line? If user would like to use search path relative to compiler, they could just remove -isysroot and get this behaviour.

The intent was simply that if someone builds a Clang-based toolchain on Apple platforms and they include libc++ in that toolchain, the toolchain libc++ should be preferred over any system-provided libc++ we have in the SDK. So even if you use `-isysroot <SDK>` (which you need for everything like the C stdlib and other system headers), we want your custom-built toolchain libc++ headers to be preferred over the system-provided libc++ headers (in the SDK). But by default, we don't ship toolchain headers with AppleClang so we check in the toolchain, find nothing, and then fall back to the SDK.

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


More information about the cfe-commits mailing list