All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: sstabellini@kernel.org, jbeulich@suse.com,
	andrew.cooper3@citrix.com,  wl@xen.org, iwj@xenproject.org,
	anthony.perard@citrix.com
Subject: [PATCH for-next] configure: probe for gcc -m32 integer sizes
Date: Tue, 23 Feb 2021 17:08:43 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2102231648580.3234@sstabellini-ThinkPad-T480s> (raw)

The hvmloader build on Alpine Linux x86_64 currenly fails:


hvmloader.c: In function 'init_vm86_tss':
hvmloader.c:202:39: error: left shift count >= width of type [-Werror=shift-count-overflow]
  202 |                   ((uint64_t)TSS_SIZE << 32) | virt_to_phys(tss));

util.c: In function 'get_cpu_mhz':
util.c:824:15: error: conversion from 'long long unsigned int' to 'uint64_t' {aka 'long unsigned int'} changes value from
'4294967296000000' to '0' [-Werror=overflow]
  824 |     cpu_khz = 1000000ull << 32;


The root cause of the issue is that gcc -m32 picks up headers meant for
64-bit builds.

The failures are currently causing problems to the xen-project
gitlab-ci pipeline.

This patch introduces code to detect this kind of errors in the
configure script, and disables with a warning the compilation of
hvmloader if problems are detected.

This patch also updates tools/configure. It has been done by calling
autoreconf -fi.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>


diff --git a/config/Tools.mk.in b/config/Tools.mk.in
index d47936686b..395ed2a6d2 100644
--- a/config/Tools.mk.in
+++ b/config/Tools.mk.in
@@ -51,6 +51,7 @@ CONFIG_OVMF         := @ovmf@
 CONFIG_ROMBIOS      := @rombios@
 CONFIG_SEABIOS      := @seabios@
 CONFIG_IPXE         := @ipxe@
+CONFIG_HVMLOADER    := @hvmloader@
 CONFIG_QEMU_TRAD    := @qemu_traditional@
 CONFIG_QEMU_XEN     := @qemu_xen@
 CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
diff --git a/tools/configure b/tools/configure
index bb5acf9d43..f23a3bb8aa 100755
--- a/tools/configure
+++ b/tools/configure
@@ -687,6 +687,7 @@ INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
 SET_MAKE
+hvmloader
 AWK
 IASL
 XGETTEXT
@@ -5279,6 +5280,25 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdint.h>
+#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
+int main() { BUILD_BUG_ON(sizeof(uint64_t) != 8); }
+_ACEOF
+if gcc -m32 -c conftest.c -o /dev/null 2>/dev/null; then :
+  hvmloader=y
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: hvmloader build disabled as the compiler cannot build 32bit binaries" >&5
+$as_echo "$as_me: WARNING: hvmloader build disabled as the compiler cannot build 32bit binaries" >&2;}
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
diff --git a/tools/configure.ac b/tools/configure.ac
index 636e7077be..706c162322 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -307,6 +307,12 @@ AC_ARG_VAR([AWK], [Path to awk tool])
 
 # Checks for programs.
 AC_PROG_CC
+AC_LANG(C)
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <stdint.h>
+#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
+int main() { BUILD_BUG_ON(sizeof(uint64_t) != 8); }]])])
+AS_IF([gcc -m32 -c conftest.c -o /dev/null 2>/dev/null], [hvmloader=y], [AC_MSG_WARN(hvmloader build disabled due to headers mismatch)])
+AC_SUBST(hvmloader)
 AC_PROG_MAKE_SET
 AC_PROG_INSTALL
 AC_PATH_PROG([FLEX], [flex])
diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
index 1f27117794..5c395ad738 100644
--- a/tools/firmware/Makefile
+++ b/tools/firmware/Makefile
@@ -13,7 +13,7 @@ SUBDIRS-$(CONFIG_ROMBIOS) += rombios
 SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
 SUBDIRS-$(CONFIG_IPXE) += etherboot
 SUBDIRS-$(CONFIG_PV_SHIM) += xen-dir
-SUBDIRS-y += hvmloader
+SUBDIRS-$(CONFIG_HVMLOADER) += hvmloader
 
 SEABIOSCC ?= $(CC)
 SEABIOSLD ?= $(LD)


             reply	other threads:[~2021-02-24  1:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  1:08 Stefano Stabellini [this message]
2021-02-24  7:26 ` [PATCH for-next] configure: probe for gcc -m32 integer sizes Jan Beulich
2021-02-24 10:20 ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2102231648580.3234@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.