Investigation of gobject introspection with a view to cross compiling
Packages produce
- A text (xml) .gir file detailing the Gobject API of the package
- An encoded .typelib file encapsulating that data in a format readable by the gobject introspection library libgirepository.so
See An ASCII art representation
The problem for cross compilation is that g-ir-scanner runs (or loads) the target binary to query it regarding it's Gobject API.
As of May 2011 Debian has a smaller number of introspected packages than ubuntu, although for a larger number of architectures.
Note that gtk-doc may run an introspection scanner - this has not been considered below.
Current cross builds of such packages have --gtk-doc-enabled=no, or similar, passed to their configuration.
Conclusions after the investigations described below
- .gir files will differ across register widths
- For identical register widths .gir files will hardly vary across architectures
- armel uses gles, not gl
- .typelib files will differ across register widths
- For identical register widths .typelib files will vary fairly often
- This is because the .typelib file format is not architecture agnostic - files may vary because of endianness of variables bigger than one byte, and because of structure packing
- TODO: Do typelibs containing floating point numbers? If so this will provide another source of variation.
However, since gobject introspection is not currently used during the boot process, it is possible to cross compile those packages using gobject introspection by satisfying the package .gir & .typelib requirements with copies of the host files (provided the host & target have the same register width).
In the short term it may become necessary, should the boot process use gobject introspection, to provide a tool to reformat host.typelib files into a byte stream and then reformat this into the target architecture format.
Ideally, in the long term, the gobject introspection g-ir-compiler should be rewritten such that .typelib files, and/or the tools which use them, are architecture agnostic.
Investigation of the Ubuntu introspected packages
All .gir & .typelib files removed from a natty VMWare image
- Image still booted (Ubuntu only - Unity not tested since unavailable in VM)
All available .typelib & .gir files were extracted for the i386, amd64 & armel architectures:
Buzztard files not installable - see https://bugs.launchpad.net/ubuntu/+source/buzztard/+bug/677382.
GnomeGamesSupport installs to incorrect directory - https://bugs.launchpad.net/ubuntu/+source/gnome-games/+bug/777017 raised.
Mutter installs to incorrect directory - https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/777130 raised.
- .gir files were diffed
- Only observed difference in installed files
armel is built for embedded graphics
Clutter-1.0.gir - amd64 or i386 to armel < <constant name="COGL" value="gl"> --- > <constant name="COGL" value="gles"> < <constant name="FLAVOUR" value="glx"> --- > <constant name="FLAVOUR" value="eglx"> < <constant name="WINDOWING_GLX" value="1"> --- > <constant name="WINDOWING_EGL" value="1">
Glib shows 64/32 bit differences
GLib-2.0.gir - amd64 to both armel or i386 < <constant name="GINT64_FORMAT" value="li"> --- > <constant name="GINT64_FORMAT" value="lli"> < <constant name="GINT64_MODIFIER" value="l"> --- > <constant name="GINT64_MODIFIER" value="ll"> < <constant name="GINTPTR_FORMAT" value="li"> --- > <constant name="GINTPTR_FORMAT" value="i"> < <constant name="GINTPTR_MODIFIER" value="l"> --- > <constant name="GINTPTR_MODIFIER" value=""> < <constant name="GSIZE_FORMAT" value="lu"> --- > <constant name="GSIZE_FORMAT" value="u"> < <constant name="GSIZE_MODIFIER" value="l"> --- > <constant name="GSIZE_MODIFIER" value=""> < <constant name="GSSIZE_FORMAT" value="li"> --- > <constant name="GSSIZE_FORMAT" value="i"> < <constant name="GUINT64_FORMAT" value="lu"> --- > <constant name="GUINT64_FORMAT" value="llu"> < <constant name="GUINTPTR_FORMAT" value="lu"> --- > <constant name="GUINTPTR_FORMAT" value="u"> < <constant name="SIZEOF_LONG" value="8"> --- > <constant name="SIZEOF_LONG" value="4"> < <constant name="SIZEOF_SIZE_T" value="8"> --- > <constant name="SIZEOF_SIZE_T" value="4"> < <constant name="SIZEOF_VOID_P" value="8"> --- > <constant name="SIZEOF_VOID_P" value="4"> < <array zero-terminated="0" c:type="gchar" fixed-size="40"> --- > <array zero-terminated="0" c:type="gchar" fixed-size="24"> < <array zero-terminated="0" c:type="gchar" fixed-size="8"> --- > <array zero-terminated="0" c:type="gchar" fixed-size="4"> < <constant name="VA_COPY_AS_ARRAY" value="1"> < <type name="gint" c:type="gint"/> < </constant>
Hence host .gir files could be substituted, providing the host register width matches that of the target, with just clutter needing manual intervention.
- .typelib files were compared
- Many more differences were observed. However, if g-ir-generate was used to convert back to .gir files few diffrences were observed in the resulting files.
- The embedded graphics as above in Clutter
- A difference where the c:prefix gets set wrongly as in:
- Many more differences were observed. However, if g-ir-generate was used to convert back to .gir files few diffrences were observed in the resulting files.
======= GstVideo-0.10.typelib.gir ========= 12,14c12 < <namespace name="GstVideo" version="0.10" shared-library="libgstvideo-0.10.so.0" c:prefix="GOBJ < METADATA < "> --- > <namespace name="GstVideo" version="0.10" shared-library="libgstvideo-0.10.so.0" c:prefix="Gst">
This difference was observed in amd64, i386 & armel conversions, so cause may be a problem with g-ir-generate. However, more failures were observed with armel files only. TODO Investigate further
TODO Establish the cause of the differences in the typelib files
- Uncleared storage?
- Bad armel g-ir-compiler?
- Compile armel .girs on i386
- Compile i386 girs on armel
TODO Write a tester/test framework to exercise armel typelibs on i386, i386 typelibs on armel
- Try detecting dependence on typelibs
- make a i386 VM & replace all typelibs with armel typelibs
TODO Is gobject introspection currently used during bootup/login
Delete all typelibs & girs form VMWare natty image & reboot.
Delete all from ALIP image & reboot.
Recompiling from gir
TODO Recompile i386 girs on i386 - are the typelibs identical?
If the armel girs are recompiled on i386 fewer of the resulting typelibs differ from the installed i386 typelibs.
Recompilation performed in chroot emptied of installed host .girs & .typelibs
Still different
ClutterGst-1.0.typelib
- GES-0.10.typelib
- GIRepository-2.0.typelib
- GMenu-2.0.typelib
- GSSDP-1.0.typelib
- GTop-2.0.typelib
- GUPnPAV-1.0.typelib
- GUdev-1.0.typelib
- Gda-4.0.typelib
- Gdk-3.0.typelib
GdkPixbuf-2.0.typelib
- Grip-0.1.typelib
GstPbutils-0.10.typelib
GstRtp-0.10.typelib
GstRtspServer-0.10.typelib
GstVideo-0.10.typelib
- Gtk-3.0.typelib
- JSCore-1.0.typelib
- JSCore-3.0.typelib
- LightDM-0.typelib
PanelApplet-3.0.typelib
PangoXft-1.0.typelib
PolkitAgent-1.0.typelib
TotemPlParser-1.0.typelib
Now the same
- GIRepository-2.0
- GLib-2.0
- GObject-2.0
- Gdk-2.0
- Gst-0.10
GstApp-0.10
GstAudio-0.10
GstBase-0.10
GstCheck-0.10
GstController-0.10
GstFft-0.10
GstInterfaces-0.10
GstNet-0.10
GstNetBufferbuffer-0.10
GstRiff-0.10
GstRtsp-0.10
GstSdp-0.10
GstTag-0.10
- Gtk-2.0
- Pango-1.0
PangoCairo-1.0
- UPowerGlib-1.0
- fontconfig-2.0
- xfixes-4.0
Continuous recompilation of the girs reveals that the compiler is not always consistent.
The typelibs listed below may differ between compilations.
Differences are only of 1 to 3 bytes.
for n in \ GUPnPAV-1.0.typelib \ GstPbutils-0.10.typelib \ GstVideo-0.10.typelib \ LightDM-0.typelib \ PanelApplet-3.0.typelib \ TotemPlParser-1.0.typelib do t=`basename $n .typelib` echo "$t =========================" echo "Set up first previous" g-ir-compiler --output recompiled/from_armel/$n.previous --includedir extracted/armel/usr/share/gir-1.0 extracted/armel/usr/share/gir-1.0/$t.gir while [ 1 ] do g-ir-compiler --output recompiled/from_armel/$n --includedir extracted/armel/usr/share/gir-1.0 extracted/armel/usr/share/gir-1.0/$t.gir cmp -l recompiled/from_armel/$n recompiled/from_armel/$n.previous if [ $? -eq 0 ] then echo "Same" mv recompiled/from_armel/$n recompiled/from_armel/$n.previous else echo "They differ" break fi done done
PeterPearse/GobjectIntrospection (last modified 2011-05-10 13:14:09)