[clang] Add support for sysroot-relative system header search paths (PR #82084)
Huaqi Fang via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 29 02:58:28 PDT 2025
================
@@ -3191,6 +3191,22 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
bool IsIndexHeaderMap = false;
bool IsSysrootSpecified =
Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
+
+ // Expand a leading `=` to the sysroot if one was passed (and it's not a
+ // framework flag).
+ auto PrefixHeaderPath = [IsSysrootSpecified,
----------------
fanghuaqi wrote:
Hello, I have a question about why `IsSysrootSpecified` is required, since the sysroot could use default sysroot defined in toolchain, for gcc, it is not required.
`If dir begins with ‘=’ or $SYSROOT, then the ‘=’ or $SYSROOT is replaced by the sysroot prefix; see --sysroot and -isysroot.`
So it will replace sysroot defined in toolchain, as tested below:
- gcc `-isystem=/include/libncrt`: `xxxxx/gcc/bin/../riscv64-unknown-elf/include/libncrt`, this is expected
- clang `-isystem=/include/libncrt` : ignoring nonexistent directory "=/include/libncrt"
https://github.com/llvm/llvm-project/pull/82084
More information about the cfe-commits
mailing list