Hurd: Clean up Debian multiarch /usr/include/<triplet>
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 27 Apr 2021 20:36:12 +0000 (13:36 -0700)
committerFangrui Song <i@maskray.me>
Tue, 27 Apr 2021 20:36:12 +0000 (13:36 -0700)
This is a follow-up of 35dd6470de84 for the Hurd case, to avoid the
duplication of the i386-gnu path, already provided by
Hurd::getMultiarchTriple.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101324

clang/lib/Driver/ToolChains/Hurd.cpp

index bfb9677..48b9cca 100644 (file)
@@ -170,11 +170,13 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
 
   AddMultilibIncludeArgs(DriverArgs, CC1Args);
 
-  if (getTriple().getArch() == llvm::Triple::x86) {
-    std::string Path = SysRoot + "/usr/include/i386-gnu";
-    if (D.getVFS().exists(Path))
-      addExternCSystemInclude(DriverArgs, CC1Args, Path);
-  }
+  // On systems using multiarch, add /usr/include/$triple before
+  // /usr/include.
+  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), SysRoot);
+  if (!MultiarchIncludeDir.empty() &&
+      D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
+    addExternCSystemInclude(DriverArgs, CC1Args,
+                            SysRoot + "/usr/include/" + MultiarchIncludeDir);
 
   // Add an include of '/include' directly. This isn't provided by default by
   // system GCCs, but is often used with cross-compiling GCCs, and harmless to