From D Wiki
Jump to: navigation, search

GDC on Android

Note: This tutorial should give you a usable GDC for Android. GDC on Android is not supported and especially phobos may need some updates to be usable.


Not yet available

Building a toolchain with GDC for the Android NDK

Linux host

Install all packages required for building the NDK. Then:

mkdir workdir
cd workdir
git clone
git clone
mkdir src
mkdir dest
./ndk/build/tools/ /home/build/workdir/src
./ndk/build/tools/ --minimal

git clone
cd GDC
git checkout gdc-4.9
./ /home/build/workdir/src/gcc/gcc-4.9
cd ../

./ndk/build/tools/ /home/build/workdir/src /home/build/workdir/dest arm-linux-androideabi-4.9 --verbose --try-64

Building unittests

cd /tmp/ndk-/build/toolchain/gcc-4.9/arm-linux-androideabi/libphobos/libdruntime
make unittest
cd /tmp/ndk-/build/toolchain/gcc-4.9/arm-linux-androideabi/libphobos/src
make unittest

Debugging help

adb push unittest /data/local/tmp
# gdbserver is in standard NDK builds
adb push prebuilt/android-arm/gdbserver/gdbserver /data/local/tmp 
adb forward tcp:5039 tcp:5039

adb shell
cd /data/local/tmp
./gdbserver :5039 unittest

./toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb unittest
<gdb> target extended-remote :5039
<gdb> continue

# Usually android devices dont have hardware watchpoints, to disable:
<gdb> set can-use-hw-watchpoints 0


  • phobos
  • shared libraries
  • GC: We currently scan the data segment using etext and _end symbols. This doesn't work for dynamic libraries and it sometimes doesn't work for static libraries: In some cases there's a gap between etext and the start of the data section. Accessing this gap results in a segfault on some systems. Solution is to implement sections_elf for Android.