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

David Salinas via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 12:57:09 PST 2026


================
@@ -1183,6 +1183,14 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(Args.MakeArgString(P));
   }
 
+  // Add HIP toolkit include paths after C++ stdlib but before system headers.
+  // This ensures the selected ROCm headers beat distro-installed HIP headers
+  // in /usr/include without breaking C++ #include_next chains.
+  // Skip when using LLVM offloading (-foffload-via-llvm): that mode uses its
+  // own offload headers instead of vendor ROCm headers.
+  if (JA.isOffloading(Action::OFK_HIP) && !UsesLLVMOffloading)
+    getToolChain().AddHIPIncludeArgsLate(Args, CmdArgs);
----------------
david-salinas wrote:

yes it is intended.  I'll add a test.

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


More information about the cfe-commits mailing list