From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKk56-0006z7-2J for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKk52-0000Ps-Cy for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:20:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKk52-0000Pi-4V for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:20:16 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7M8KCoj027193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 22 Aug 2014 04:20:13 -0400 Date: Fri, 22 Aug 2014 09:20:08 +0100 From: "Daniel P. Berrange" Message-ID: <20140822082008.GA8447@redhat.com> References: <53F55173.6070704@redhat.com> <20140821090328.GA32580@stefanha-thinkpad.redhat.com> <53F68A8E.4060105@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <53F68A8E.4060105@redhat.com> Subject: Re: [Qemu-devel] issue: linking 64bit glib when building for cpu=i386 Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: qemu-devel , Stefan Hajnoczi On Thu, Aug 21, 2014 at 08:10:54PM -0400, John Snow wrote: > I was running a series of tests on 32 and 64 bit hosts to test for > endianness and variable width issues when I noticed that I couldn't properly > perform a build of "make check" against a 32bit target from a 64bit host: > > ../../configure --cpu=i386 && make -j4 && make check > > This produces some warnings in tests-cutils about overflowing variables that > are of type guint64. It's been mentioned on the mailing lists before, > actually: http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg00452.html > > The problem is that guint64 is being aliased against "unsigned long", which > is only 4 bytes instead of the implied 8. This occurs because we link > against the 64bit headers for glib instead of the 32bit ones when we're > building for i386 from an x86_64 host. > > Our include flags wind up looking like: -I/usr/include/glib-2.0 but > -I/usr/lib64/glib-2.0/include > > I was discussing the problem with Stefan: > > On 08/21/2014 05:03 AM, Stefan Hajnoczi wrote: > >The problem is that pkg-config uses libdir=/usr/lib64 by default on > >amd64 hosts. It doesn't know that gcc -m32 is being used. > > > >This results in glib's 64-bit headers being used where guint64 is just > >unsigned long. On 32-bit hosts this is incorrect. > > > >Two workarounds: > > > >1. yum install pkgconfig.i686 and run it instead of pkgconfig.x86_64 > > > >2. Use the pkg-config --define-variable libdir=/usr/lib option > > > >You can set PKG_CONFIG=path/to/pkg-config.i686 on QEMU's ./configure > >command-line. > > > >This is all distro-specific :(. Any other solutions? > > > >Stefan > > > > I am not extremely well versed in configure or pkg-config ninjutsu, but I > must imagine that the ARCH/cpu variables we are setting in configure could > help us know to call the 32bit pkg-config instead of the native 64bit > version and fix this issue. > > Does anyone have any good ideas? Surely other projects must have run into > this elsewhere. Distros will install pkg-config .pc files for non-native architectures in a different location normally. The supported / recommended way to tell pkg-config to look in these alternative dirs is to set the env variable PKG_CONFIG_LIBDIR. This replaces the built-in default search directory that looks for native. So on a Fedora / RHELL system, to make pkg-config use 32-bit libs you want to set PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig which replaces the default location of /usr/lib64/pkgconfig. This is the same thing you'd need to do to build QEMU for say, mingw32 where you must set something like PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ Note, i say PKG_CONFIG_LIBDIR here, *not* PKG_CONFIG_PATH. The latter variable adds the default search path - you want to stop it looking in the default search path completely because it is the wrong arch, so must use PKG_CONFIG_LIBDIR Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|