GNOME Bugzilla – Bug 645881
Full port of glib-2.28.1 onto Android-ARM
Last modified: 2013-04-17 10:24:04 UTC
Created attachment 184405 [details] [review] Patch for porting full glib-2.28 onto android-arm This is my instructions and patches for full port of glib-2.28.1 onto Android-ARM. It's still nascent and raw though, more hacking is needed! These are my steps, suppose you're familiar with cross compiling. 1.I use the android NDK provided by Mozzila which has nearly full C++ support: http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2 and I have modified Andrew Ross's perl script:agcc to extract and use the toolchain from this NDK (attached) 2. Then I cross compile glib2.28.1 onto Android in this order: 1)libiconv-1.13.1.tar.gz: configured by: CC=agcc CXX=agcc LD=arm-eabi-ld RANLIB=arm-eabi-ranlib \ PKG_CONFIG_LIBDIR=/data/local/lib/pkgconfig:/data/local/share/pkgconfig/ \ ./configure \ --prefix=/data/local \ --host=arm-eabi-linux \ --enable-shared \ 2)gettext-0.18.1.1.tar.gz configured by: CC=agcc CPPFLAGS="-I/data/local/include" LDFLAGS="-L/data/local/lib" CXX=agcc LD=arm-eabi-ld RANLIB=arm-eabi-ranlib \ PKG_CONFIG_LIBDIR=/data/local/lib/pkgconfig:/data/local/share/pkgconfig/ \ ./configure \ --prefix=/data/local \ --host=arm-eabi-linux \ --enable-shared \ --cache-file=arm.cache \ --without-included-regex \ --disable-java --disable-openmp --without-libiconv-prefix --without-libintl-prefix --without-libglib-2.0-prefix --without-libcroco-0.6-prefix --with-included-libxml --without-libncurses-prefix --without-libtermcap-prefix --without-libcurses-prefix --without-libexpat-prefix --without-emacs But the build of gettext will not fully succeed,never mind, I need only libintl.so so just make install. 3) glib-2.28.1.tar.gz 1st, do patching with my attached file #patch -p0 < glib-android.patch 2nd, write this into the cache file arm.cache: #cat > arm.cache ac_cv_android_arm=yes glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=no ac_cv_func_posix_getgrgid_r=no ctrl-D 3rd, make sure you have the tools such as glib-genmarshaller of right vision in your host machine(you may need to first install glib on your host machine) 4th, autoconf;then configured the same as libiconv. 5td, make;make install That's it! Anybody can have a try especially on the patching from arpa/*.h files?
Created attachment 184406 [details] [review] modified patch for android-glib-porting
Thanks for the bug and patches, Shohyang Lim. I don't think that we can use the patches in their current state (since they are not very elegant) but it provides an extremely useful starting out point for figuring out what changes we need to make to get glib working properly on Android.
Hi Shohyang, Can you break up this patch into a series of logical changes, in "git format-patch" format, with comprehensible commit messages? Start with the configure.ac changes.
Hi, I recently took a look myself at porting glib to android for using Cogl and have looked at the patches attached here as well as similar patches I found for gstreamer's android port and have tried to come up with a fairly clean patchset that hopefully might help here. I still have some further work relating to mainloop integration + g_log integration do but am at the point where I can cross compile a complete glib for android and I think my patches are fairly minimal. One notable thing is that I rely on libbind for things like res_query which normally come from libresolv.so that isn't part of the android ndk. This avoids some of the hairy copying and pasting of arpa defines required in the current set of patches which I don't think can really work. I'll follow up with attachments. I made my patches against glib-2.29.2 but hopefully they all still apply against master or are trivial to rebase.
Created attachment 195315 [details] [review] android: don't pass -pthreads to the toolchain The android toolchain doesn't recognize the -pthreads argument so we skip the check as done for cygwin and darwin already.
Created attachment 195316 [details] [review] Include missing headers when checking res_query from bind When we fail to find a libresolv and fallback to checking libbind for res_query() we still need to include the following as we do for the libresolv checks: #include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> This patch makes sure to pass those include directives to AC_TRY_LINK
Created attachment 195317 [details] [review] android: avoid dereferencing lconv->decimal_place Android's shim locale.h simply declares the lconv struct as: struct lconv { }; When building on android we simply define the decimal point character to be "."
Created attachment 195318 [details] [review] utils: avoid redundant set/endpwent around getpwuid set/endpwent are only required for iterating through passwd entries using getpwent(). Since we are explicitly requesting a passwd entry for a uid then the set/endpwent calls are redundant. Removing these redundant calls is required for building on Android since their C library doesn't implement these.
Created attachment 195319 [details] [review] pass all 5 args to prctl Even though the PR_SET_PDEATHSIG option for prctl only implies significance for one additional argument we still need to pass dummy values for the remaining 3 arguments.
Created attachment 195322 [details] Reference script for how I cross compiled glib and dependencies For reference to show how I cross compiled glib and its dependencies I've attached a script I wrote as I was going. It no doubt it won't just work to run that script but at least someone interested can see how I did things. This is a work in progress but my plan initially is to land a cleaned up version of this script as a convenience script in Cogl to make it simple for developers to set themselves up a basic SDK for using Cogl on Android. I was using the r6 ndk from google. The config.sub and config.guess files referenced were just the latest upstream versions of these files required because the versions I currently have with Fedora can't cope with the arm-linux-androideabi host name.
Comment on attachment 195316 [details] [review] Include missing headers when checking res_query from bind >- AC_TRY_LINK([#include <resolv.h>], >+ AC_TRY_LINK([#include <sys/types.h> >+#include <netinet/in.h> >+#include <arpa/nameser.h> >+#include <resolv.h>], The indentation of this set of configure checks has changed since you made this patch. But this is ok to commit after reindenting to match the surrounding checks.
See also bug #689223 , which has similar changes for latest git master and is used since some time for the GStreamer SDK on Android.
Review of attachment 195319 [details] [review]: Sure, though I don't know why bionic didn't use varargs for the prototype.
Review of attachment 195318 [details] [review]: Right.
Review of attachment 195315 [details] [review]: This one looks like it could be rebased on top of the other bug, and check for bionic potentially.
Comment on attachment 195319 [details] [review] pass all 5 args to prctl This code is actually gone in master.
Ok, I think with parts of this that are now pushed, along with the stuff from bug 689223, we can now close this bug. Let's file any future Android work as separate patches. Thanks to everyone who contributed here!