Skip to content

Add native Linux ARM64 (linuxarm64) build target - #439

Open
greenjon wants to merge 1 commit into
SpaiR:mainfrom
greenjon:linux-arm64-native-target
Open

greenjon wants to merge 1 commit into
SpaiR:mainfrom
greenjon:linux-arm64-native-target

Conversation

@greenjon

Copy link
Copy Markdown

Summary

Closes #105 by adding an opt-in linuxarm64 env to generateLibs, mirroring the existing macosarm64 convention.

generateLibs' Linux target has always been constructed via newDefaultTarget(Os.Linux, Bitness._64), which defaults to Architecture.x86. That's the actual reason Linux ARM64 native builds have never worked here, even on a native aarch64 host: the task emits x86-only compiler flags (-mfpmath=sse -msse -m64), which a real aarch64 g++/gcc rejects outright with unrecognized command-line option.

gdx-jnigen 2.5.2 (already a dependency here) ships a correct Architecture.ARM Linux target (aarch64-linux-gnu- prefix, -fPIC, no SSE flags) — this build script just never selects it.

Changes

  • Add forLinuxArm64 (opt-in via -Denvs=linuxarm64), following the same naming convention as forMacArm64/macosarm64.
  • Refactor the existing x86 Linux target construction into a createLinuxTarget(Architecture) helper (mirroring the existing createMacTarget(Architecture) helper), used by both forLinux and forLinuxArm64.
  • libName is pinned to libimgui-java64.so regardless of architecture, matching how createMacTarget already keeps the same filename across x86_64/arm64 (the Java-side native loader distinguishes platforms by directory/classpath entry, not filename).
  • When already running natively on an aarch64 host (e.g. GitHub's ubuntu-24.04-arm runners), the aarch64-linux-gnu- cross-compiler prefix is cleared, since no cross toolchain is needed there and that package usually isn't installed on native ARM64 runners.
  • Existing forLinux (x86) behavior and output paths (linux64/...) are unchanged.

Test plan

  • Verified on a native ubuntu-24.04-arm GitHub Actions runner: ./gradlew :imgui-binding:compileJava && ./gradlew :imgui-binding:generateLibs -Denvs=linuxarm64 -Dlocal produces imgui-binding/build/libsNative/linuxarm64/libimgui-java64.so, confirmed via file:
    ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, ...
    
    (run)
  • Existing forLinux/forWindows/forMac/forMacArm64 paths are unchanged by this diff and weren't independently re-verified in this PR — happy to run the full existing matrix if useful.

generateLibs' Linux target has always been constructed via
newDefaultTarget(Os.Linux, Bitness._64), which defaults to
Architecture.x86 regardless of host architecture. That's the root
cause behind SpaiR#105: even on a native aarch64 host, the task emits
x86-only compiler flags (-mfpmath=sse -msse -m64), which a real
aarch64 g++/gcc rejects outright.

gdx-jnigen 2.5.2 (the library this build script sits on top of)
already ships a correct Architecture.ARM Linux target
(aarch64-linux-gnu- prefix, -fPIC, no SSE flags) — this task just
never selects it.

Add an opt-in `linuxarm64` env (mirroring the existing `macosarm64`
convention) that builds via that target instead, refactoring the
existing x86 Linux target into a shared createLinuxTarget() helper
(mirroring createMacTarget()) so both paths stay in sync. libName is
pinned to libimgui-java64.so on both architectures for consistency,
matching how the mac target already does this for x86_64/arm64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant