After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 645881 - Full port of glib-2.28.1 onto Android-ARM
Full port of glib-2.28.1 onto Android-ARM
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
2.28.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
android
Depends on:
Blocks:
 
 
Reported: 2011-03-28 01:25 UTC by Shohyang Lim
Modified: 2013-04-17 10:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for porting full glib-2.28 onto android-arm (14.13 KB, patch)
2011-03-28 01:25 UTC, Shohyang Lim
none Details | Review
modified patch for android-glib-porting (14.13 KB, patch)
2011-03-28 01:31 UTC, Shohyang Lim
none Details | Review
android: don't pass -pthreads to the toolchain (1.05 KB, patch)
2011-08-31 16:11 UTC, Robert Bragg
reviewed Details | Review
Include missing headers when checking res_query from bind (1.37 KB, patch)
2011-08-31 16:12 UTC, Robert Bragg
reviewed Details | Review
android: avoid dereferencing lconv->decimal_place (1.72 KB, patch)
2011-08-31 16:13 UTC, Robert Bragg
none Details | Review
utils: avoid redundant set/endpwent around getpwuid (1.02 KB, patch)
2011-08-31 16:14 UTC, Robert Bragg
committed Details | Review
pass all 5 args to prctl (891 bytes, patch)
2011-08-31 16:15 UTC, Robert Bragg
accepted-commit_now Details | Review
Reference script for how I cross compiled glib and dependencies (3.87 KB, text/x-sh)
2011-08-31 16:25 UTC, Robert Bragg
  Details

Description Shohyang Lim 2011-03-28 01:25:15 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?
Comment 1 Shohyang Lim 2011-03-28 01:31:32 UTC
Created attachment 184406 [details] [review]
modified patch for android-glib-porting
Comment 2 Allison Karlitskaya (desrt) 2011-04-11 15:36:14 UTC
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.
Comment 3 Colin Walters 2011-06-02 18:01:55 UTC
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.
Comment 4 Robert Bragg 2011-08-31 16:09:24 UTC
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.
Comment 5 Robert Bragg 2011-08-31 16:11:31 UTC
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.
Comment 6 Robert Bragg 2011-08-31 16:12:39 UTC
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
Comment 7 Robert Bragg 2011-08-31 16:13:28 UTC
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 "."
Comment 8 Robert Bragg 2011-08-31 16:14:11 UTC
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.
Comment 9 Robert Bragg 2011-08-31 16:15:05 UTC
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.
Comment 10 Robert Bragg 2011-08-31 16:25:53 UTC
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 11 Dan Winship 2011-09-22 14:05:54 UTC
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.
Comment 12 Sebastian Dröge (slomo) 2013-04-16 08:28:49 UTC
See also bug #689223 , which has similar changes for latest git master and is used since some time for the GStreamer SDK on Android.
Comment 13 Colin Walters 2013-04-16 09:34:32 UTC
Review of attachment 195319 [details] [review]:

Sure, though I don't know why bionic didn't use varargs for the prototype.
Comment 14 Colin Walters 2013-04-16 09:36:22 UTC
Review of attachment 195318 [details] [review]:

Right.
Comment 15 Colin Walters 2013-04-16 09:37:03 UTC
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 16 Colin Walters 2013-04-17 08:01:43 UTC
Comment on attachment 195319 [details] [review]
pass all 5 args to prctl

This code is actually gone in master.
Comment 17 Colin Walters 2013-04-17 10:24:04 UTC
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!