From 0b10137008ff0b4e9cdee32cfbb29d3eaae7d2b4 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 25 Feb 2026 16:44:50 +0200 Subject: [PATCH 1/2] feat: ARM64 target architecture support Extend the MSVC toolchain integration to support Windows ARM64 targets. (I know very little about gyp, so these changes may be a bit rough. They were enough to get NSS building on Windows 11/ARM in CI via https://github.com/mozilla/neqo/pull/2591. Please let me know if anything needs changing!) --- pylib/gyp/MSVSVersion.py | 6 +++--- pylib/gyp/generator/ninja.py | 3 ++- pylib/gyp/msvs_emulation.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pylib/gyp/MSVSVersion.py b/pylib/gyp/MSVSVersion.py index 2d8e4cea..f46607b3 100644 --- a/pylib/gyp/MSVSVersion.py +++ b/pylib/gyp/MSVSVersion.py @@ -87,7 +87,7 @@ def DefaultToolset(self): def _SetupScriptInternal(self, target_arch): """Returns a command (with arguments) to be used to set up the environment.""" - assert target_arch in ("x86", "x64"), "target_arch not supported" + assert target_arch in ("x86", "x64", "arm64"), "target_arch not supported" # If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the # depot_tools build tools and should run SetEnv.Cmd to set up the # environment. The check for WindowsSDKDir alone is not sufficient because @@ -109,8 +109,8 @@ def _SetupScriptInternal(self, target_arch): ) # Always use a native executable, cross-compiling if necessary. - host_arch = "amd64" if is_host_arch_x64 else "x86" - msvc_target_arch = "amd64" if target_arch == "x64" else "x86" + host_arch = "amd64" if is_host_arch_x64 else ("arm64" if os.environ.get("PROCESSOR_ARCHITECTURE") == "ARM64" else "x86") + msvc_target_arch = {"x64": "amd64"}.get(target_arch, target_arch) arg = host_arch if host_arch != msvc_target_arch: arg += "_" + msvc_target_arch diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py index 4eac6cdb..3ceaf470 100644 --- a/pylib/gyp/generator/ninja.py +++ b/pylib/gyp/generator/ninja.py @@ -246,7 +246,7 @@ def __init__( if flavor == "win": # See docstring of msvs_emulation.GenerateEnvironmentFiles(). self.win_env = {} - for arch in ("x86", "x64"): + for arch in ("x86", "x64", "arm64"): self.win_env[arch] = "environment." + arch # Relative path from build output dir to base dir. @@ -2339,6 +2339,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name master_ninja.variable("rc", "rc.exe") master_ninja.variable("ml_x86", "ml.exe") master_ninja.variable("ml_x64", "ml64.exe") + master_ninja.variable("ml_arm64", "armasm64.exe") master_ninja.variable("mt", "mt.exe") else: master_ninja.variable("ld", CommandWithWrapper("LINK", wrappers, ld)) diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py index 7c461a8f..f1c15819 100644 --- a/pylib/gyp/msvs_emulation.py +++ b/pylib/gyp/msvs_emulation.py @@ -1174,7 +1174,7 @@ def GenerateEnvironmentFiles( meet your requirement (e.g. for custom toolchains), you can pass "-G ninja_use_custom_environment_files" to the gyp to suppress file generation and use custom environment files prepared by yourself.""" - archs = ("x86", "x64") + archs = ("x86", "x64", "arm64") if generator_flags.get("ninja_use_custom_environment_files", 0): cl_paths = {} for arch in archs: From 46fac93b268df95c799d745efd24145307e4b624 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 25 Feb 2026 17:33:15 +0200 Subject: [PATCH 2/2] Update pylib/gyp/MSVSVersion.py Co-authored-by: Christian Clauss --- pylib/gyp/MSVSVersion.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylib/gyp/MSVSVersion.py b/pylib/gyp/MSVSVersion.py index f46607b3..12fa57d2 100644 --- a/pylib/gyp/MSVSVersion.py +++ b/pylib/gyp/MSVSVersion.py @@ -109,7 +109,9 @@ def _SetupScriptInternal(self, target_arch): ) # Always use a native executable, cross-compiling if necessary. - host_arch = "amd64" if is_host_arch_x64 else ("arm64" if os.environ.get("PROCESSOR_ARCHITECTURE") == "ARM64" else "x86") + host_arch = "amd64" if is_host_arch_x64 else ( + "arm64" if os.environ.get("PROCESSOR_ARCHITECTURE") == "ARM64" else "x86" + ) msvc_target_arch = {"x64": "amd64"}.get(target_arch, target_arch) arg = host_arch if host_arch != msvc_target_arch: