Skip to content

Commit 9cdfc47

Browse files
authored
Check HXCPP_ARCH before defaulting to host arch (HaxeFoundation#1122)
* 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. * Fix formatting
1 parent f97a11e commit 9cdfc47

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

tools/hxcpp/BuildTool.hx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,23 @@ class BuildTool
137137
var otherArmArchitecture = mDefines.exists("HXCPP_ARMV6") || mDefines.exists("HXCPP_ARMV7") || mDefines.exists("HXCPP_ARMV7S");
138138
if (m64==m32 && !arm64 && !otherArmArchitecture)
139139
{
140-
var arch = getArch();
140+
var arch = mDefines.get("HXCPP_ARCH");
141+
if (arch!=null)
142+
{
143+
m64 = arch=="x86_64";
144+
m32 = arch=="x86";
145+
arm64 = arch=="arm64";
146+
}
147+
else
148+
{
149+
var hostArch = getArch();
150+
151+
// Default to the current OS version. windowsArm runs m32 code too
152+
m64 = hostArch=="m64";
153+
m32 = hostArch=="m32";
154+
arm64 = hostArch=="arm64";
155+
}
141156

142-
// Default to the current OS version. windowsArm runs m32 code too
143-
m64 = arch=="m64";
144-
m32 = arch=="m32";
145-
arm64 = arch=="arm64";
146157
mDefines.remove(m32 ? "HXCPP_M64" : "HXCPP_M32");
147158
set64(mDefines,m64,arm64);
148159
}

0 commit comments

Comments
 (0)