Due to the removal of GCC in NDK r18, I was curious if I could get mGBA to compile with Clang and how it’d perform. I’m just posting my results in case anyone else was curious.
Here’s a patch that allows compilation with Clang: https://gist.github.com/GrieverV/a949c6f59577e3b0b6b2b955e7b17381
Patch notes:
- Only armeabi-v7a’s Makefile was ported
- Assumes you’re using a custom toolchain generated using
make_standalone_toolchain.py --arch arm --api 22 --stl=libc++ --install-dir=$HOME/ndk-arm-22
. You probably only need to pass-target
and slightly change some paths to work with the default NDK toolchain. -
ANDROID_TOOLCHAIN
needs to be set to your toolchain path -
-DHAVE_STRTOF_L
-DHAVE_XLOCALE
are now required - The
DEBUG
check always evaluated to true on my system so I changed it to better match similar check inMakefile.common
which only enablesDEBUG
if explicitly set -
futimes
does not seem to be available butfutimens
is, added android ifdef to fix compilation - NDK r16(?) switched to unified headers which significantly simplifies includes
-
-mthumb -mtune=cortex-a72.cortex-a53 -mfpu=neon -flto -funroll-loops
compiler flags were added - Due to using Android 22,
-mthumb
and-mfpu=neon
, binaries produced using this patch likely require Android >=5.1 and a CPU that supports Thumb-2 and NEON.
Here’s a mGBA core produced using the above patch: https://mega.nz/#!VthgSawZ!8KoqEyiQTs1s60Iakyb4vmtGW9pdalwKqTgF2rT-wsM
libretro/mgba abf712f w/ upstream mgba-emu/mgba master (575adca) merged
I haven’t done much performance testing, but I believe performance was similar to the core produced by the buildbot. -mthumb
appeared to give ~5% increase in fps and ~20% reduction in size. I haven’t tested with/without other flags.