[PATCH] D131563: [WIP] [clang] Fix clang multiarch isssue with musl

Brahmajit via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 07:34:56 PDT 2022


listout updated this revision to Diff 451452.
listout added a comment.
Herald added subscribers: pcwang-thead, luke957, s.egerton, simoncook.

Less drastic changes and rebased with main


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131563/new/

https://reviews.llvm.org/D131563

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -46,6 +46,8 @@
   bool IsMipsR6 = TargetTriple.getSubArch() == llvm::Triple::MipsSubArch_r6;
   bool IsMipsN32Abi = TargetTriple.getEnvironment() == llvm::Triple::GNUABIN32;
 
+  std::string EnvName = TargetTriple.isMusl() ? "musl" : "gnu";
+
   // For most architectures, just use whatever we have rather than trying to be
   // clever.
   switch (TargetTriple.getArch()) {
@@ -61,35 +63,35 @@
     if (IsAndroid)
       return "arm-linux-androideabi";
     if (TargetEnvironment == llvm::Triple::GNUEABIHF)
-      return "arm-linux-gnueabihf";
-    return "arm-linux-gnueabi";
+      return "arm-linux-" + EnvName;
+    return "arm-linux-" + EnvName;
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
     if (TargetEnvironment == llvm::Triple::GNUEABIHF)
-      return "armeb-linux-gnueabihf";
-    return "armeb-linux-gnueabi";
+      return "armeb-linux-" + EnvName;
+    return "armeb-linux-" + EnvName;
   case llvm::Triple::x86:
     if (IsAndroid)
       return "i686-linux-android";
-    return "i386-linux-gnu";
+    return "i386-linux" + EnvName;
   case llvm::Triple::x86_64:
     if (IsAndroid)
       return "x86_64-linux-android";
     if (TargetEnvironment == llvm::Triple::GNUX32)
       return "x86_64-linux-gnux32";
-    return "x86_64-linux-gnu";
+    return "x86_64-linux-" + EnvName;
   case llvm::Triple::aarch64:
     if (IsAndroid)
       return "aarch64-linux-android";
-    return "aarch64-linux-gnu";
+    return "aarch64-linux-" + EnvName;
   case llvm::Triple::aarch64_be:
-    return "aarch64_be-linux-gnu";
+    return "aarch64_be-linux-" + EnvName;
 
   case llvm::Triple::m68k:
     return "m68k-linux-gnu";
 
   case llvm::Triple::mips:
-    return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
+    return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-" + EnvName;
   case llvm::Triple::mipsel:
     if (IsAndroid)
       return "mipsel-linux-android";
@@ -119,13 +121,13 @@
       return "powerpc-linux-gnuspe";
     return "powerpc-linux-gnu";
   case llvm::Triple::ppcle:
-    return "powerpcle-linux-gnu";
+    return "powerpcle-linux-" EnvName;
   case llvm::Triple::ppc64:
-    return "powerpc64-linux-gnu";
+    return "powerpc64-linux-" + EnvName;
   case llvm::Triple::ppc64le:
-    return "powerpc64le-linux-gnu";
+    return "powerpc64le-linux-" + EnvName;
   case llvm::Triple::riscv64:
-    return "riscv64-linux-gnu";
+    return "riscv64-linux-" + EnvName;
   case llvm::Triple::sparc:
     return "sparc-linux-gnu";
   case llvm::Triple::sparcv9:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131563.451452.patch
Type: text/x-patch
Size: 2722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220810/fc838eca/attachment.bin>


More information about the cfe-commits mailing list