GNOME Bugzilla – Bug 560282
Cross-compilation and field offsets
Last modified: 2018-02-08 11:46:15 UTC
The field offset computation in giroffsets.c won't work when cross-compiling. - There is usage of size/alignment information from libffi, which is right for the host environment instead of the target environment. - The enum-width computation trick also depends on the host and target environments being the same. So, this needs at some point to be reworked a bit to do the determination of ABI specifics in configure.ac. - Some things (like the widths of the enums) can be checked with AC_CHECK_SIZEOF() - Other things could probably be handled by doing magic similar to the way AC_CHECK_SIZEOF() works, though not sure how worthwhile figuring out deep magic is. - The remainder can be mopped up by doing runtime checks and allowing overriding the checks with a cache file. (http://library.gnome.org/devel/glib/stable/glib-cross-compiling.html describes using a cache from a user perspective.)
For now we should add a check to abort if cross-compiling then probably.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Created attachment 299339 [details] proof of concept Here's a proof of concept for what I expect a solution to this problem would look like...
Basically, we produce a binary that contains an array of ints with constant expression initialisers (sizeof, struct offsets, etc). We put magic values on either side of that array and then we scan the resulting compiler output for those magic values in order to discover the values of the expressions we put in.
Cross-compiling introspection data is basically a lost cause anyway, given that we need to generate, compile, and run code to introspection all object-like GTypes for properties, signals, parent types, and implemented interfaces. The recommended best practice for cross-compilation is to actually run the scanner under a wrapper script like qemu-arm-static; that approach requires a native build of gobject-introspection in any case, and that's not a huge deal.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/6.