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 699690 - Cross-compilation broken as of 3.9.0 due to extract-strings tool
Cross-compilation broken as of 3.9.0 due to extract-strings tool
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.9.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-05-05 00:21 UTC by Erik van Pienbroek
Modified: 2013-05-13 15:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Build extract-strings tool for build system (3.99 KB, patch)
2013-05-11 18:30 UTC, Hib Eris
none Details | Review
Build extract-strings tool for build system (4.06 KB, patch)
2013-05-11 19:26 UTC, Hib Eris
none Details | Review
Improved patch. (4.11 KB, patch)
2013-05-13 12:44 UTC, Hib Eris
committed Details | Review

Description Erik van Pienbroek 2013-05-05 00:21:22 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
Comment 1 Ross Burton 2013-05-09 13:26:31 UTC
gtk+ already has infrastructure to do this (gtkupdateiconcache) so it won't be *that* tricky.
Comment 2 Hib Eris 2013-05-09 15:21:01 UTC
(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
Comment 3 Hib Eris 2013-05-11 18:30:16 UTC
Created attachment 243860 [details] [review]
Build extract-strings tool for build system

This fixes cross compiling where build system != host system.
Comment 4 Erik van Pienbroek 2013-05-11 18:34:34 UTC
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
Comment 5 Erik van Pienbroek 2013-05-11 18:36:25 UTC
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
Comment 6 Hib Eris 2013-05-11 18:41:01 UTC
(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.
Comment 7 Hib Eris 2013-05-11 19:26:51 UTC
Created attachment 243863 [details] [review]
Build extract-strings tool for build system

This fixes cross compiling where build system != host system.
Comment 8 Hib Eris 2013-05-11 19:27:56 UTC
(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?
Comment 9 Erik van Pienbroek 2013-05-11 19:49:28 UTC
(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
Comment 10 Erik van Pienbroek 2013-05-11 19:53:07 UTC
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
Comment 11 Erik van Pienbroek 2013-05-11 20:14:49 UTC
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?
Comment 12 Hib Eris 2013-05-11 21:09:09 UTC
(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?
Comment 13 Erik van Pienbroek 2013-05-12 13:38:58 UTC
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)
Comment 14 Hib Eris 2013-05-13 12:44:39 UTC
Created attachment 243983 [details] [review]
Improved patch.

Build extract-strings tool for build system

This fixes cross compiling where build system != host system.