GDC/Installation/Android

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.

Binaries

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 https://android.googlesource.com/platform/ndk
git clone https://android.googlesource.com/platform/development
mkdir src
mkdir dest
./ndk/build/tools/download-toolchain-sources.sh /home/build/workdir/src
./ndk/build/tools/gen-platforms.sh --minimal

git clone git@github.com:D-Programming-GDC/GDC.git
cd GDC
git checkout gdc-4.9
./setup-gcc.sh /home/build/workdir/src/gcc/gcc-4.9
cd ../

./ndk/build/tools/build-gcc.sh /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
su
cd /data/local/tmp
./unittest
./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

TODO

  • 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.