[PATCH] D104589: [llvm-rc] Don't rewrite the arch in the default triple unless necessary

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 25 12:59:28 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbdb03557c059: [llvm-rc] Don't rewrite the arch in the default triple unless necessary (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104589

Files:
  llvm/tools/llvm-rc/llvm-rc.cpp


Index: llvm/tools/llvm-rc/llvm-rc.cpp
===================================================================
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -145,7 +145,7 @@
   return Path;
 }
 
-Triple::ArchType getDefaultArch(Triple::ArchType Arch) {
+bool isUsableArch(Triple::ArchType Arch) {
   switch (Arch) {
   case Triple::x86:
   case Triple::x86_64:
@@ -154,17 +154,23 @@
   case Triple::aarch64:
     // These work properly with the clang driver, setting the expected
     // defines such as _WIN32 etc.
-    return Arch;
+    return true;
   default:
     // Other archs aren't set up for use with windows as target OS, (clang
-    // doesn't define e.g. _WIN32 etc), so set a reasonable default arch.
-    return Triple::x86_64;
+    // doesn't define e.g. _WIN32 etc), so with them we need to set a
+    // different default arch.
+    return false;
   }
 }
 
+Triple::ArchType getDefaultFallbackArch() {
+  return Triple::x86_64;
+}
+
 std::string getClangClTriple() {
   Triple T(sys::getDefaultTargetTriple());
-  T.setArch(getDefaultArch(T.getArch()));
+  if (!isUsableArch(T.getArch()))
+    T.setArch(getDefaultFallbackArch());
   T.setOS(Triple::Win32);
   T.setVendor(Triple::PC);
   T.setEnvironment(Triple::MSVC);
@@ -174,7 +180,8 @@
 
 std::string getMingwTriple() {
   Triple T(sys::getDefaultTargetTriple());
-  T.setArch(getDefaultArch(T.getArch()));
+  if (!isUsableArch(T.getArch()))
+    T.setArch(getDefaultFallbackArch());
   if (T.isWindowsGNUEnvironment())
     return T.str();
   // Write out the literal form of the vendor/env here, instead of


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104589.354587.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210625/ff709695/attachment.bin>


More information about the llvm-commits mailing list