[clang] [Clang] [Driver] Canoncalise `-internal-isystem` include paths (PR #148745)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 21 10:22:12 PDT 2025
Sirraide wrote:
> The Windows failures look annoying.
>
> Taking one failure, Driver/aarch64-multilib-pauthabi.c. It contains:
>
> `// CHECK: "-internal-externc-isystem" "{{.*}}/usr/include/aarch64-linux-pauthtest"`
>
> However, on Windows, this has been canonicalized to `"C:\\_work\\llvm-project\\llvm-project\\clang\\test\\Driver\\Inputs\\multilib_aarch64_linux_tree\\usr\\include\\aarch64-linux-pauthtest"` (canonicalized path, from the specified sysroot `C:\\_work\\llvm-project\\llvm-project\\clang\\test\\Driver/Inputs/multilib_aarch64_linux_tree`).
>
> So, fine, we can just change the CHECK line to use `{{(/|\\\\)}}`.
>
> But taking another, Driver/aix-toolchain-include.cpp, it has: `// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"` but, `"-resource-dir" is uncanoncalized, "C:\\_work\\llvm-project\\llvm-project\\clang\\test\\Driver/Inputs/resource_dir"` which can't match the now-canonicalized include path, `"C:\\_work\\llvm-project\\llvm-project\\clang\\test\\Driver\\Inputs\\resource_dir\\include"`.
>
> Ugh.
Yeah, this is getting a bit messy...
> Notes about -no-canonical-prefixes :
>
> > -no-canonical-prefixes instructs Clang to call realpath on the executable name and use the dereferenced absolute path for the -cc1 command. This path, either canonicalized by realpath or not, is used to derive the resource directory. See https://gcc.gnu.org/legacy-ml/gcc/2011-01/msg00429.html for some background.
>
> It's unclear whether -internal-isystem should reuse -no-canonical-prefixes. While I find `../..` for GCC/glibc paths difficult to read as well, they work best with all use cases. In addition, it is confusing that library paths are not canonicalized. I've tried this option with GCC, which does not change the `-v` output or `LIBRARY_PATH` in -### output.
>
> ```
> % /Dev/gcc/out/debug/gcc/xgcc -B ~/Dev/gcc/out/debug/gcc -c x.cc -v
> ```
>
> I prefer that by default we don't do canonicalization.
We could make this a separate option, yeah. Also what with the Windows issues (which I have a hard time debugging because I’m not on Windows...), it might really be easier to just make it an opt-in flag at this point. It’s a bit sad but it might be less of a hassle to do it that way...
CC @AaronBallman for opinions
https://github.com/llvm/llvm-project/pull/148745
More information about the cfe-commits
mailing list