From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxDry-0007Hs-Gl for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:54:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxDru-0002cn-6M for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:54:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxDrt-0002cc-Uj for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:54:18 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4AEDDC0D8035 for ; Fri, 13 Nov 2015 12:54:17 +0000 (UTC) Date: Fri, 13 Nov 2015 12:54:13 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151113125413.GG2456@work-vm> References: <1447414307-5295-1-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1447414307-5295-1-git-send-email-berrange@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] configure: sanity check the glib library that pkg-config finds List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Paolo Bonzini , qemu-devel@nongnu.org * Daniel P. Berrange (berrange@redhat.com) wrote: > Developers on 64-bit machines will often try to perform a > 32-bit build of QEMU by running >=20 > ./configure --extra-cflags=3D"-m32" >=20 > Unfortunately if PKG_CONFIG_LIBDIR is not set to point to > the location of the 32-bit pkg-config files, then configure > will silently pick up the 64-bit pkg-config files and still > succeed. Having fallen into this trap, thanks; seems to do the trick on RHEL7.x: # /root/try/../qemu/configure --prefix=3D/root/try --enable-trace-backen= ds=3Dstderr --extra-cflags=3D"-m32" --extra-ldflags=3D"-m32" ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. You probably need to set PKG_CONFIG_LIBDIR to point to the right pkg-config files for your build target # export PKG_CONFIG_LIBDIR=3D/usr/lib/pkgconfig # /root/try/../qemu/configure --prefix=3D/root/try --enable-trace-backen= ds=3Dstderr --extra-cflags=3D"-m32" --extra-ldflags=3D"-m32" Install prefix /root/try BIOS directory /root/try/share/qemu .... and the gsize def ( https://developer.gnome.org/glib/stable/glib-Basic-Ty= pes.html#gsize ) does say it should always match size_t size. Reviewed-by: Dr. David Alan Gilbert Dave >=20 > This causes a problem for glib because it means QEMU will > be pulling in /usr/lib64/glib-2.0/include/glibconfig.h > instead of /usr/lib/glib-2.0/include/glibconfig.h >=20 > This causes problems because the 'gsize' type (defined as > 'unsigned long') will no longer be fully compatible with > the 'size_t' type (defined as 'unsigned int'). Although > both are the same size, the compiler refuses to allow > casts from 'unsigned long *' to 'unsigned int *' as they > are different pointer types. This results in non-obvious > compiler errors when building QEMU eg >=20 > qga/commands-posix.c: In function =E2=80=98qmp_guest_set_user_password=E2= =80=99: > qga/commands-posix.c:1912:55: error: passing argument 2 of =E2=80=98g_b= ase64_decode=E2=80=99 from incompatible pointer type [-Werror=3Dincompati= ble-pointer-types] > rawpasswddata =3D (char *)g_base64_decode(password, &rawpasswdlen)= ; > ^ > In file included from /usr/include/glib-2.0/glib.h:35:0, > from qga/commands-posix.c:14: > /usr/include/glib-2.0/glib/gbase64.h:52:9: note: expected =E2=80=98gsiz= e * {aka long unsigned int *}=E2=80=99 but argument is of type =E2=80=98s= ize_t * {aka unsigned int *}=E2=80=99 > guchar *g_base64_decode (const gchar *text, > ^ > cc1: all warnings being treated as errors >=20 > To detect this problem, add a check to configure that > verifies that GLIB_SIZEOF_SIZE_T matches sizeof(size_t). > If this fails print a warning suggesting that the dev > probably needs to set PKG_CONFIG_LIBDIR. >=20 > On Fedora x86_64 it passes with any of: >=20 > # ./configure > # PKG_CONFIG_LIBDIR=3D/usr/lib/pkgconfig ./configure --extra-cflags=3D= "-m32" > # PKG_CONFIG_LIBDIR=3D/usr/lib64/pkgconfig ./configure --extra-cflags=3D= "-m64" >=20 > And fails with a mis-match >=20 > # PKG_CONFIG_LIBDIR=3D/usr/lib64/pkgconfig ./configure --extra-cflags=3D= "-m32" > # PKG_CONFIG_LIBDIR=3D/usr/lib/pkgconfig ./configure --extra-cflags=3D= "-m64" >=20 > ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. > You probably need to set PKG_CONFIG_LIBDIR > to point to the right pkg-config files for your > build target >=20 > Signed-off-by: Daniel P. Berrange > --- > Changed in v2: >=20 > - Add 'return 0' to silence compiler warning on some > platforms about returning without a value >=20 > configure | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) >=20 > diff --git a/configure b/configure > index f75df4b..c53334f 100755 > --- a/configure > +++ b/configure > @@ -2939,6 +2939,27 @@ for i in $glib_modules; do > fi > done > =20 > +# Sanity check that the current size_t matches the > +# size that glib thinks it should be. This catches > +# problems on multi-arch where people try to build > +# 32-bit QEMU while pointing at 64-bit glib headers > +cat > $TMPC < +#include > +#include > + > +int main(void) { > + G_STATIC_ASSERT(sizeof(size_t) =3D=3D GLIB_SIZEOF_SIZE_T); > + return 0; > +} > +EOF > + > +if ! compile_prog "-Werror $CFLAGS" "$LIBS" ; then > + error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ > + "You probably need to set PKG_CONFIG_LIBDIR"\ > + "to point to the right pkg-config files for your"\ > + "build target" > +fi > + > # g_test_trap_subprocess added in 2.38. Used by some tests. > glib_subprocess=3Dyes > if ! $pkg_config --atleast-version=3D2.38 glib-2.0; then > --=20 > 2.5.0 >=20 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK