bug#81211: #81211 31.0.90; Android build fails with current Java compilers

Johan Myréen <[email protected]> Thu, 30 Jul 2026 21:57:52 +0300
Newsgroups gmane.emacs.bugs
Message-ID <CA+TD5hiYPF54QjW6uGy2UWpp98qcZ=wmQ3DhP8uMq5TrUkYbAQ@mail.gmail.com>
On Wed, 29 Jul 2026 at 15:44, Sean Whitton <[email protected]> wrote:


> > I will need to investigate this anyway, because although I got the Java
> > version to compile, when I got a chance to test it on an Android device,
> *it
> > wouldn't install...* :-(
>
> This is pretty bad.  Let's hope that your investigations bear fruit, and
> hopefully Po Lu can chime in.  Thanks for looking.


I have found something odd when building the Android version. According to
src/java/INSTALL the configure script should be run as follows:

  ./configure --with-android=/path/to/android.jar \
     ANDROID_CC=/path/to/android/ndk/cc  \
     SDK_BUILD_TOOLS=/path/to/sdk/build/tools

In my case the path to the aarch64 cross compiler
is /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang

In the emacs/exec directory the linker is passed an obscure option
-Ttext=0x2000000000, which I presume is trying to say that the text segment
should be placed starting at address 0x200000000 (?):

/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
-c -O -g loader-aarch64.s -o loader-aarch64.o
clang: warning: argument unused during compilation: '-O'
[-Wunused-command-line-argume
nt]
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
-o loader -nostdlib -nostartfiles -static -Wl,-Ttext=0x2000000000
loader-aarch64.o

I don't know for which compiler/linker combination the Makefile is
generated for, since, as far as I can tell, both lld and GNU ld use the -T
switch to specify a linker script file. Anyway, the outcome of the linker
invocation above results in a huge binary file consisting mostly of null
bytes. The size of the file is 137436859800 bytes, which happens to be a
little less than 0x200000000. Likewise the file libloader.so, which is
included in the Android Emacs installer file is 137 GB in size; examining
an older emacs.apk file reveals that the correct size is about 7.3 kB.

I'm hoping for someone who knows more about the Android Emacs build process
to step forward and clarify what went wrong, and how to correct it.