GNOME Bugzilla – Bug 699690
Cross-compilation broken as of 3.9.0 due to extract-strings tool
Last modified: 2013-05-13 15:13:00 UTC
I just tried to cross-compile gtk 3.9.0 on a Fedora Linux host for the Win32 target (i686-w64-mingw32) but I found out that the build failed. As of commit d90ddf85f6ce211994e4a784a2211f57bf79e3f7 a new tool was introduced called extract-strings which is automatically compiled while building gtk. This tool will then be executed later on in gtk build process to extract strings from .ui files. However, when cross-compiling it isn't possible to run cross-compiled binaries. Therefore the build fails like can be seen at http://koji.fedoraproject.org/koji/getfile?taskID=5332017&name=build.log IMHO tools like extract-strings should be compiled using the host compiler, not with the target compiler so they can be executed later on in the build process
gtk+ already has infrastructure to do this (gtkupdateiconcache) so it won't be *that* tricky.
(In reply to comment #1) > gtk+ already has infrastructure to do this (gtkupdateiconcache) so it won't be > *that* tricky. The infrastructure for gtkupdateiconcache does not work well unfortunately. See https://bugzilla.gnome.org/show_bug.cgi?id=696951
Created attachment 243860 [details] [review] Build extract-strings tool for build system This fixes cross compiling where build system != host system.
Thanks for the patch. Just tried it on Fedora (to cross-compile for the win32 target), but it failed: gcc -mms-bitfields -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -g -O2 extract-strings.c -L/usr/i686-w64-mingw32/sys-root/mingw/lib -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -o extract-strings gcc: error: extract-strings.c: No such file or directory make: *** [extract-strings] Error 1 My guess is that this is caused by the fact that I'm doing an out-of-source-tree build
The CFLAGS also seem to be invalid, they're the CFLAGS which are needed for cross-compiled binaries and shouldn't be used to build native binaries
(In reply to comment #5) > The CFLAGS also seem to be invalid, they're the CFLAGS which are needed for > cross-compiled binaries and shouldn't be used to build native binaries Are you setting PKG_CONFIG_PATH when running configure? That would mess up the system pkg-config.
Created attachment 243863 [details] [review] Build extract-strings tool for build system This fixes cross compiling where build system != host system.
(In reply to comment #4) > Thanks for the patch. Just tried it on Fedora (to cross-compile for the win32 > target), but it failed: > > gcc -mms-bitfields -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 > -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -g -O2 > extract-strings.c -L/usr/i686-w64-mingw32/sys-root/mingw/lib -lgobject-2.0 > -lgmodule-2.0 -lglib-2.0 -lintl -o extract-strings > gcc: error: extract-strings.c: No such file or directory > make: *** [extract-strings] Error 1 > > My guess is that this is caused by the fact that I'm doing an > out-of-source-tree build Can you try the new patch 243863?
(In reply to comment #6) > Are you setting PKG_CONFIG_PATH when running configure? That would mess up the > system pkg-config. PKG_CONFIG_PATH isn't set in our build, but PKG_CONFIG_LIBDIR is (and points to the cross-compiled environment). We've also got a i686-w64-mingw32-pkg-config available which uses the cross-compiled environment directly, but AFAIK the configure script isn't searching for it ($host-pkg-config). Once the configure script is able to find $host-pkg-config then we can remove the PKG_CONFIG_LIBDIR override I'll try out your updated patch to see if the 'No such file or directory' issue is resolved with it
The 'No such file or directory' issue is resolved with your latest patch. As expected the compilation of extract-strings.c fails due to the invalid CFLAGS
Okay, I did some more testing here. For this patch to work the environment variables PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR have to be unset and the environment variable PKG_CONFIG has to point to the cross-compiler aware version of pkg-config ($host-pkg-config). With these conditions gtk+ can be built using a cross-compiler again. I think other users will eventually run into this issue as well. Perhaps it would be useful to add a note about this subject to the release notes?
(In reply to comment #11) > Okay, I did some more testing here. For this patch to work the environment > variables PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR have to be unset and the > environment variable PKG_CONFIG has to point to the cross-compiler aware > version of pkg-config ($host-pkg-config). Doesn't it find $host-pkg-config automatically when you do not set PKG_CONFIG?
Apparently PKG_CONFIG doesn't have to be set: $ unset PKG_CONFIG $ echo $PKG_CONFIG $ ../configure --host=i686-w64-mingw32 --build=x86_64-redhat-linux-gnu --target=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32/sys-root/mingw --exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw --bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin --sbindir=/usr/i686-w64-mingw32/sys-root/mingw/sbin --sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc --datadir=/usr/i686-w64-mingw32/sys-root/mingw/share --includedir=/usr/i686-w64-mingw32/sys-root/mingw/include --libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib --libexecdir=/usr/i686-w64-mingw32/sys-root/mingw/libexec --localstatedir=/usr/i686-w64-mingw32/sys-root/mingw/var --sharedstatedir=/usr/i686-w64-mingw32/sys-root/mingw/com --mandir=/usr/i686-w64-mingw32/sys-root/mingw/share/man --infodir=/usr/i686-w64-mingw32/sys-root/mingw/share/info --enable-gtk2-dependency --disable-cups checking build system type... x86_64-redhat-linux-gnu checking host system type... i686-w64-mingw32 <snip> $ grep '^PKG_CONFIG' config.log PKG_CONFIG='/usr/bin/i686-w64-mingw32-pkg-config' PKG_CONFIG_FOR_BUILD='/usr/bin/pkg-config' PKG_CONFIG_LIBDIR='' PKG_CONFIG_PATH='' I think it's safe to assume that none of the environment variables PKG_CONFIG_PATH and PKG_CONFIG_LIDIR need to be set and that PKG_CONFIG may point to the cross-compiler aware version of pkg-config (although it's not required)
Created attachment 243983 [details] [review] Improved patch. Build extract-strings tool for build system This fixes cross compiling where build system != host system.