[llvm] cb254d5 - [Windows] Don't try to use x64 linker on ARM64 Windows.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 17:01:03 PST 2022
Author: Eli Friedman
Date: 2022-02-28T17:00:50-08:00
New Revision: cb254d5919814402163c83c90248f666409f875f
URL: https://github.com/llvm/llvm-project/commit/cb254d5919814402163c83c90248f666409f875f
DIFF: https://github.com/llvm/llvm-project/commit/cb254d5919814402163c83c90248f666409f875f.diff
LOG: [Windows] Don't try to use x64 linker on ARM64 Windows.
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.
Differential Revision: https://reviews.llvm.org/D120681
Added:
Modified:
llvm/lib/WindowsDriver/MSVCPaths.cpp
Removed:
################################################################################
diff --git a/llvm/lib/WindowsDriver/MSVCPaths.cpp b/llvm/lib/WindowsDriver/MSVCPaths.cpp
index de1ee85e1d9b0..23d67378a22e1 100644
--- a/llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ b/llvm/lib/WindowsDriver/MSVCPaths.cpp
@@ -359,7 +359,16 @@ std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout,
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
More information about the llvm-commits
mailing list