[clang] [clang] Skip host default include paths for GPU triples (PR #192821)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 08:47:56 PDT 2026


================
@@ -879,8 +879,21 @@ void AMDGPUToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
 
 void AMDGPUToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
                                                 ArgStringList &CC1Args) const {
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-      DriverArgs.hasArg(options::OPT_nostdlibinc))
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+    return;
+
+  // Add clang's builtin headers (`stddef.h`, `float.h`, `stdint.h`, ...).
+  // These are compiler-provided headers, not host libc headers.
+  //
+  // Example: an amdgcn compile may still need `float.h`, but it should come
+  // from clang's resource directory, not from the host system's `/usr/include`.
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
----------------
jhuber6 wrote:

I thought `nostdlibinc` was supposed to be the canonical method to say 'I only want the clang builtin headers'? This seems a little redundant. Could `-Xarch_device -nostdlibinc` work?

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


More information about the cfe-commits mailing list