openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
749 stars 362 forks source link

`lime rebuild ios` fails on M1 due to multiple architecture flags #1733

Closed tobil4sk closed 7 months ago

tobil4sk commented 7 months ago

By default, when running lime rebuild ios, both armv7 and arm64 architecture flags are active. See: https://github.com/openfl/lime/blob/e6205bf3aaace23c7e2458841da4435ff9879eaf/tools/platforms/IOSPlatform.hx#L478-L482

This means that HXCPP_ARMV7 and HXCPP_ARM64 are set at once: https://github.com/openfl/lime/blob/e6205bf3aaace23c7e2458841da4435ff9879eaf/tools/platforms/IOSPlatform.hx#L491-L493

The hxcpp code does not allow for these flags to be set at once (see https://github.com/HaxeFoundation/hxcpp/blob/18f87b949464ddcf24c6a83a2f7b8f76233540bc/toolchain/iphoneos-toolchain.xml#L43-L47).

The compiler receives -arch armv7 arm64, so only armv7 is treated as an architecture flag, and the arm64 is treated as a file to be compiled, resulting in the error:

Error: clang: error: no such file or directory: 'arm64'

Perhaps it's fine to just no longer set HXCPP_ARMV7 by default? Considering the commit message here: https://github.com/openfl/lime/commit/f34b595e70785758d3517030466a954af17027bb.

player-03 commented 7 months ago

In IOSPlatform, commands is an array of arrays. Each sub-array is handled independently, meaning the two flags aren't set at once. Your error must be coming from somewhere else.

tobil4sk commented 7 months ago

Each sub-array is handled independently, meaning the two flags aren't set at once.

Ah you're right... So the HXCPP_ARM64 flag is being set from elsewhere. Worth noting that this problem happened when compiling ios from m1.

tobil4sk commented 7 months ago

Maybe the problem is just that the host architecture results in a flag being added, when that should not be happening.

This would go unnoticed on intel mac is because the x86_64 architecture does not result in a -arch flag being set, so even if the host architecture bled through into the compiler flags it wouldn't cause any issues:

https://github.com/HaxeFoundation/hxcpp/blob/18f87b949464ddcf24c6a83a2f7b8f76233540bc/toolchain/iphoneos-toolchain.xml#L43-L47

tobil4sk commented 7 months ago

After further debugging, it looks like the problem lies with hxcpp, not lime: https://github.com/HaxeFoundation/hxcpp/pull/1079