Skip to content
April 20, 2011 / pjcoup

Crossbuilding WebKit with a yocto toolchain: Part I, glib.

The yocto project is a pretty cool project which seems to want to be the ultimate embedded linux distro creation mechanism. Just pick your architecture, and start adding your own libraries and applications. Among the things available from the project are some pre-built cross compiling toolchains. Think of these as your gcc/ar/as/ranlib/ld toolchains, but with all of your “batteries included”, meaning lots of cross compiled libraries bundled with the tools themselves. Plus, some prebuilt qemu simulator images. See the quick start guide.
With all of that available out of the box, you’d think that cross compiling WebKit would be a breeze. Alas, even though the toolchain comes bundled with glib, it is not a new enough version for WebKit’s taste. And, there are still quirks to feel out (or, perhaps I’m not experienced using the yocto tools yet). So, let’s build it!

  • First, get a 2.28 source version of glib, available at Gnome’s glib download page.
  • Next, build a non-cross compiled version of the 2.28 source. This won’t be necessary if you already have an up-to-date 2.28 build on your system, with all the tools, but older glib builds aren’t current enough to bootstrap the cross compiled 2.28 build. If you start seeing things like can't find glib-compile-schemas, or GLib-Genmarshal-WARNING **: unknown type: VARIANT, make sure that you are using a native 2.28 build to bootstrap the 2.28 cross build.
  • Libtool is kindof funky. This could be because glib generates its own libtool that it tries to use. I got some link errors building gio, because it tried to link in the native libz instead of the cross-compiled libz. By editing the yocto libtool to look in the correct place for sed, grep, and use the correct tool names (on ubuntu), I seemed to get this to work. I would be interested if there in fact a better way. By messing with ZLIB_* environment variables, I was able to switch one link error (wrong arch), for another (undefined symbols for things downstream from gio)…it looks like the libz dependency didn’t make it into libgio-2.0.la‘s dependency_libs.

Once you have a cross compiled glib 2.28 version, you will need to integrate this with the yocto toolchain.
Next time…build WebKit with this toolchain.

Update: I forgot to put how we got here (for the i686/mips yocto-poky cross-toolchain):

$ wget http://ftp.gnome.org/pub/gnome/sources/glib/2.28/glib-2.28.6.tar.bz2
$ tar jxvf glib-2.28.6.tar.bz2
$ cd glib-2.28.6
$ mkdir build-x86
$ cd build-x86
$ ../configure --prefix=/path/to/install; make; make install
(at this point you should have a glib build with the binaries needed to bootstrap the cross build. Now, switch to the cross-toolchain).
$ source /opt/poky/1.0/environment-setup-mips-poky-linux
$ export PATH=/path/to/install/bin:$PATH
$ mkdir ../build-mips
$ cd ../build-mips
$ mkdir build-mips
$ ../configure --host=mips-poky-linux --build=i686-pokysdk-linux --prefix=/opt/poky/1.0/sysroots/mips-poky-linux/usr/local
$ cp /opt/poky/1.0/sysroots/i686-pokysdk-linux/usr/bin/i686-pokysdk-libtool libtool

$ make; make install

3 Comments

Leave a Comment
  1. Aamer / Nov 29 2011 9:53 am

    “If you start seeing things like can’t find glib-compile-schemas, or GLib-Genmarshal-WARNING **: unknown type: VARIANT, make sure that you are using a native 2.28 build to bootstrap the 2.28 cross build.”

    This is a very very valuable line, and it ended my 2 days of search to compile latest glib 2.30.2.
    I was having glib 2.16 on my host system and was getting the errors exactly as you mentioned.

    Thanks a lot 🙂

    • pjcoup / Nov 29 2011 2:41 pm

      Glad it helped. I recall that I didn’t find any docs mentioning this, and people are usually left on their own to do cross-compiling.

  2. Al / Dec 1 2011 1:18 pm

    Thank you very, very much!
    I’ve wasted the whole morning trying to solve these errors.

    “This is a very very valuable line, and it ended my 2 days of search to compile latest glib 2.30.2.”

    Indeed 🙂

Leave a comment