Support Android libc (bionic) for cross compilation
For dynamic libc, this can be done through the usual libc-abi-tools approach. For static libc, we'd have to either import the C code, or do it through #2879. I personally think most would find dynamic linking preferable on Android to reduce app download size, though, and there also aren't the usual problems with libc that you have on desktop Linux.
ooo, that's exciting good luck
Really excited about this — replacing the NDK with a clean Zig-native approach is a great direction. What could be the first steps to help?
I know this is a bit orthogonal (since .dex isn’t native code), but in my project craftdex, I generate .dex from .smali. It still needs a lot of work, but while building the IR and codegen, I started wondering:
what if we could emit .dex directly from Zig AIR, like SPIR-V codegen?
This could allow writing limited Zig functions that compile straight to Dalvik bytecode — skipping the JVM and smali entirely. Could something like this ever be integrated into the Zig compiler with a proper implementation? Or is it better left as an external toolchain?
It would be interesting to mix both .dex and native code — and potentially open a new field for Zig.
Really excited about this — replacing the NDK with a clean Zig-native approach is a great direction. What could be the first steps to help?
Realistically, contributors can't help with issues like this one. There are at least 2 major steps in the process of adding/updating support for a libc - importing headers and generating the abilists file - which must be done by a Zig core team member for security reasons. And the build artifacts required for those steps therefore also must be produced by a Zig core team member.
So it's just a matter of me finding the time to go through the process of building bionic for each target using the official Android build system, and then repeating all the usual steps required for adding a new libc.
I suspect that building bionic is going to be the most time-consuming part; if there's anything my years of working on Mono's Android port has taught me, it's that "simple" is not a word known to Android engineers.
what if we could emit .dex directly from Zig AIR, like SPIR-V codegen?
This could allow writing limited Zig functions that compile straight to Dalvik bytecode — skipping the JVM and smali entirely. Could something like this ever be integrated into the Zig compiler with a proper implementation? Or is it better left as an external toolchain?
It would be interesting to mix both .dex and native code — and potentially open a new field for Zig.
This all depends on how powerful Dalvik bytecode is. Normal JVM bytecode is far too limited for a language like Zig. Can Dalvik bytecode operate directly on native memory? Is it bitness-aware and/or endian-aware?
Anyway, I would suggest opening a separate issue for exploring that topic.