[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
This commit is contained in:
Eli Friedman 2022-02-28 13:32:25 -08:00
parent 96ae86bd29
commit cb254d5919
1 changed files with 10 additions and 1 deletions

View File

@ -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