[clang] [HIP] Fix distro HIP headers shadowing ROCm includes (PR #238058)

David Salinas via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 13:02:00 PST 2026


david-salinas wrote:


> The issue is just the ROCm includes showing up after `/usr/include`? Any reason we cant' just move it before those overall with `-isystem`? I don't know if that would break anything.

The ticket describes the issue fairly well actually.  The user could just use the work around: "-isystem $ROCM/include (or CMAKE_HIP_FLAGS), or remove the distro package.".  But,  on using -isystem universally: At the cc1 level, driver -isystem maps to -internal-isystem, which is what this patch already uses for the non-system case. The issue is that it can't be used unconditionally. When ROCm is installed under /usr, -internal-isystem /usr/include prepends /usr/include before the C++ standard  library headers. Since libstdc++/libc++ headers rely on #include_next to reach the C standard library headers in /usr/include, reordering them breaks that chain — which is the exact regression D120132/cd597588 fixed. The conditional preserves that fix while closing the shadowing hole for the /opt/rocm case (which is the overwhelmingly common install layout).

I also agree that this case is (generally speaking) rare/uncommon.  But the patch is fairly minimal and (IMO) not likely to cause issues down the road.


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


More information about the cfe-commits mailing list