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)
On 24.02.2021 02:08, Stefano Stabellini wrote: > --- 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]) I'm fine with the approach now, but I'm rather uncertain about the insertion point you've selected (in the middle of the "Checks for programs" section). It'll need to be the tools maintainers to judge about this. Jan
© 2016 - 2024 Red Hat, Inc.