All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
@ 2021-04-19 23:08 Christopher Clark
  2021-04-19 23:08 ` [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64 Christopher Clark
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Christopher Clark @ 2021-04-19 23:08 UTC (permalink / raw)
  To: meta-virtualization; +Cc: cardoe, bruce.ashfield, bertrand.marquis

Backport Xen patches to enable hvmloader to be built without needing
32-bit glibc.

Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
---
 ...-stand-alone-set-of-headers-Xen-4.14.patch | 178 ++++++++++++++++++
 ...d-firmware-as-ffreestanding-Xen-4.14.patch |  83 ++++++++
 recipes-extended/xen/xen-tools_4.14.bb        |   2 +
 3 files changed, 263 insertions(+)
 create mode 100644 recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
 create mode 100644 recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch

diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
new file mode 100644
index 0000000..7b062b7
--- /dev/null
+++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
@@ -0,0 +1,178 @@
+From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
+Date: Thu, 4 Mar 2021 16:49:00 +0100
+Subject: [PATCH] firmware: provide a stand alone set of headers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The current build of the firmware relies on having 32bit compatible
+headers installed in order to build some of the 32bit firmware.
+Usually this can be solved by using the -ffreestanding compiler option
+which drops the usage of the system headers in favor of a private set
+of freestanding headers provided by the compiler itself that are not
+tied to libc.
+
+However such option is broken at least in the gcc compiler provided in
+Alpine Linux, as the system include path (ie: /usr/include) takes
+precedence over the gcc private include path:
+
+#include <...> search starts here:
+ /usr/include
+ /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include
+
+And the headers in /usr/include are exclusively 64bit.
+
+Since -ffreestanding is currently broken on at least that distro, and
+for resilience against future compilers also having the option broken
+provide a set of stand alone 32bit headers required for the firmware
+build.
+
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Reviewed-by: Jan Beulich <jbeulich@suse.com>
+Release-Acked-by: Ian Jackson <iwj@xenproject.org>
+Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com>
+---
+ tools/firmware/Rules.mk                       | 13 +++++++
+ tools/firmware/include/stdarg.h               | 10 +++++
+ tools/firmware/include/stdbool.h              |  9 +++++
+ tools/firmware/include/stddef.h               | 10 +++++
+ tools/firmware/include/stdint.h               | 39 +++++++++++++++++++
+ tools/firmware/rombios/32bit/rombios_compat.h |  4 +-
+ 6 files changed, 82 insertions(+), 3 deletions(-)
+ create mode 100644 tools/firmware/include/stdarg.h
+ create mode 100644 tools/firmware/include/stdbool.h
+ create mode 100644 tools/firmware/include/stddef.h
+ create mode 100644 tools/firmware/include/stdint.h
+
+diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h
+new file mode 100644
+index 0000000000..c5e3761cd2
+--- /dev/null
++++ b/tools/firmware/include/stdarg.h
+@@ -0,0 +1,10 @@
++#ifndef _STDARG_H_
++#define _STDARG_H_
++
++typedef __builtin_va_list va_list;
++#define va_copy(dest, src) __builtin_va_copy(dest, src)
++#define va_start(ap, last) __builtin_va_start(ap, last)
++#define va_end(ap) __builtin_va_end(ap)
++#define va_arg __builtin_va_arg
++
++#endif
+diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h
+new file mode 100644
+index 0000000000..0cf76b106c
+--- /dev/null
++++ b/tools/firmware/include/stdbool.h
+@@ -0,0 +1,9 @@
++#ifndef _STDBOOL_H_
++#define _STDBOOL_H_
++
++#define bool _Bool
++#define true 1
++#define false 0
++#define __bool_true_false_are_defined 1
++
++#endif
+diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h
+new file mode 100644
+index 0000000000..c7f974608a
+--- /dev/null
++++ b/tools/firmware/include/stddef.h
+@@ -0,0 +1,10 @@
++#ifndef _STDDEF_H_
++#define _STDDEF_H_
++
++typedef __SIZE_TYPE__ size_t;
++
++#define NULL ((void*)0)
++
++#define offsetof(t, m) __builtin_offsetof(t, m)
++
++#endif
+diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
+new file mode 100644
+index 0000000000..16a0b6de19
+--- /dev/null
++++ b/tools/firmware/include/stdint.h
+@@ -0,0 +1,39 @@
++#ifndef _STDINT_H_
++#define _STDINT_H_
++
++#if defined(__LP64__) || defined(__P64__)
++#error "32bit only header"
++#endif
++
++typedef unsigned char uint8_t;
++typedef signed char int8_t;
++
++typedef unsigned short uint16_t;
++typedef signed short int16_t;
++
++typedef unsigned int uint32_t;
++typedef signed int int32_t;
++
++typedef unsigned long long uint64_t;
++typedef signed long long int64_t;
++
++#define INT8_MIN        (-0x7f-1)
++#define INT16_MIN       (-0x7fff-1)
++#define INT32_MIN       (-0x7fffffff-1)
++#define INT64_MIN       (-0x7fffffffffffffffll-1)
++
++#define INT8_MAX        0x7f
++#define INT16_MAX       0x7fff
++#define INT32_MAX       0x7fffffff
++#define INT64_MAX       0x7fffffffffffffffll
++
++#define UINT8_MAX       0xff
++#define UINT16_MAX      0xffff
++#define UINT32_MAX      0xffffffffu
++#define UINT64_MAX      0xffffffffffffffffull
++
++typedef uint32_t uintptr_t;
++
++#define UINTPTR_MAX     UINT32_MAX
++
++#endif
+diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h
+index 3fe7d67721..8ba4c17ffd 100644
+--- a/tools/firmware/rombios/32bit/rombios_compat.h
++++ b/tools/firmware/rombios/32bit/rombios_compat.h
+@@ -8,9 +8,7 @@
+ 
+ #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
+ 
+-typedef unsigned char uint8_t;
+-typedef unsigned short int uint16_t;
+-typedef unsigned int uint32_t;
++#include <stdint.h>
+ 
+ typedef uint8_t  Bit8u;
+ typedef uint16_t Bit16u;
+diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
+index 26bbddccd4..cb388b7011 100644
+--- a/tools/firmware/Rules.mk
++++ b/tools/firmware/Rules.mk
+@@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
+ 
+ # Extra CFLAGS suitable for an embedded type of environment.
+ CFLAGS += -fno-builtin -msoft-float
++
++# Use our own set of stand alone headers to build firmware.
++#
++# Ideally using -ffreestanding should be enough, but that relies on the
++# compiler having the right order for include paths (ie: compiler private
++# headers before system ones) or the libc headers having proper arch-agnostic
++# freestanding support. This is not the case in Alpine at least which searches
++# system headers before compiler ones and has arch-specific libc headers. This
++# has been reported upstream:
++# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
++# In the meantime (and for resilience against broken systems) use our own set
++# of headers that provide what's needed for the firmware build.
++CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
+-- 
+2.25.1
+
diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
new file mode 100644
index 0000000..001b196
--- /dev/null
+++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
@@ -0,0 +1,83 @@
+From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001
+From: Andrew Cooper <andrew.cooper3@citrix.com>
+Date: Thu, 25 Feb 2021 19:15:08 +0000
+Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding
+
+firmware should always have been -ffreestanding, as it doesn't execute in the
+host environment.  -ffreestanding implies -fno-builtin, so replace the option.
+
+inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants
+the stdint.h types so switch to the more appropriate include.
+
+This removes the build time dependency on a 32bit libc just to compile the
+hvmloader and friends.
+
+Update README and the TravisCI configuration.
+
+Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
+Reviewed-by: Jan Beulich <jbeulich@suse.com>
+Reviewed-by: Ian Jackson <iwj@xenproject.org>
+Release-Acked-by: Ian Jackson <iwj@xenproject.org>
+Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com>
+---
+ .travis.yml                                  | 1 -
+ README                                       | 3 ---
+ tools/firmware/Rules.mk                      | 2 +-
+ tools/firmware/hvmloader/32bitbios_support.c | 2 +-
+ 4 files changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/.travis.yml b/.travis.yml
+index 15ca9e9047..2362475f7a 100644
+--- a/.travis.yml
++++ b/.travis.yml
+@@ -58,7 +58,6 @@ addons:
+             - acpica-tools
+             - bin86
+             - bcc
+-            - libc6-dev-i386
+             - libnl-3-dev
+             - ocaml-nox
+             - libfindlib-ocaml-dev
+diff --git a/README b/README
+index 6e15242ae1..8c99c30986 100644
+--- a/README
++++ b/README
+@@ -62,9 +62,6 @@ provided by your OS distributor:
+     * GNU bison and GNU flex
+     * GNU gettext
+     * ACPI ASL compiler (iasl)
+-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
+-      Required when building on a 64-bit platform to build
+-      32-bit components which are enabled on a default build.
+ 
+ In addition to the above there are a number of optional build
+ prerequisites. Omitting these will cause the related features to be
+diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
+index cb388b7011..9f78a7dec9 100644
+--- a/tools/firmware/Rules.mk
++++ b/tools/firmware/Rules.mk
+@@ -16,7 +16,7 @@ CFLAGS += -Werror
+ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
+ 
+ # Extra CFLAGS suitable for an embedded type of environment.
+-CFLAGS += -fno-builtin -msoft-float
++CFLAGS += -ffreestanding -msoft-float
+ 
+ # Use our own set of stand alone headers to build firmware.
+ #
+diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c
+index 114135022e..ef681d4f57 100644
+--- a/tools/firmware/hvmloader/32bitbios_support.c
++++ b/tools/firmware/hvmloader/32bitbios_support.c
+@@ -20,7 +20,7 @@
+  * this program; If not, see <http://www.gnu.org/licenses/>.
+  */
+ 
+-#include <inttypes.h>
++#include <stdint.h>
+ #include <elf.h>
+ #ifdef __sun__
+ #include <sys/machelf.h>
+-- 
+2.25.1
+
diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb
index a79b41d..10982a2 100644
--- a/recipes-extended/xen/xen-tools_4.14.bb
+++ b/recipes-extended/xen/xen-tools_4.14.bb
@@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
 SRC_URI = " \
     git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
     file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \
+    file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \
+    file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \
     "
 
 LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64
  2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
@ 2021-04-19 23:08 ` Christopher Clark
  2021-04-21  9:20   ` Bertrand Marquis
  2021-04-19 23:08 ` [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency Christopher Clark
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Christopher Clark @ 2021-04-19 23:08 UTC (permalink / raw)
  To: meta-virtualization; +Cc: cardoe, bruce.ashfield, bertrand.marquis

Xen 4.15 added support for standalone x86-64 hvmloader build and
previous commit provided Xen 4.14 backports.

Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
---
 recipes-extended/xen/xen-tools.inc | 37 ------------------------------
 1 file changed, 37 deletions(-)

diff --git a/recipes-extended/xen/xen-tools.inc b/recipes-extended/xen/xen-tools.inc
index 722c503..3560e79 100644
--- a/recipes-extended/xen/xen-tools.inc
+++ b/recipes-extended/xen/xen-tools.inc
@@ -6,29 +6,6 @@ COMPATIBLE_HOST = 'i686-.*-linux|(x86_64.*).*-linux|aarch64.*-linux|arm-.*-linux
 inherit setuptools3 update-rc.d systemd deploy
 require xen-blktap.inc
 
-# To build hvmloader, which is needed on x86-64 targets when 'hvm' is enabled
-# in PACKAGECONFIG, to support running HVM-mode guest VMs, some files from
-# 32-bit glibc are needed.
-# Add the multilib 32-bit glibc to DEPENDS only when necessary.
-#
-# To enable multilib, please add the following to your local.conf -:
-#
-#    require conf/multilib.conf
-#    MULTILIBS = "multilib:lib32"
-#    DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
-
-# Use this multilib prefix for x86 32-bit to match local.conf:
-MLPREFIX32 = "lib32-"
-
-# The DEPENDS on a multilib 32-bit glibc is only added when target is x86-64
-# and 'hvm' is enabled in PACKAGECONFIG.
-# This x86-64 override is never intended for native use, so clear that.
-GLIBC32 = ""
-GLIBC32_x86-64 = \
-    "${@bb.utils.contains('PACKAGECONFIG', 'hvm', '${MLPREFIX32}glibc', '', d)}"
-GLIBC32_class-native = ""
-DEPENDS += "${GLIBC32}"
-
 RDEPENDS_${PN} = "\
     bash perl xz \
     ${PN}-console \
@@ -736,16 +713,6 @@ SYSTEMD_SERVICE_${PN}-xencommons = " \
     "
 SYSTEMD_SERVICE_${PN}-xendomains = "xendomains.service"
 
-# To build hvmloader, which is needed on x86-64 targets when 'hvm' is enabled
-# in PACKAGECONFIG, additional CFLAGS are needed to set the 32-bit sysroot.
-RECIPE_SYSROOT32 = "${WORKDIR}/${MLPREFIX32}recipe-sysroot"
-ADD_SYSROOT32_CFLAGS = ""
-ADD_SYSROOT32_CFLAGS_x86-64 = \
-    "${@bb.utils.contains('PACKAGECONFIG', 'hvm', \
-        'CFLAGS += "--sysroot=${RECIPE_SYSROOT32}"', '', d)}"
-# This x86-64 override is never intended for native use, so clear that.
-ADD_SYSROOT32_CFLAGS_class-native = ""
-
 EXTRA_OECONF += " \
     --with-systemd=${systemd_unitdir}/system \
     --with-systemd-modules-load=${systemd_unitdir}/modules-load.d \
@@ -756,10 +723,6 @@ EXTRA_OECONF += " \
 
 do_configure() {
     do_configure_common
-
-    if [ -n '${ADD_SYSROOT32_CFLAGS}' ] ; then
-        echo '${ADD_SYSROOT32_CFLAGS}' >>"${S}/tools/firmware/Rules.mk"
-    fi
 }
 
 do_compile() {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency
  2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
  2021-04-19 23:08 ` [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64 Christopher Clark
@ 2021-04-19 23:08 ` Christopher Clark
  2021-04-21  9:22   ` Bertrand Marquis
  2021-04-20  2:05 ` [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Bruce Ashfield
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Christopher Clark @ 2021-04-19 23:08 UTC (permalink / raw)
  To: meta-virtualization
  Cc: cardoe, bruce.ashfield, andrew.cooper3, bertrand.marquis

The latest Xen Test Framework has removed the gcc-multilib dependency.

Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
---
 recipes-extended/xen/xtf_git.bb | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/recipes-extended/xen/xtf_git.bb b/recipes-extended/xen/xtf_git.bb
index db08643..3580324 100644
--- a/recipes-extended/xen/xtf_git.bb
+++ b/recipes-extended/xen/xtf_git.bb
@@ -6,7 +6,7 @@ LICENSE = "BSD-2-Clause"
 # https://static.sched.com/hosted_files/xendeveloperanddesignsummit2017/79/xtf.pdf
 
 SRC_URI = "git://xenbits.xen.org/xtf"
-SRCREV = "8ab15139728a8efd3ebbb60beb16a958a6a93fa1"
+SRCREV = "b0bc49846c154b79243f39d461a4515804bcaf53"
 
 COMPATIBLE_HOST = '(x86_64.*).*-linux'
 
@@ -18,23 +18,6 @@ S = "${WORKDIR}/git"
 
 inherit python3native
 
-# To build 32-bit binaries some files from 32-bit glibc are needed.
-# To enable multilib, please add the following to your local.conf -:
-#
-#    require conf/multilib.conf
-#    MULTILIBS = "multilib:lib32"
-#    DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
-
-# Use this multilib prefix for x86 32-bit to match local.conf:
-MLPREFIX32 = "lib32-"
-# Add the multilib 32-bit glibc to DEPENDS only when necessary:
-# The DEPENDS on a multilib 32-bit glibc is only added when target is x86-64
-# This x86-64 override is never intended for native use, so clear that.
-GLIBC32 = ""
-GLIBC32_x86-64 = "${MLPREFIX32}glibc"
-GLIBC32_class-native = ""
-DEPENDS += "${GLIBC32}"
-
 PACKAGES = "${PN}"
 
 FILES_${PN} = " \
@@ -47,7 +30,7 @@ RDEPENDS_${PN} = " \
     "
 
 do_compile() {
-    oe_runmake CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} -I${RECIPE_SYSROOT}/../${MLPREFIX32}recipe-sysroot/usr/include" \
+    oe_runmake CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" \
                CPP="${CPP}" \
                OBJCOPY="${OBJCOPY}" \
                PYTHON="${PYTHON}"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
  2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
  2021-04-19 23:08 ` [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64 Christopher Clark
  2021-04-19 23:08 ` [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency Christopher Clark
@ 2021-04-20  2:05 ` Bruce Ashfield
  2021-04-20 21:00 ` Bruce Ashfield
  2021-04-21  9:20 ` Bertrand Marquis
  4 siblings, 0 replies; 9+ messages in thread
From: Bruce Ashfield @ 2021-04-20  2:05 UTC (permalink / raw)
  To: Christopher Clark; +Cc: meta-virtualization, Doug Goldstein, Bertrand Marquis

On Mon, Apr 19, 2021 at 7:09 PM Christopher Clark
<christopher.w.clark@gmail.com> wrote:
>
> Backport Xen patches to enable hvmloader to be built without needing
> 32-bit glibc.
>

Excellent!

The 32 bit multilib routinely terrorizes me when building Xen :D

Bruce

> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
> ---
>  ...-stand-alone-set-of-headers-Xen-4.14.patch | 178 ++++++++++++++++++
>  ...d-firmware-as-ffreestanding-Xen-4.14.patch |  83 ++++++++
>  recipes-extended/xen/xen-tools_4.14.bb        |   2 +
>  3 files changed, 263 insertions(+)
>  create mode 100644 recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
>  create mode 100644 recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
>
> diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> new file mode 100644
> index 0000000..7b062b7
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> @@ -0,0 +1,178 @@
> +From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
> +Date: Thu, 4 Mar 2021 16:49:00 +0100
> +Subject: [PATCH] firmware: provide a stand alone set of headers
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +The current build of the firmware relies on having 32bit compatible
> +headers installed in order to build some of the 32bit firmware.
> +Usually this can be solved by using the -ffreestanding compiler option
> +which drops the usage of the system headers in favor of a private set
> +of freestanding headers provided by the compiler itself that are not
> +tied to libc.
> +
> +However such option is broken at least in the gcc compiler provided in
> +Alpine Linux, as the system include path (ie: /usr/include) takes
> +precedence over the gcc private include path:
> +
> +#include <...> search starts here:
> + /usr/include
> + /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include
> +
> +And the headers in /usr/include are exclusively 64bit.
> +
> +Since -ffreestanding is currently broken on at least that distro, and
> +for resilience against future compilers also having the option broken
> +provide a set of stand alone 32bit headers required for the firmware
> +build.
> +
> +Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + tools/firmware/Rules.mk                       | 13 +++++++
> + tools/firmware/include/stdarg.h               | 10 +++++
> + tools/firmware/include/stdbool.h              |  9 +++++
> + tools/firmware/include/stddef.h               | 10 +++++
> + tools/firmware/include/stdint.h               | 39 +++++++++++++++++++
> + tools/firmware/rombios/32bit/rombios_compat.h |  4 +-
> + 6 files changed, 82 insertions(+), 3 deletions(-)
> + create mode 100644 tools/firmware/include/stdarg.h
> + create mode 100644 tools/firmware/include/stdbool.h
> + create mode 100644 tools/firmware/include/stddef.h
> + create mode 100644 tools/firmware/include/stdint.h
> +
> +diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h
> +new file mode 100644
> +index 0000000000..c5e3761cd2
> +--- /dev/null
> ++++ b/tools/firmware/include/stdarg.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDARG_H_
> ++#define _STDARG_H_
> ++
> ++typedef __builtin_va_list va_list;
> ++#define va_copy(dest, src) __builtin_va_copy(dest, src)
> ++#define va_start(ap, last) __builtin_va_start(ap, last)
> ++#define va_end(ap) __builtin_va_end(ap)
> ++#define va_arg __builtin_va_arg
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h
> +new file mode 100644
> +index 0000000000..0cf76b106c
> +--- /dev/null
> ++++ b/tools/firmware/include/stdbool.h
> +@@ -0,0 +1,9 @@
> ++#ifndef _STDBOOL_H_
> ++#define _STDBOOL_H_
> ++
> ++#define bool _Bool
> ++#define true 1
> ++#define false 0
> ++#define __bool_true_false_are_defined 1
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h
> +new file mode 100644
> +index 0000000000..c7f974608a
> +--- /dev/null
> ++++ b/tools/firmware/include/stddef.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDDEF_H_
> ++#define _STDDEF_H_
> ++
> ++typedef __SIZE_TYPE__ size_t;
> ++
> ++#define NULL ((void*)0)
> ++
> ++#define offsetof(t, m) __builtin_offsetof(t, m)
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
> +new file mode 100644
> +index 0000000000..16a0b6de19
> +--- /dev/null
> ++++ b/tools/firmware/include/stdint.h
> +@@ -0,0 +1,39 @@
> ++#ifndef _STDINT_H_
> ++#define _STDINT_H_
> ++
> ++#if defined(__LP64__) || defined(__P64__)
> ++#error "32bit only header"
> ++#endif
> ++
> ++typedef unsigned char uint8_t;
> ++typedef signed char int8_t;
> ++
> ++typedef unsigned short uint16_t;
> ++typedef signed short int16_t;
> ++
> ++typedef unsigned int uint32_t;
> ++typedef signed int int32_t;
> ++
> ++typedef unsigned long long uint64_t;
> ++typedef signed long long int64_t;
> ++
> ++#define INT8_MIN        (-0x7f-1)
> ++#define INT16_MIN       (-0x7fff-1)
> ++#define INT32_MIN       (-0x7fffffff-1)
> ++#define INT64_MIN       (-0x7fffffffffffffffll-1)
> ++
> ++#define INT8_MAX        0x7f
> ++#define INT16_MAX       0x7fff
> ++#define INT32_MAX       0x7fffffff
> ++#define INT64_MAX       0x7fffffffffffffffll
> ++
> ++#define UINT8_MAX       0xff
> ++#define UINT16_MAX      0xffff
> ++#define UINT32_MAX      0xffffffffu
> ++#define UINT64_MAX      0xffffffffffffffffull
> ++
> ++typedef uint32_t uintptr_t;
> ++
> ++#define UINTPTR_MAX     UINT32_MAX
> ++
> ++#endif
> +diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h
> +index 3fe7d67721..8ba4c17ffd 100644
> +--- a/tools/firmware/rombios/32bit/rombios_compat.h
> ++++ b/tools/firmware/rombios/32bit/rombios_compat.h
> +@@ -8,9 +8,7 @@
> +
> + #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
> +
> +-typedef unsigned char uint8_t;
> +-typedef unsigned short int uint16_t;
> +-typedef unsigned int uint32_t;
> ++#include <stdint.h>
> +
> + typedef uint8_t  Bit8u;
> + typedef uint16_t Bit16u;
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index 26bbddccd4..cb388b7011 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> +
> + # Extra CFLAGS suitable for an embedded type of environment.
> + CFLAGS += -fno-builtin -msoft-float
> ++
> ++# Use our own set of stand alone headers to build firmware.
> ++#
> ++# Ideally using -ffreestanding should be enough, but that relies on the
> ++# compiler having the right order for include paths (ie: compiler private
> ++# headers before system ones) or the libc headers having proper arch-agnostic
> ++# freestanding support. This is not the case in Alpine at least which searches
> ++# system headers before compiler ones and has arch-specific libc headers. This
> ++# has been reported upstream:
> ++# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
> ++# In the meantime (and for resilience against broken systems) use our own set
> ++# of headers that provide what's needed for the firmware build.
> ++CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
> +--
> +2.25.1
> +
> diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> new file mode 100644
> index 0000000..001b196
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> @@ -0,0 +1,83 @@
> +From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001
> +From: Andrew Cooper <andrew.cooper3@citrix.com>
> +Date: Thu, 25 Feb 2021 19:15:08 +0000
> +Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding
> +
> +firmware should always have been -ffreestanding, as it doesn't execute in the
> +host environment.  -ffreestanding implies -fno-builtin, so replace the option.
> +
> +inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants
> +the stdint.h types so switch to the more appropriate include.
> +
> +This removes the build time dependency on a 32bit libc just to compile the
> +hvmloader and friends.
> +
> +Update README and the TravisCI configuration.
> +
> +Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Reviewed-by: Ian Jackson <iwj@xenproject.org>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + .travis.yml                                  | 1 -
> + README                                       | 3 ---
> + tools/firmware/Rules.mk                      | 2 +-
> + tools/firmware/hvmloader/32bitbios_support.c | 2 +-
> + 4 files changed, 2 insertions(+), 6 deletions(-)
> +
> +diff --git a/.travis.yml b/.travis.yml
> +index 15ca9e9047..2362475f7a 100644
> +--- a/.travis.yml
> ++++ b/.travis.yml
> +@@ -58,7 +58,6 @@ addons:
> +             - acpica-tools
> +             - bin86
> +             - bcc
> +-            - libc6-dev-i386
> +             - libnl-3-dev
> +             - ocaml-nox
> +             - libfindlib-ocaml-dev
> +diff --git a/README b/README
> +index 6e15242ae1..8c99c30986 100644
> +--- a/README
> ++++ b/README
> +@@ -62,9 +62,6 @@ provided by your OS distributor:
> +     * GNU bison and GNU flex
> +     * GNU gettext
> +     * ACPI ASL compiler (iasl)
> +-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
> +-      Required when building on a 64-bit platform to build
> +-      32-bit components which are enabled on a default build.
> +
> + In addition to the above there are a number of optional build
> + prerequisites. Omitting these will cause the related features to be
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index cb388b7011..9f78a7dec9 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -16,7 +16,7 @@ CFLAGS += -Werror
> + $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> +
> + # Extra CFLAGS suitable for an embedded type of environment.
> +-CFLAGS += -fno-builtin -msoft-float
> ++CFLAGS += -ffreestanding -msoft-float
> +
> + # Use our own set of stand alone headers to build firmware.
> + #
> +diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c
> +index 114135022e..ef681d4f57 100644
> +--- a/tools/firmware/hvmloader/32bitbios_support.c
> ++++ b/tools/firmware/hvmloader/32bitbios_support.c
> +@@ -20,7 +20,7 @@
> +  * this program; If not, see <http://www.gnu.org/licenses/>.
> +  */
> +
> +-#include <inttypes.h>
> ++#include <stdint.h>
> + #include <elf.h>
> + #ifdef __sun__
> + #include <sys/machelf.h>
> +--
> +2.25.1
> +
> diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb
> index a79b41d..10982a2 100644
> --- a/recipes-extended/xen/xen-tools_4.14.bb
> +++ b/recipes-extended/xen/xen-tools_4.14.bb
> @@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
>  SRC_URI = " \
>      git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
>      file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \
> +    file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \
> +    file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \
>      "
>
>  LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5"
> --
> 2.25.1
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
  2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
                   ` (2 preceding siblings ...)
  2021-04-20  2:05 ` [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Bruce Ashfield
@ 2021-04-20 21:00 ` Bruce Ashfield
  2021-04-20 21:51   ` Christopher Clark
  2021-04-21  9:20 ` Bertrand Marquis
  4 siblings, 1 reply; 9+ messages in thread
From: Bruce Ashfield @ 2021-04-20 21:00 UTC (permalink / raw)
  To: Christopher Clark; +Cc: meta-virtualization, cardoe, bertrand.marquis

These look good to me.

I've queued them on master .. were you also interested in
getting them into hardknott ?

Bruce

In message: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
on 19/04/2021 Christopher Clark wrote:

> Backport Xen patches to enable hvmloader to be built without needing
> 32-bit glibc.
> 
> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
> ---
>  ...-stand-alone-set-of-headers-Xen-4.14.patch | 178 ++++++++++++++++++
>  ...d-firmware-as-ffreestanding-Xen-4.14.patch |  83 ++++++++
>  recipes-extended/xen/xen-tools_4.14.bb        |   2 +
>  3 files changed, 263 insertions(+)
>  create mode 100644 recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
>  create mode 100644 recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> 
> diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> new file mode 100644
> index 0000000..7b062b7
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> @@ -0,0 +1,178 @@
> +From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
> +Date: Thu, 4 Mar 2021 16:49:00 +0100
> +Subject: [PATCH] firmware: provide a stand alone set of headers
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +The current build of the firmware relies on having 32bit compatible
> +headers installed in order to build some of the 32bit firmware.
> +Usually this can be solved by using the -ffreestanding compiler option
> +which drops the usage of the system headers in favor of a private set
> +of freestanding headers provided by the compiler itself that are not
> +tied to libc.
> +
> +However such option is broken at least in the gcc compiler provided in
> +Alpine Linux, as the system include path (ie: /usr/include) takes
> +precedence over the gcc private include path:
> +
> +#include <...> search starts here:
> + /usr/include
> + /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include
> +
> +And the headers in /usr/include are exclusively 64bit.
> +
> +Since -ffreestanding is currently broken on at least that distro, and
> +for resilience against future compilers also having the option broken
> +provide a set of stand alone 32bit headers required for the firmware
> +build.
> +
> +Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + tools/firmware/Rules.mk                       | 13 +++++++
> + tools/firmware/include/stdarg.h               | 10 +++++
> + tools/firmware/include/stdbool.h              |  9 +++++
> + tools/firmware/include/stddef.h               | 10 +++++
> + tools/firmware/include/stdint.h               | 39 +++++++++++++++++++
> + tools/firmware/rombios/32bit/rombios_compat.h |  4 +-
> + 6 files changed, 82 insertions(+), 3 deletions(-)
> + create mode 100644 tools/firmware/include/stdarg.h
> + create mode 100644 tools/firmware/include/stdbool.h
> + create mode 100644 tools/firmware/include/stddef.h
> + create mode 100644 tools/firmware/include/stdint.h
> +
> +diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h
> +new file mode 100644
> +index 0000000000..c5e3761cd2
> +--- /dev/null
> ++++ b/tools/firmware/include/stdarg.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDARG_H_
> ++#define _STDARG_H_
> ++
> ++typedef __builtin_va_list va_list;
> ++#define va_copy(dest, src) __builtin_va_copy(dest, src)
> ++#define va_start(ap, last) __builtin_va_start(ap, last)
> ++#define va_end(ap) __builtin_va_end(ap)
> ++#define va_arg __builtin_va_arg
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h
> +new file mode 100644
> +index 0000000000..0cf76b106c
> +--- /dev/null
> ++++ b/tools/firmware/include/stdbool.h
> +@@ -0,0 +1,9 @@
> ++#ifndef _STDBOOL_H_
> ++#define _STDBOOL_H_
> ++
> ++#define bool _Bool
> ++#define true 1
> ++#define false 0
> ++#define __bool_true_false_are_defined 1
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h
> +new file mode 100644
> +index 0000000000..c7f974608a
> +--- /dev/null
> ++++ b/tools/firmware/include/stddef.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDDEF_H_
> ++#define _STDDEF_H_
> ++
> ++typedef __SIZE_TYPE__ size_t;
> ++
> ++#define NULL ((void*)0)
> ++
> ++#define offsetof(t, m) __builtin_offsetof(t, m)
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
> +new file mode 100644
> +index 0000000000..16a0b6de19
> +--- /dev/null
> ++++ b/tools/firmware/include/stdint.h
> +@@ -0,0 +1,39 @@
> ++#ifndef _STDINT_H_
> ++#define _STDINT_H_
> ++
> ++#if defined(__LP64__) || defined(__P64__)
> ++#error "32bit only header"
> ++#endif
> ++
> ++typedef unsigned char uint8_t;
> ++typedef signed char int8_t;
> ++
> ++typedef unsigned short uint16_t;
> ++typedef signed short int16_t;
> ++
> ++typedef unsigned int uint32_t;
> ++typedef signed int int32_t;
> ++
> ++typedef unsigned long long uint64_t;
> ++typedef signed long long int64_t;
> ++
> ++#define INT8_MIN        (-0x7f-1)
> ++#define INT16_MIN       (-0x7fff-1)
> ++#define INT32_MIN       (-0x7fffffff-1)
> ++#define INT64_MIN       (-0x7fffffffffffffffll-1)
> ++
> ++#define INT8_MAX        0x7f
> ++#define INT16_MAX       0x7fff
> ++#define INT32_MAX       0x7fffffff
> ++#define INT64_MAX       0x7fffffffffffffffll
> ++
> ++#define UINT8_MAX       0xff
> ++#define UINT16_MAX      0xffff
> ++#define UINT32_MAX      0xffffffffu
> ++#define UINT64_MAX      0xffffffffffffffffull
> ++
> ++typedef uint32_t uintptr_t;
> ++
> ++#define UINTPTR_MAX     UINT32_MAX
> ++
> ++#endif
> +diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h
> +index 3fe7d67721..8ba4c17ffd 100644
> +--- a/tools/firmware/rombios/32bit/rombios_compat.h
> ++++ b/tools/firmware/rombios/32bit/rombios_compat.h
> +@@ -8,9 +8,7 @@
> + 
> + #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
> + 
> +-typedef unsigned char uint8_t;
> +-typedef unsigned short int uint16_t;
> +-typedef unsigned int uint32_t;
> ++#include <stdint.h>
> + 
> + typedef uint8_t  Bit8u;
> + typedef uint16_t Bit16u;
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index 26bbddccd4..cb388b7011 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> + 
> + # Extra CFLAGS suitable for an embedded type of environment.
> + CFLAGS += -fno-builtin -msoft-float
> ++
> ++# Use our own set of stand alone headers to build firmware.
> ++#
> ++# Ideally using -ffreestanding should be enough, but that relies on the
> ++# compiler having the right order for include paths (ie: compiler private
> ++# headers before system ones) or the libc headers having proper arch-agnostic
> ++# freestanding support. This is not the case in Alpine at least which searches
> ++# system headers before compiler ones and has arch-specific libc headers. This
> ++# has been reported upstream:
> ++# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
> ++# In the meantime (and for resilience against broken systems) use our own set
> ++# of headers that provide what's needed for the firmware build.
> ++CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
> +-- 
> +2.25.1
> +
> diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> new file mode 100644
> index 0000000..001b196
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> @@ -0,0 +1,83 @@
> +From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001
> +From: Andrew Cooper <andrew.cooper3@citrix.com>
> +Date: Thu, 25 Feb 2021 19:15:08 +0000
> +Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding
> +
> +firmware should always have been -ffreestanding, as it doesn't execute in the
> +host environment.  -ffreestanding implies -fno-builtin, so replace the option.
> +
> +inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants
> +the stdint.h types so switch to the more appropriate include.
> +
> +This removes the build time dependency on a 32bit libc just to compile the
> +hvmloader and friends.
> +
> +Update README and the TravisCI configuration.
> +
> +Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Reviewed-by: Ian Jackson <iwj@xenproject.org>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + .travis.yml                                  | 1 -
> + README                                       | 3 ---
> + tools/firmware/Rules.mk                      | 2 +-
> + tools/firmware/hvmloader/32bitbios_support.c | 2 +-
> + 4 files changed, 2 insertions(+), 6 deletions(-)
> +
> +diff --git a/.travis.yml b/.travis.yml
> +index 15ca9e9047..2362475f7a 100644
> +--- a/.travis.yml
> ++++ b/.travis.yml
> +@@ -58,7 +58,6 @@ addons:
> +             - acpica-tools
> +             - bin86
> +             - bcc
> +-            - libc6-dev-i386
> +             - libnl-3-dev
> +             - ocaml-nox
> +             - libfindlib-ocaml-dev
> +diff --git a/README b/README
> +index 6e15242ae1..8c99c30986 100644
> +--- a/README
> ++++ b/README
> +@@ -62,9 +62,6 @@ provided by your OS distributor:
> +     * GNU bison and GNU flex
> +     * GNU gettext
> +     * ACPI ASL compiler (iasl)
> +-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
> +-      Required when building on a 64-bit platform to build
> +-      32-bit components which are enabled on a default build.
> + 
> + In addition to the above there are a number of optional build
> + prerequisites. Omitting these will cause the related features to be
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index cb388b7011..9f78a7dec9 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -16,7 +16,7 @@ CFLAGS += -Werror
> + $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> + 
> + # Extra CFLAGS suitable for an embedded type of environment.
> +-CFLAGS += -fno-builtin -msoft-float
> ++CFLAGS += -ffreestanding -msoft-float
> + 
> + # Use our own set of stand alone headers to build firmware.
> + #
> +diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c
> +index 114135022e..ef681d4f57 100644
> +--- a/tools/firmware/hvmloader/32bitbios_support.c
> ++++ b/tools/firmware/hvmloader/32bitbios_support.c
> +@@ -20,7 +20,7 @@
> +  * this program; If not, see <http://www.gnu.org/licenses/>.
> +  */
> + 
> +-#include <inttypes.h>
> ++#include <stdint.h>
> + #include <elf.h>
> + #ifdef __sun__
> + #include <sys/machelf.h>
> +-- 
> +2.25.1
> +
> diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb
> index a79b41d..10982a2 100644
> --- a/recipes-extended/xen/xen-tools_4.14.bb
> +++ b/recipes-extended/xen/xen-tools_4.14.bb
> @@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
>  SRC_URI = " \
>      git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
>      file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \
> +    file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \
> +    file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \
>      "
>  
>  LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5"
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
  2021-04-20 21:00 ` Bruce Ashfield
@ 2021-04-20 21:51   ` Christopher Clark
  0 siblings, 0 replies; 9+ messages in thread
From: Christopher Clark @ 2021-04-20 21:51 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: meta-virtualization, cardoe, Bertrand.Marquis



> On Apr 20, 2021, at 2:00 PM, Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> 
> These look good to me.
> 
> I've queued them on master .. were you also interested in
> getting them into hardknott ?

Yes, I am. I’d appreciate any test reports too.

Christopher 

> 
> Bruce
> 
> In message: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
>> on 19/04/2021 Christopher Clark wrote:
>> 
>> Backport Xen patches to enable hvmloader to be built without needing
>> 32-bit glibc.
>> 
>> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
>> ---
>> ...-stand-alone-set-of-headers-Xen-4.14.patch | 178 ++++++++++++++++++
>> ...d-firmware-as-ffreestanding-Xen-4.14.patch |  83 ++++++++
>> recipes-extended/xen/xen-tools_4.14.bb        |   2 +
>> 3 files changed, 263 insertions(+)
>> create mode 100644 recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
>> create mode 100644 recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
>> 
>> diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
>> new file mode 100644
>> index 0000000..7b062b7
>> --- /dev/null
>> +++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
>> @@ -0,0 +1,178 @@
>> +From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001
>> +From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
>> +Date: Thu, 4 Mar 2021 16:49:00 +0100
>> +Subject: [PATCH] firmware: provide a stand alone set of headers
>> +MIME-Version: 1.0
>> +Content-Type: text/plain; charset=UTF-8
>> +Content-Transfer-Encoding: 8bit
>> +
>> +The current build of the firmware relies on having 32bit compatible
>> +headers installed in order to build some of the 32bit firmware.
>> +Usually this can be solved by using the -ffreestanding compiler option
>> +which drops the usage of the system headers in favor of a private set
>> +of freestanding headers provided by the compiler itself that are not
>> +tied to libc.
>> +
>> +However such option is broken at least in the gcc compiler provided in
>> +Alpine Linux, as the system include path (ie: /usr/include) takes
>> +precedence over the gcc private include path:
>> +
>> +#include <...> search starts here:
>> + /usr/include
>> + /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include
>> +
>> +And the headers in /usr/include are exclusively 64bit.
>> +
>> +Since -ffreestanding is currently broken on at least that distro, and
>> +for resilience against future compilers also having the option broken
>> +provide a set of stand alone 32bit headers required for the firmware
>> +build.
>> +
>> +Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
>> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
>> +Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com>
>> +---
>> + tools/firmware/Rules.mk                       | 13 +++++++
>> + tools/firmware/include/stdarg.h               | 10 +++++
>> + tools/firmware/include/stdbool.h              |  9 +++++
>> + tools/firmware/include/stddef.h               | 10 +++++
>> + tools/firmware/include/stdint.h               | 39 +++++++++++++++++++
>> + tools/firmware/rombios/32bit/rombios_compat.h |  4 +-
>> + 6 files changed, 82 insertions(+), 3 deletions(-)
>> + create mode 100644 tools/firmware/include/stdarg.h
>> + create mode 100644 tools/firmware/include/stdbool.h
>> + create mode 100644 tools/firmware/include/stddef.h
>> + create mode 100644 tools/firmware/include/stdint.h
>> +
>> +diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h
>> +new file mode 100644
>> +index 0000000000..c5e3761cd2
>> +--- /dev/null
>> ++++ b/tools/firmware/include/stdarg.h
>> +@@ -0,0 +1,10 @@
>> ++#ifndef _STDARG_H_
>> ++#define _STDARG_H_
>> ++
>> ++typedef __builtin_va_list va_list;
>> ++#define va_copy(dest, src) __builtin_va_copy(dest, src)
>> ++#define va_start(ap, last) __builtin_va_start(ap, last)
>> ++#define va_end(ap) __builtin_va_end(ap)
>> ++#define va_arg __builtin_va_arg
>> ++
>> ++#endif
>> +diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h
>> +new file mode 100644
>> +index 0000000000..0cf76b106c
>> +--- /dev/null
>> ++++ b/tools/firmware/include/stdbool.h
>> +@@ -0,0 +1,9 @@
>> ++#ifndef _STDBOOL_H_
>> ++#define _STDBOOL_H_
>> ++
>> ++#define bool _Bool
>> ++#define true 1
>> ++#define false 0
>> ++#define __bool_true_false_are_defined 1
>> ++
>> ++#endif
>> +diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h
>> +new file mode 100644
>> +index 0000000000..c7f974608a
>> +--- /dev/null
>> ++++ b/tools/firmware/include/stddef.h
>> +@@ -0,0 +1,10 @@
>> ++#ifndef _STDDEF_H_
>> ++#define _STDDEF_H_
>> ++
>> ++typedef __SIZE_TYPE__ size_t;
>> ++
>> ++#define NULL ((void*)0)
>> ++
>> ++#define offsetof(t, m) __builtin_offsetof(t, m)
>> ++
>> ++#endif
>> +diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
>> +new file mode 100644
>> +index 0000000000..16a0b6de19
>> +--- /dev/null
>> ++++ b/tools/firmware/include/stdint.h
>> +@@ -0,0 +1,39 @@
>> ++#ifndef _STDINT_H_
>> ++#define _STDINT_H_
>> ++
>> ++#if defined(__LP64__) || defined(__P64__)
>> ++#error "32bit only header"
>> ++#endif
>> ++
>> ++typedef unsigned char uint8_t;
>> ++typedef signed char int8_t;
>> ++
>> ++typedef unsigned short uint16_t;
>> ++typedef signed short int16_t;
>> ++
>> ++typedef unsigned int uint32_t;
>> ++typedef signed int int32_t;
>> ++
>> ++typedef unsigned long long uint64_t;
>> ++typedef signed long long int64_t;
>> ++
>> ++#define INT8_MIN        (-0x7f-1)
>> ++#define INT16_MIN       (-0x7fff-1)
>> ++#define INT32_MIN       (-0x7fffffff-1)
>> ++#define INT64_MIN       (-0x7fffffffffffffffll-1)
>> ++
>> ++#define INT8_MAX        0x7f
>> ++#define INT16_MAX       0x7fff
>> ++#define INT32_MAX       0x7fffffff
>> ++#define INT64_MAX       0x7fffffffffffffffll
>> ++
>> ++#define UINT8_MAX       0xff
>> ++#define UINT16_MAX      0xffff
>> ++#define UINT32_MAX      0xffffffffu
>> ++#define UINT64_MAX      0xffffffffffffffffull
>> ++
>> ++typedef uint32_t uintptr_t;
>> ++
>> ++#define UINTPTR_MAX     UINT32_MAX
>> ++
>> ++#endif
>> +diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h
>> +index 3fe7d67721..8ba4c17ffd 100644
>> +--- a/tools/firmware/rombios/32bit/rombios_compat.h
>> ++++ b/tools/firmware/rombios/32bit/rombios_compat.h
>> +@@ -8,9 +8,7 @@
>> + 
>> + #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
>> + 
>> +-typedef unsigned char uint8_t;
>> +-typedef unsigned short int uint16_t;
>> +-typedef unsigned int uint32_t;
>> ++#include <stdint.h>
>> + 
>> + typedef uint8_t  Bit8u;
>> + typedef uint16_t Bit16u;
>> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
>> +index 26bbddccd4..cb388b7011 100644
>> +--- a/tools/firmware/Rules.mk
>> ++++ b/tools/firmware/Rules.mk
>> +@@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
>> + 
>> + # Extra CFLAGS suitable for an embedded type of environment.
>> + CFLAGS += -fno-builtin -msoft-float
>> ++
>> ++# Use our own set of stand alone headers to build firmware.
>> ++#
>> ++# Ideally using -ffreestanding should be enough, but that relies on the
>> ++# compiler having the right order for include paths (ie: compiler private
>> ++# headers before system ones) or the libc headers having proper arch-agnostic
>> ++# freestanding support. This is not the case in Alpine at least which searches
>> ++# system headers before compiler ones and has arch-specific libc headers. This
>> ++# has been reported upstream:
>> ++# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
>> ++# In the meantime (and for resilience against broken systems) use our own set
>> ++# of headers that provide what's needed for the firmware build.
>> ++CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
>> +-- 
>> +2.25.1
>> +
>> diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
>> new file mode 100644
>> index 0000000..001b196
>> --- /dev/null
>> +++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
>> @@ -0,0 +1,83 @@
>> +From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001
>> +From: Andrew Cooper <andrew.cooper3@citrix.com>
>> +Date: Thu, 25 Feb 2021 19:15:08 +0000
>> +Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding
>> +
>> +firmware should always have been -ffreestanding, as it doesn't execute in the
>> +host environment.  -ffreestanding implies -fno-builtin, so replace the option.
>> +
>> +inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants
>> +the stdint.h types so switch to the more appropriate include.
>> +
>> +This removes the build time dependency on a 32bit libc just to compile the
>> +hvmloader and friends.
>> +
>> +Update README and the TravisCI configuration.
>> +
>> +Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
>> +Reviewed-by: Ian Jackson <iwj@xenproject.org>
>> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
>> +Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com>
>> +---
>> + .travis.yml                                  | 1 -
>> + README                                       | 3 ---
>> + tools/firmware/Rules.mk                      | 2 +-
>> + tools/firmware/hvmloader/32bitbios_support.c | 2 +-
>> + 4 files changed, 2 insertions(+), 6 deletions(-)
>> +
>> +diff --git a/.travis.yml b/.travis.yml
>> +index 15ca9e9047..2362475f7a 100644
>> +--- a/.travis.yml
>> ++++ b/.travis.yml
>> +@@ -58,7 +58,6 @@ addons:
>> +             - acpica-tools
>> +             - bin86
>> +             - bcc
>> +-            - libc6-dev-i386
>> +             - libnl-3-dev
>> +             - ocaml-nox
>> +             - libfindlib-ocaml-dev
>> +diff --git a/README b/README
>> +index 6e15242ae1..8c99c30986 100644
>> +--- a/README
>> ++++ b/README
>> +@@ -62,9 +62,6 @@ provided by your OS distributor:
>> +     * GNU bison and GNU flex
>> +     * GNU gettext
>> +     * ACPI ASL compiler (iasl)
>> +-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
>> +-      Required when building on a 64-bit platform to build
>> +-      32-bit components which are enabled on a default build.
>> + 
>> + In addition to the above there are a number of optional build
>> + prerequisites. Omitting these will cause the related features to be
>> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
>> +index cb388b7011..9f78a7dec9 100644
>> +--- a/tools/firmware/Rules.mk
>> ++++ b/tools/firmware/Rules.mk
>> +@@ -16,7 +16,7 @@ CFLAGS += -Werror
>> + $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
>> + 
>> + # Extra CFLAGS suitable for an embedded type of environment.
>> +-CFLAGS += -fno-builtin -msoft-float
>> ++CFLAGS += -ffreestanding -msoft-float
>> + 
>> + # Use our own set of stand alone headers to build firmware.
>> + #
>> +diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c
>> +index 114135022e..ef681d4f57 100644
>> +--- a/tools/firmware/hvmloader/32bitbios_support.c
>> ++++ b/tools/firmware/hvmloader/32bitbios_support.c
>> +@@ -20,7 +20,7 @@
>> +  * this program; If not, see <http://www.gnu.org/licenses/>.
>> +  */
>> + 
>> +-#include <inttypes.h>
>> ++#include <stdint.h>
>> + #include <elf.h>
>> + #ifdef __sun__
>> + #include <sys/machelf.h>
>> +-- 
>> +2.25.1
>> +
>> diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb
>> index a79b41d..10982a2 100644
>> --- a/recipes-extended/xen/xen-tools_4.14.bb
>> +++ b/recipes-extended/xen/xen-tools_4.14.bb
>> @@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
>> SRC_URI = " \
>>     git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
>>     file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \
>> +    file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \
>> +    file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \
>>     "
>> 
>> LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5"
>> -- 
>> 2.25.1
>> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build
  2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
                   ` (3 preceding siblings ...)
  2021-04-20 21:00 ` Bruce Ashfield
@ 2021-04-21  9:20 ` Bertrand Marquis
  4 siblings, 0 replies; 9+ messages in thread
From: Bertrand Marquis @ 2021-04-21  9:20 UTC (permalink / raw)
  To: Christopher Clark; +Cc: meta-virtualization, Doug Goldstein, Bruce Ashfield, nd

Hi Christopher,

> On 20 Apr 2021, at 00:08, Christopher Clark via lists.yoctoproject.org <christopher.w.clark=gmail.com@lists.yoctoproject.org> wrote:
> 
> Backport Xen patches to enable hvmloader to be built without needing
> 32-bit glibc.
> 
> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>

This is really awesome, the multilib thing was really painful and it is nice to have a solution.

I reviewed and checked compilation of all versions of xen available for arm32, arm64 and x86_64 (without multilib activated) using you complete serie.

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> ...-stand-alone-set-of-headers-Xen-4.14.patch | 178 ++++++++++++++++++
> ...d-firmware-as-ffreestanding-Xen-4.14.patch |  83 ++++++++
> recipes-extended/xen/xen-tools_4.14.bb        |   2 +
> 3 files changed, 263 insertions(+)
> create mode 100644 recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> create mode 100644 recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> 
> diff --git a/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> new file mode 100644
> index 0000000..7b062b7
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch
> @@ -0,0 +1,178 @@
> +From 73b13705af7c3bb8fdf11932eb68788d090a443f Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
> +Date: Thu, 4 Mar 2021 16:49:00 +0100
> +Subject: [PATCH] firmware: provide a stand alone set of headers
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +The current build of the firmware relies on having 32bit compatible
> +headers installed in order to build some of the 32bit firmware.
> +Usually this can be solved by using the -ffreestanding compiler option
> +which drops the usage of the system headers in favor of a private set
> +of freestanding headers provided by the compiler itself that are not
> +tied to libc.
> +
> +However such option is broken at least in the gcc compiler provided in
> +Alpine Linux, as the system include path (ie: /usr/include) takes
> +precedence over the gcc private include path:
> +
> +#include <...> search starts here:
> + /usr/include
> + /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include
> +
> +And the headers in /usr/include are exclusively 64bit.
> +
> +Since -ffreestanding is currently broken on at least that distro, and
> +for resilience against future compilers also having the option broken
> +provide a set of stand alone 32bit headers required for the firmware
> +build.
> +
> +Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to Xen 4.14 by: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + tools/firmware/Rules.mk                       | 13 +++++++
> + tools/firmware/include/stdarg.h               | 10 +++++
> + tools/firmware/include/stdbool.h              |  9 +++++
> + tools/firmware/include/stddef.h               | 10 +++++
> + tools/firmware/include/stdint.h               | 39 +++++++++++++++++++
> + tools/firmware/rombios/32bit/rombios_compat.h |  4 +-
> + 6 files changed, 82 insertions(+), 3 deletions(-)
> + create mode 100644 tools/firmware/include/stdarg.h
> + create mode 100644 tools/firmware/include/stdbool.h
> + create mode 100644 tools/firmware/include/stddef.h
> + create mode 100644 tools/firmware/include/stdint.h
> +
> +diff --git a/tools/firmware/include/stdarg.h b/tools/firmware/include/stdarg.h
> +new file mode 100644
> +index 0000000000..c5e3761cd2
> +--- /dev/null
> ++++ b/tools/firmware/include/stdarg.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDARG_H_
> ++#define _STDARG_H_
> ++
> ++typedef __builtin_va_list va_list;
> ++#define va_copy(dest, src) __builtin_va_copy(dest, src)
> ++#define va_start(ap, last) __builtin_va_start(ap, last)
> ++#define va_end(ap) __builtin_va_end(ap)
> ++#define va_arg __builtin_va_arg
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdbool.h b/tools/firmware/include/stdbool.h
> +new file mode 100644
> +index 0000000000..0cf76b106c
> +--- /dev/null
> ++++ b/tools/firmware/include/stdbool.h
> +@@ -0,0 +1,9 @@
> ++#ifndef _STDBOOL_H_
> ++#define _STDBOOL_H_
> ++
> ++#define bool _Bool
> ++#define true 1
> ++#define false 0
> ++#define __bool_true_false_are_defined 1
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stddef.h
> +new file mode 100644
> +index 0000000000..c7f974608a
> +--- /dev/null
> ++++ b/tools/firmware/include/stddef.h
> +@@ -0,0 +1,10 @@
> ++#ifndef _STDDEF_H_
> ++#define _STDDEF_H_
> ++
> ++typedef __SIZE_TYPE__ size_t;
> ++
> ++#define NULL ((void*)0)
> ++
> ++#define offsetof(t, m) __builtin_offsetof(t, m)
> ++
> ++#endif
> +diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
> +new file mode 100644
> +index 0000000000..16a0b6de19
> +--- /dev/null
> ++++ b/tools/firmware/include/stdint.h
> +@@ -0,0 +1,39 @@
> ++#ifndef _STDINT_H_
> ++#define _STDINT_H_
> ++
> ++#if defined(__LP64__) || defined(__P64__)
> ++#error "32bit only header"
> ++#endif
> ++
> ++typedef unsigned char uint8_t;
> ++typedef signed char int8_t;
> ++
> ++typedef unsigned short uint16_t;
> ++typedef signed short int16_t;
> ++
> ++typedef unsigned int uint32_t;
> ++typedef signed int int32_t;
> ++
> ++typedef unsigned long long uint64_t;
> ++typedef signed long long int64_t;
> ++
> ++#define INT8_MIN        (-0x7f-1)
> ++#define INT16_MIN       (-0x7fff-1)
> ++#define INT32_MIN       (-0x7fffffff-1)
> ++#define INT64_MIN       (-0x7fffffffffffffffll-1)
> ++
> ++#define INT8_MAX        0x7f
> ++#define INT16_MAX       0x7fff
> ++#define INT32_MAX       0x7fffffff
> ++#define INT64_MAX       0x7fffffffffffffffll
> ++
> ++#define UINT8_MAX       0xff
> ++#define UINT16_MAX      0xffff
> ++#define UINT32_MAX      0xffffffffu
> ++#define UINT64_MAX      0xffffffffffffffffull
> ++
> ++typedef uint32_t uintptr_t;
> ++
> ++#define UINTPTR_MAX     UINT32_MAX
> ++
> ++#endif
> +diff --git a/tools/firmware/rombios/32bit/rombios_compat.h b/tools/firmware/rombios/32bit/rombios_compat.h
> +index 3fe7d67721..8ba4c17ffd 100644
> +--- a/tools/firmware/rombios/32bit/rombios_compat.h
> ++++ b/tools/firmware/rombios/32bit/rombios_compat.h
> +@@ -8,9 +8,7 @@
> + 
> + #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
> + 
> +-typedef unsigned char uint8_t;
> +-typedef unsigned short int uint16_t;
> +-typedef unsigned int uint32_t;
> ++#include <stdint.h>
> + 
> + typedef uint8_t  Bit8u;
> + typedef uint16_t Bit16u;
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index 26bbddccd4..cb388b7011 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -17,3 +17,16 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> + 
> + # Extra CFLAGS suitable for an embedded type of environment.
> + CFLAGS += -fno-builtin -msoft-float
> ++
> ++# Use our own set of stand alone headers to build firmware.
> ++#
> ++# Ideally using -ffreestanding should be enough, but that relies on the
> ++# compiler having the right order for include paths (ie: compiler private
> ++# headers before system ones) or the libc headers having proper arch-agnostic
> ++# freestanding support. This is not the case in Alpine at least which searches
> ++# system headers before compiler ones and has arch-specific libc headers. This
> ++# has been reported upstream:
> ++# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
> ++# In the meantime (and for resilience against broken systems) use our own set
> ++# of headers that provide what's needed for the firmware build.
> ++CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
> +-- 
> +2.25.1
> +
> diff --git a/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> new file mode 100644
> index 0000000..001b196
> --- /dev/null
> +++ b/recipes-extended/xen/files/0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch
> @@ -0,0 +1,83 @@
> +From 0eae016b6e3dce69e3fb86aca5c4f221591a2f12 Mon Sep 17 00:00:00 2001
> +From: Andrew Cooper <andrew.cooper3@citrix.com>
> +Date: Thu, 25 Feb 2021 19:15:08 +0000
> +Subject: [PATCH] tools/firmware: Build firmware as -ffreestanding
> +
> +firmware should always have been -ffreestanding, as it doesn't execute in the
> +host environment.  -ffreestanding implies -fno-builtin, so replace the option.
> +
> +inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants
> +the stdint.h types so switch to the more appropriate include.
> +
> +This removes the build time dependency on a 32bit libc just to compile the
> +hvmloader and friends.
> +
> +Update README and the TravisCI configuration.
> +
> +Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> +Reviewed-by: Jan Beulich <jbeulich@suse.com>
> +Reviewed-by: Ian Jackson <iwj@xenproject.org>
> +Release-Acked-by: Ian Jackson <iwj@xenproject.org>
> +Applied to m-v Xen 4.14 series: Christopher Clark <christopher.w.clark@gmail.com>
> +---
> + .travis.yml                                  | 1 -
> + README                                       | 3 ---
> + tools/firmware/Rules.mk                      | 2 +-
> + tools/firmware/hvmloader/32bitbios_support.c | 2 +-
> + 4 files changed, 2 insertions(+), 6 deletions(-)
> +
> +diff --git a/.travis.yml b/.travis.yml
> +index 15ca9e9047..2362475f7a 100644
> +--- a/.travis.yml
> ++++ b/.travis.yml
> +@@ -58,7 +58,6 @@ addons:
> +             - acpica-tools
> +             - bin86
> +             - bcc
> +-            - libc6-dev-i386
> +             - libnl-3-dev
> +             - ocaml-nox
> +             - libfindlib-ocaml-dev
> +diff --git a/README b/README
> +index 6e15242ae1..8c99c30986 100644
> +--- a/README
> ++++ b/README
> +@@ -62,9 +62,6 @@ provided by your OS distributor:
> +     * GNU bison and GNU flex
> +     * GNU gettext
> +     * ACPI ASL compiler (iasl)
> +-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
> +-      Required when building on a 64-bit platform to build
> +-      32-bit components which are enabled on a default build.
> + 
> + In addition to the above there are a number of optional build
> + prerequisites. Omitting these will cause the related features to be
> +diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk
> +index cb388b7011..9f78a7dec9 100644
> +--- a/tools/firmware/Rules.mk
> ++++ b/tools/firmware/Rules.mk
> +@@ -16,7 +16,7 @@ CFLAGS += -Werror
> + $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
> + 
> + # Extra CFLAGS suitable for an embedded type of environment.
> +-CFLAGS += -fno-builtin -msoft-float
> ++CFLAGS += -ffreestanding -msoft-float
> + 
> + # Use our own set of stand alone headers to build firmware.
> + #
> +diff --git a/tools/firmware/hvmloader/32bitbios_support.c b/tools/firmware/hvmloader/32bitbios_support.c
> +index 114135022e..ef681d4f57 100644
> +--- a/tools/firmware/hvmloader/32bitbios_support.c
> ++++ b/tools/firmware/hvmloader/32bitbios_support.c
> +@@ -20,7 +20,7 @@
> +  * this program; If not, see <http://www.gnu.org/licenses/>.
> +  */
> + 
> +-#include <inttypes.h>
> ++#include <stdint.h>
> + #include <elf.h>
> + #ifdef __sun__
> + #include <sys/machelf.h>
> +-- 
> +2.25.1
> +
> diff --git a/recipes-extended/xen/xen-tools_4.14.bb b/recipes-extended/xen/xen-tools_4.14.bb
> index a79b41d..10982a2 100644
> --- a/recipes-extended/xen/xen-tools_4.14.bb
> +++ b/recipes-extended/xen/xen-tools_4.14.bb
> @@ -6,6 +6,8 @@ XEN_BRANCH ?= "stable-${XEN_REL}"
> SRC_URI = " \
>     git://xenbits.xen.org/xen.git;branch=${XEN_BRANCH} \
>     file://0001-python-pygrub-pass-DISTUTILS-xen-4.14.patch \
> +    file://0001-firmware-provide-a-stand-alone-set-of-headers-Xen-4.14.patch \
> +    file://0001-tools-firmware-Build-firmware-as-ffreestanding-Xen-4.14.patch \
>     "
> 
> LIC_FILES_CHKSUM ?= "file://COPYING;md5=419739e325a50f3d7b4501338e44a4e5"
> -- 
> 2.25.1
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64
  2021-04-19 23:08 ` [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64 Christopher Clark
@ 2021-04-21  9:20   ` Bertrand Marquis
  0 siblings, 0 replies; 9+ messages in thread
From: Bertrand Marquis @ 2021-04-21  9:20 UTC (permalink / raw)
  To: Christopher Clark; +Cc: meta-virtualization, Doug Goldstein, Bruce Ashfield, nd

Hi,

> On 20 Apr 2021, at 00:08, Christopher Clark <christopher.w.clark@gmail.com> wrote:
> 
> Xen 4.15 added support for standalone x86-64 hvmloader build and
> previous commit provided Xen 4.14 backports.
> 
> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> recipes-extended/xen/xen-tools.inc | 37 ------------------------------
> 1 file changed, 37 deletions(-)
> 
> diff --git a/recipes-extended/xen/xen-tools.inc b/recipes-extended/xen/xen-tools.inc
> index 722c503..3560e79 100644
> --- a/recipes-extended/xen/xen-tools.inc
> +++ b/recipes-extended/xen/xen-tools.inc
> @@ -6,29 +6,6 @@ COMPATIBLE_HOST = 'i686-.*-linux|(x86_64.*).*-linux|aarch64.*-linux|arm-.*-linux
> inherit setuptools3 update-rc.d systemd deploy
> require xen-blktap.inc
> 
> -# To build hvmloader, which is needed on x86-64 targets when 'hvm' is enabled
> -# in PACKAGECONFIG, to support running HVM-mode guest VMs, some files from
> -# 32-bit glibc are needed.
> -# Add the multilib 32-bit glibc to DEPENDS only when necessary.
> -#
> -# To enable multilib, please add the following to your local.conf -:
> -#
> -#    require conf/multilib.conf
> -#    MULTILIBS = "multilib:lib32"
> -#    DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
> -
> -# Use this multilib prefix for x86 32-bit to match local.conf:
> -MLPREFIX32 = "lib32-"
> -
> -# The DEPENDS on a multilib 32-bit glibc is only added when target is x86-64
> -# and 'hvm' is enabled in PACKAGECONFIG.
> -# This x86-64 override is never intended for native use, so clear that.
> -GLIBC32 = ""
> -GLIBC32_x86-64 = \
> -    "${@bb.utils.contains('PACKAGECONFIG', 'hvm', '${MLPREFIX32}glibc', '', d)}"
> -GLIBC32_class-native = ""
> -DEPENDS += "${GLIBC32}"
> -
> RDEPENDS_${PN} = "\
>     bash perl xz \
>     ${PN}-console \
> @@ -736,16 +713,6 @@ SYSTEMD_SERVICE_${PN}-xencommons = " \
>     "
> SYSTEMD_SERVICE_${PN}-xendomains = "xendomains.service"
> 
> -# To build hvmloader, which is needed on x86-64 targets when 'hvm' is enabled
> -# in PACKAGECONFIG, additional CFLAGS are needed to set the 32-bit sysroot.
> -RECIPE_SYSROOT32 = "${WORKDIR}/${MLPREFIX32}recipe-sysroot"
> -ADD_SYSROOT32_CFLAGS = ""
> -ADD_SYSROOT32_CFLAGS_x86-64 = \
> -    "${@bb.utils.contains('PACKAGECONFIG', 'hvm', \
> -        'CFLAGS += "--sysroot=${RECIPE_SYSROOT32}"', '', d)}"
> -# This x86-64 override is never intended for native use, so clear that.
> -ADD_SYSROOT32_CFLAGS_class-native = ""
> -
> EXTRA_OECONF += " \
>     --with-systemd=${systemd_unitdir}/system \
>     --with-systemd-modules-load=${systemd_unitdir}/modules-load.d \
> @@ -756,10 +723,6 @@ EXTRA_OECONF += " \
> 
> do_configure() {
>     do_configure_common
> -
> -    if [ -n '${ADD_SYSROOT32_CFLAGS}' ] ; then
> -        echo '${ADD_SYSROOT32_CFLAGS}' >>"${S}/tools/firmware/Rules.mk"
> -    fi
> }
> 
> do_compile() {
> -- 
> 2.25.1
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency
  2021-04-19 23:08 ` [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency Christopher Clark
@ 2021-04-21  9:22   ` Bertrand Marquis
  0 siblings, 0 replies; 9+ messages in thread
From: Bertrand Marquis @ 2021-04-21  9:22 UTC (permalink / raw)
  To: Christopher Clark
  Cc: meta-virtualization, Doug Goldstein, Bruce Ashfield, Andrew Cooper, nd

Hi,

> On 20 Apr 2021, at 00:08, Christopher Clark via lists.yoctoproject.org <christopher.w.clark=gmail.com@lists.yoctoproject.org> wrote:
> 
> The latest Xen Test Framework has removed the gcc-multilib dependency.
> 
> Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>

XTF is compiling properly in a project without multilib for x86_64.

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> recipes-extended/xen/xtf_git.bb | 21 ++-------------------
> 1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/recipes-extended/xen/xtf_git.bb b/recipes-extended/xen/xtf_git.bb
> index db08643..3580324 100644
> --- a/recipes-extended/xen/xtf_git.bb
> +++ b/recipes-extended/xen/xtf_git.bb
> @@ -6,7 +6,7 @@ LICENSE = "BSD-2-Clause"
> # https://static.sched.com/hosted_files/xendeveloperanddesignsummit2017/79/xtf.pdf
> 
> SRC_URI = "git://xenbits.xen.org/xtf"
> -SRCREV = "8ab15139728a8efd3ebbb60beb16a958a6a93fa1"
> +SRCREV = "b0bc49846c154b79243f39d461a4515804bcaf53"
> 
> COMPATIBLE_HOST = '(x86_64.*).*-linux'
> 
> @@ -18,23 +18,6 @@ S = "${WORKDIR}/git"
> 
> inherit python3native
> 
> -# To build 32-bit binaries some files from 32-bit glibc are needed.
> -# To enable multilib, please add the following to your local.conf -:
> -#
> -#    require conf/multilib.conf
> -#    MULTILIBS = "multilib:lib32"
> -#    DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
> -
> -# Use this multilib prefix for x86 32-bit to match local.conf:
> -MLPREFIX32 = "lib32-"
> -# Add the multilib 32-bit glibc to DEPENDS only when necessary:
> -# The DEPENDS on a multilib 32-bit glibc is only added when target is x86-64
> -# This x86-64 override is never intended for native use, so clear that.
> -GLIBC32 = ""
> -GLIBC32_x86-64 = "${MLPREFIX32}glibc"
> -GLIBC32_class-native = ""
> -DEPENDS += "${GLIBC32}"
> -
> PACKAGES = "${PN}"
> 
> FILES_${PN} = " \
> @@ -47,7 +30,7 @@ RDEPENDS_${PN} = " \
>     "
> 
> do_compile() {
> -    oe_runmake CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} -I${RECIPE_SYSROOT}/../${MLPREFIX32}recipe-sysroot/usr/include" \
> +    oe_runmake CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" \
>                CPP="${CPP}" \
>                OBJCOPY="${OBJCOPY}" \
>                PYTHON="${PYTHON}"
> -- 
> 2.25.1
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-21  9:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 23:08 [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Christopher Clark
2021-04-19 23:08 ` [meta-virtualization][PATCH 2/3] xen-tools: remove multilib build requirement for x86-64 Christopher Clark
2021-04-21  9:20   ` Bertrand Marquis
2021-04-19 23:08 ` [meta-virtualization][PATCH 3/3] xtf: update SRCREV and remove multilib dependency Christopher Clark
2021-04-21  9:22   ` Bertrand Marquis
2021-04-20  2:05 ` [meta-virtualization][PATCH 1/3] xen-tools: add patches for 4.14 to enable dropping multilib build Bruce Ashfield
2021-04-20 21:00 ` Bruce Ashfield
2021-04-20 21:51   ` Christopher Clark
2021-04-21  9:20 ` Bertrand Marquis

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.