[PATCH] D120681: [Windows] Don't try to use x64 linker on ARM64 Windows.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 13:41:11 PST 2022


efriedma created this revision.
efriedma added reviewers: rnk, mstorsjo.
Herald added subscribers: hiraditya, kristof.beyls.
efriedma requested review of this revision.
Herald added a project: LLVM.

Trying to invoke an x64 binary on ARM64 Windows 10 won't work, and will print an obscure error message.  Choose the 32-bit linker instead, which will run under emulation.

The x64 linker should in theory run under ARM64 Windows 11.  We could detect this using IsWow64GuestMachineSupported(), but I don't have a setup to test that with at the moment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120681

Files:
  llvm/lib/WindowsDriver/MSVCPaths.cpp


Index: llvm/lib/WindowsDriver/MSVCPaths.cpp
===================================================================
--- llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ llvm/lib/WindowsDriver/MSVCPaths.cpp
@@ -359,7 +359,16 @@
   switch (Type) {
   case SubDirectoryType::Bin:
     if (VSLayout == ToolsetLayout::VS2017OrNewer) {
-      const bool HostIsX64 = Triple(sys::getProcessTriple()).isArch64Bit();
+      // MSVC ships with two linkers: a 32-bit x86 and 64-bit x86 linker.
+      // On x86, pick the linker that corresponds to the current process.
+      // On ARM64, pick the 32-bit x86 linker; the 64-bit one doesn't run
+      // on Windows 10.
+      //
+      // FIXME: Consider using IsWow64GuestMachineSupported to figure out
+      // if we can invoke the 64-bit linker. It's generally preferable
+      // because it won't run out of address-space.
+      const bool HostIsX64 =
+          Triple(sys::getProcessTriple()).getArch() == Triple::x86_64;
       const char *const HostName = HostIsX64 ? "Hostx64" : "Hostx86";
       sys::path::append(Path, "bin", HostName, SubdirName);
     } else { // OlderVS or DevDivInternal


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120681.411879.patch
Type: text/x-patch
Size: 1132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220228/f39916f0/attachment.bin>


More information about the llvm-commits mailing list