From 5562d225c965ac8ff642fd01696e0b6c7adf67d4 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 25 Jun 2024 11:05:48 +0100 Subject: [PATCH] Check HXCPP_ARCH before defaulting to host arch Right now HXCPP_ARCH is ignored, which means you can get situations where `HXCPP_ARM64` is set but the architecture is x86_64 so you may end up with a broken build. --- tools/hxcpp/BuildTool.hx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index 15339a9a9..b2e76b9d6 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -136,12 +136,20 @@ class BuildTool arm64 = mDefines.exists("HXCPP_ARM64"); if (m64==m32 && !arm64) { - var arch = getArch(); + var arch = mDefines.get("HXCPP_ARCH"); + if (arch != null) { + m64 = arch == "x86_64"; + m32 = arch == "x86"; + arm64 = arch == "arm64"; + } else { + var hostArch = getArch(); + + // Default to the current OS version. windowsArm runs m32 code too + m64 = hostArch == "m64"; + m32 = hostArch == "m32"; + arm64 = hostArch == "arm64"; + } - // Default to the current OS version. windowsArm runs m32 code too - m64 = arch=="m64"; - m32 = arch=="m32"; - arm64 = arch=="arm64"; mDefines.remove(m32 ? "HXCPP_M64" : "HXCPP_M32"); set64(mDefines,m64,arm64); }