From 9f7789ffdae2ea0aa5a3b389ca9745ff160fa60f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Sep 2024 14:41:22 +0200 Subject: Fix issues in MSVC ARM64 support --- libbuild2/cc/guess.cxx | 21 ++++++++++++++++----- libbuild2/cc/msvc.cxx | 12 ++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index f092933..406534d 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -949,9 +949,15 @@ namespace build2 // there is nothing like -m32/-m64 or /MACHINE). Targeting // 64-bit seems like as good of a default as any. // - fb = ((dir_path (mi->msvc_dir) /= "bin") /= "Hostx64") /= - "x64"; - + fb = dir_path (mi->msvc_dir) /= "bin"; + +#if defined(_M_ARM64) || defined(__aarch64__) + fb /= "HostARM64"; + fb /= "ARM64"; +#else + fb /= "Hostx64"; + fb /= "x64"; +#endif search_info = info_ptr ( new msvc_info (move (*mi)), msvc_info_deleter); } @@ -1631,8 +1637,13 @@ namespace build2 // MSVC tools (link.exe, etc). In case of the Platform SDK, it's unclear // what the CPU signifies (host, target, both). // - r = (((dir_path (mi.msvc_dir) /= "bin") /= "Hostx64") /= cpu). - representation (); + r = (((dir_path (mi.msvc_dir) /= "bin") /= +#if defined(_M_ARM64) || defined(__aarch64__) + "HostARM64" +#else + "Hostx64" +#endif + ) /= cpu).representation (); r += path::traits_type::path_separator; diff --git a/libbuild2/cc/msvc.cxx b/libbuild2/cc/msvc.cxx index d21969c..416df36 100644 --- a/libbuild2/cc/msvc.cxx +++ b/libbuild2/cc/msvc.cxx @@ -33,10 +33,10 @@ namespace build2 const char* msvc_cpu (const string& cpu) { - const char* m (cpu == "i386" || cpu == "i686" ? "x86" : - cpu == "x86_64" ? "x64" : + const char* m (cpu == "x86_64" ? "x64" : + cpu == "i386" || cpu == "i686" ? "x86" : + cpu == "aarch64" ? "arm64" : cpu == "arm" ? "arm" : - cpu == "arm64" ? "arm64" : nullptr); if (m == nullptr) @@ -51,10 +51,10 @@ namespace build2 const char* msvc_machine (const string& cpu) { - const char* m (cpu == "i386" || cpu == "i686" ? "/MACHINE:x86" : - cpu == "x86_64" ? "/MACHINE:x64" : + const char* m (cpu == "x86_64" ? "/MACHINE:x64" : + cpu == "i386" || cpu == "i686" ? "/MACHINE:x86" : + cpu == "aarch64" ? "/MACHINE:ARM64" : cpu == "arm" ? "/MACHINE:ARM" : - cpu == "arm64" ? "/MACHINE:ARM64" : nullptr); if (m == nullptr) -- cgit v1.1