feat: Add Windows ARM64 (MSVC) support#2050
feat: Add Windows ARM64 (MSVC) support#2050FixFlare wants to merge 3 commits intoopenfl:8.4.0-devfrom
Conversation
Just adding some additional context here. As I understand it, this restriction exists for legal reasons, rather than technical reasons. OpenAL-Soft is LGPL licensed, which can be dynamically linked without affecting the license of an application. However, if you want to statically link it, the application must be LGPL too, or the application must be distributed with symbols for relinking with a modified version of the library. That's not a requirement that we want to force on all users of Lime. |
|
The |
Reverted manual patches to mojoal.c to maintain clean submodules. Fixed OGG decoder metadata corruption on ARM64-MSVC by applying the /Zp8 alignment flag in the build script. Updated Build.xml to prioritize MojoAL for static ARM64 builds to satisfy legal requirements.
|
Hey guys - thanks for the feedback on this. I hadn't considered any of the legal aspects of this. Trying to get mojoal working though really sent me down a rabbit hole with debugging the sdl sound playback. In my original post I mentioned needing to force OpenAL Soft because static ARM64 builds would freeze on launch via Wine After adding way too many log statements, I found the true cause of that freeze - it was actually a memory alignment mismatch in the OGG decoder (stb_vorbis) on ARM64-MSVC. The structs were being padded incorrectly which caused the sample_rate to be read back as 0. That 0 was what was actually hanging the audio initialization and making it look like a MojoAL stall. (divide by 0 problem) @tobil4sk: I reverted all manual source-code patches to mojoal.c since I found the true cause of the freeze and was able to resolve the alignment mismatch by just using a /Zp8 compiler flag in the sdl_sound build script. This ensures the structs are packed correctly on ARM64 without tainting the submodule code. @joshtynjala: Now that the decoder bug is resolved and MojoAL is stable, I updated the logic to prioritize MojoAL for static ARM64 builds. I believe this should resolve the legal issue but let me know if you believe otherwise. |
Add Windows ARM64 build support
Description
This PR adds native compilation support for Windows ARM64 targets, allowing Lime projects to be cross-compiled for devices with ARM64 processors (Snapdragon X Elite laptops, Surface Pro X, Windows Dev Kit 2023, etc).
Usage follows the same convention as other platforms:
This should match the
-arm64flag behavior on macOS, iOS, and Android.Prerequisites
Developers cross-compiling from x64 must install the MSVC ARM64 build tools via the Visual Studio Installer:
Changes
Tools
tools/platforms/WindowsPlatform.hxisArmflag to detectArchitecture.ARM64targetsWindowsArm64paths (consistent withMacArm64,LinuxArm64)rebuild()method which was unconditionally passing-DHXCPP_M64for all 64-bit targets, ignoring the-arm64flag entirely. Now it passes-DHXCPP_ARM64when ARM64 is targeted-DHXCPP_ARM64into the hxcpp compiler flags for both HL and cpp target typestools/CommandLineTools.hxWindowsArm64/to the Neko module loader path resolution for Windows ARM64 hosts (matching the existingMacArm64/andLinuxArm64/pattern)-arm64help text to includewindowsalongsidemac|ios|androidNative dependencies
project/Build.xmlLIME_OPENALSOFTfrom thestatic_linkrestriction: Removedunless="static_link"from the desktop platform OpenAL Soft selection logic. This allows static binaries to use the more stable OpenAL Soft backend instead of being forced into MojoAL. Prior to this change, running a Windows ARM build on Linux via wine would freeze.LIME_MOJOALto only trigger for static buildsunless="LIME_OPENALSOFT || LIME_OPENAL".unsetsafety forLIME_OPENALSOFTwhenLIME_MOJOALis explicitly selected (e.g., for Switch) to prevent duplicate symbol linker errors.LIME_OPENALflag to trigger based on either backend, this should simplify downstream feature detection in the build script.project/lib/custom/openal/include/config-windows-arm64.h[NEW]project/lib/custom/openal/include/config.hconfig-windows-arm64.hwhenHXCPP_ARM64is defined on Windowsproject/lib/openal-files.xmlmixer_neon.cppon Windows (unless="windows"). This file uses GCC/Clang-specific NEON struct initialization syntax ({ a, b, c, d }onfloat32x4_t) that MSVC rejects witherror C2078: too many initializers. OpenAL cleanly falls back tomixer_c.cpp, which MSVC auto-vectorizes for ARM64project/lib/custom/pixman/config.hUSE_SSE2,USE_SSE3, andX86_MMXwhenHXCPP_ARM64is defined on Windows. These are x86-specific SIMD intrinsics that are unavailable on ARM64project/lib/custom/mojoal/mojoal.c[NEW]mojoal.cto resolve MSVC ARM64 compatibility issues:_allocashim for MSVC.project/lib/mojoalsubmodule to remain clean and untouched.project/lib/mojoal-files.xmlmojoal.cspecifically when building for ARM64 (if="HXCPP_ARM64"), ensuring the build succeeds without requiring modifications to subprojects.Testing
lime rebuild tools— CLI rebuilds successfullylime rebuild windows -arm64 -verbose— Native libraries (ndll) compile and link for ARM64 with zero errorslime rebuild windows -arm64 -static -verbose— Static library variant compiles successfullyndll/WindowsArm64/directory (notWindows64/)-machine:ARM64(not-machine:x64)lime rebuild windows -verbose(x64) is unaffectedNotes
mixer_neon.cppexclusion, mojoal.c fix) only affect Windows ARM64 builds. All other platforms (Linux ARM64, macOS ARM64, iOS, Android) continue to use their existing NEON code paths via GCC/Clang, which fully support the vector subscript syntax