From patchwork Mon Feb 8 17:02:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8252331 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC6CC9F1C1 for ; Mon, 8 Feb 2016 17:04:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEAD0203B7 for ; Mon, 8 Feb 2016 17:03:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23145203C3 for ; Mon, 8 Feb 2016 17:03:59 +0000 (UTC) Received: from localhost ([::1]:46838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpEE-0003TI-F3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Feb 2016 12:03:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpDp-00039O-Bn for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSpDi-0006ea-Rw for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:33 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:35222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpDi-0006eN-IW for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:26 -0500 Received: by mail-wm0-x22d.google.com with SMTP id c200so25235829wme.0 for ; Mon, 08 Feb 2016 09:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=pgQCqmwi/9ZEH7ZX1QY6Hrw6DF4GR55i7ToiZPVKNHQ=; b=Kc5qm0f2EIduIfrYGWrZY0bclMpByZ3tCIuTMb/9tCAf+hi0csQDZPf/dv45GdWwA3 TMdW1KhSYoyZ5C9SpcnK+iiH1tB5dSmXrVt5WfJ7ytFOo+Y8bNkYpvnh3F9X4FuwLinQ tx1+dndw0AX/0rDTlMzyG8NHjQL/n2vap5xCyGfShbyjqIihNgt5pSYqeHWOl8EgCBrV QAe1oP7J6KXUuJD9YN69+7SAJ3MYyUd/GHI01uKLScPpNbm/me6eKSbO7dWqEOBc8FD6 3e1NEczAsvZjQsDkDtA/RsEBYw2Kr7s4zHOkciJgNQvapasPIRDPXZuSMATSVyJUbbc0 TWHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=pgQCqmwi/9ZEH7ZX1QY6Hrw6DF4GR55i7ToiZPVKNHQ=; b=Z9tcWhoWOG282zMdPugtbuvZVD3JVGsBBtHR6Ea6sEft1aqvcJ+THgvHb1kIAhZOEV zqbE3shWLOvPw2TYr7L3jnP90LKT9HM0KdwSCG7qKfD0iplQWAc9OTlFRF4X2yEHnI3P 7dTGExrr+btwkXfdU1Qv2HrfzMI+cFC9w1lHtljwvL+OvWU27bYwnwzjNJK5WdirzzCK LWU7uJbNpoYqiVjgIgwURFJo6SARRHgSbASv5eGvTTpVSnZUNKinn1iD+s1hNwX5Dp2z xuBUfb7JGF7QnAuK5CtJyFGfwupm1+rVOF/938ltV+oThCaTA2XBrLqJchEgOZ9NHb3W 5x3g== X-Gm-Message-State: AG10YOSlt0DcZNWwNgD7YkIpBfiypg+W1m9BYybC3xTt/R6o5vpopcY1a/jUZyOORRtVPw== X-Received: by 10.28.19.204 with SMTP id 195mr56311433wmt.1.1454951005942; Mon, 08 Feb 2016 09:03:25 -0800 (PST) Received: from 640k.lan (94-39-141-130.adsl-ull.clienti.tiscali.it. [94.39.141.130]) by smtp.gmail.com with ESMTPSA id b1sm30651442wjy.0.2016.02.08.09.03.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 09:03:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 18:02:55 +0100 Message-Id: <1454950999-64128-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> References: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d Subject: [Qemu-devel] [PULL 04/28] configure: sanity check the glib library that pkg-config finds X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Daniel P. Berrange" Developers on 64-bit machines will often try to perform a 32-bit build of QEMU by running ./configure --extra-cflags="-m32" 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. 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 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 qga/commands-posix.c: In function ‘qmp_guest_set_user_password’: qga/commands-posix.c:1912:55: error: passing argument 2 of ‘g_base64_decode’ from incompatible pointer type [-Werror=incompatible-pointer-types] rawpasswddata = (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 ‘gsize * {aka long unsigned int *}’ but argument is of type ‘size_t * {aka unsigned int *}’ guchar *g_base64_decode (const gchar *text, ^ cc1: all warnings being treated as errors 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. On Fedora x86_64 it passes with any of: # ./configure # PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig ./configure --extra-cflags="-m32" # PKG_CONFIG_LIBDIR=/usr/lib64/pkgconfig ./configure --extra-cflags="-m64" And fails with a mis-match # PKG_CONFIG_LIBDIR=/usr/lib64/pkgconfig ./configure --extra-cflags="-m32" # PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig ./configure --extra-cflags="-m64" 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 Signed-off-by: Daniel P. Berrange Message-Id: <1453885245-15562-1-git-send-email-berrange@redhat.com> Signed-off-by: Paolo Bonzini --- configure | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/configure b/configure index d4411a1..c9cf1c9 100755 --- a/configure +++ b/configure @@ -3063,6 +3063,30 @@ for i in $glib_modules; do fi done +# 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 + +#define QEMU_BUILD_BUG_ON(x) \ + typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); + +int main(void) { + QEMU_BUILD_BUG_ON(sizeof(size_t) != 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=yes if ! $pkg_config --atleast-version=2.38 glib-2.0; then