Skip to content

build Android arm64-v8a wheel - #10

Open
rishavsanjay wants to merge 7 commits into
sirhcm:mainfrom
rishavsanjay:android-arm64-wheel
Open

build Android arm64-v8a wheel#10
rishavsanjay wants to merge 7 commits into
sirhcm:mainfrom
rishavsanjay:android-arm64-wheel

Conversation

@rishavsanjay

@rishavsanjay rishavsanjay commented Jul 30, 2026

Copy link
Copy Markdown

Adds an Android arm64-v8a build for libtinymesa.so.

  • Android API 25, NDK r29, Mesa 25.2.7
  • builds only the NIR + IR3/freedreno path needed for Adreno

NAK and libtinymesa_cpu.so are omitted to keep the Android build simple and avoid cross-compiling LLVM (its very annoying).

This keeps the Android wheel focused on the Adreno use case for now; broader compiler/CPU support can be added separately if needed.

@rishavsanjay
rishavsanjay marked this pull request as draft August 11, 2026 18:14
@rishavsanjay
rishavsanjay marked this pull request as ready for review August 25, 2026 19:28
@rishavsanjay

Copy link
Copy Markdown
Author

my bad, for some reason gh didnt trigger actions on this branch on my fork? run succeeded on an another branch tho.

Comment thread .github/workflows/compile.yml Outdated
@rishavsanjay

Copy link
Copy Markdown
Author

verified the Android arm64-v8a wheel on my phone, tinymesa imports successfully and IR3 also works. Screenshot attached.
Screenshot from 2026-08-26 23-16-06

@rishavsanjay

Copy link
Copy Markdown
Author

there is another problem though
Termux builds its Python package for Android API 24, while Mesa 25.2.7 requires API 25. This means that pip install tinymesa is rejected on standard Termux, even if device is API 25>= .

The workaround is to explicitly install for android_25_arm64_v8a using --platform. it's not too bad, but still annoying, and there doesn’t seem to be a clean fix without lowering Mesa’s API or using a Python package built for API 25+.

@sirhcm

sirhcm commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Neat. Does it work just as a compiler in tinygrad (ie. DEV=NULL:IR3:a630)?

As for the the API version thing, if it requires significant patches to mesa to use version 24 it's probably fine to require pip install --platform (should mention that in README though).

@rishavsanjay

Copy link
Copy Markdown
Author

so I spent some time analyzing the Android API requirement. Mesa’s API 25 minimum is basically an internal Meson configuration. it prevents configuring Mesa with a lower platform-sdk-version, but it is not an IR3 requirement and does not guarantee that every resulting library will load on an API 25 device. there is no IR3 code gated on API 24/25, so there is essentially no difference for IR3.

but the current Mesa 25.2.7 tinymesa build would not load on API 25. tinymesa builds Mesa outside Android’s full AOSP build system, using the NDK.

the public NDK does not include private Android platform libraries like libcutils.so, so Mesa builds small stub libraries with dummy implementations to satisfy the linker at build time. these stubs let the build succeed, but they are not included in the tinymesa wheel. libtinymesa.so still records DT_NEEDED: libcutils.so, so when it is loaded on a device Android tries to use the real platform /system/lib64/libcutils.so instead.

see here, line 3 adds cutils to the stub libraries and lines 9–15 build them as shared libraries:

https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-25.2.7/src/android_stub/meson.build#L1-20

the dummy implementations themselves are here:

https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-25.2.7/src/android_stub/cutils_stub.cpp#L6-31

libtinymesa.so uses strong imports for several tracing functions. those functions are not fully exported by the real platform libcutils.so on API 25–29, so Android’s dynamic linker can reject the library before any IR3 code executes. API 25 specifically lacks atrace_end_body.

I didnt test on an actual API 24/25 device, which is almost a decade old at this point, so this is based on the ELF and platform ABI rather than a runtime test. based on that, I dont think it will load.

API 30 is the first platform version that satisfies this particular Mesa 25.2.7 artifact’s runtime symbol dependencies.

see here, the API 30 arm64 ABI dump lists atrace_begin_body, atrace_end_body, atrace_get_enabled_tags, and property_get, see here:

https://android.googlesource.com/platform/prebuilts/abi-dumps/vndk/+/4ec65bdc81dfc29be9ca31591cedd905533c99e1/30/64/arm64_armv8-a/source-based/libcutils.so.lsdump#142

TL;DR: Mesa’s API 25 minimum is only a Meson configuration floor, not an IR3 requirement or a guarantee that the resulting library runs on API 25. The current Mesa 25.2.7 tinymesa artifact still depends on private Android libcutils symbols that are not all available until API 30, so it likely will not load on API 24–29. We can either patch Mesa 25.2.7 to remove that dependency and build a genuine API 24 wheel, temporarily declare API 30 as the runtime minimum, or wait for Mesa 26.2, where those legacy dependencies are already removed. Mesa 26.2 would still need the one-line Meson floor change for API 24.

there are three paths now:

  1. patch Mesa 25.2.7. the patch should be small and would remove the private libcutils.so dependency, then we could build a real API 24 wheel.

  2. dont patch for now and bump the supported runtime minimum to API 30. installation would still need the explicit pip --platform/--target workaround because the wheel tag does not match the tags exposed by the Termux Python we tested.

  3. wait for Mesa 26.2. when tinymesa moves to Mesa 26.2, Mesa’s legacy atrace and cutils/property stub dependencies are already removed.

see here, :

https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-26.2.1/docs/relnotes/26.2.0.rst#L6007-6011

Mesa 26.2 still has an internal API 25 Meson floor, though, so an API 24 wheel would still need the one-line floor change.

@rishavsanjay

Copy link
Copy Markdown
Author

and the phone tests. image

@sirhcm

sirhcm commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Got it. Sounds like we should target API 30 for now and then worry about updating to mesa 26.2 separately. I'm assuming that pytest run with NULL:IR3:a630 passing is doing that?

@rishavsanjay

Copy link
Copy Markdown
Author

yep, that’s the NULL:IR3:a630 compiler-only path.

I’ve bumped the Android build/wheel to API 30 for now and added the explicit Termux pip install instructions to the README.

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.

2 participants