package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled

The 0002-Update-linker-flags.patch assumes that the qemu-xen files are included
in the xen source tree. However, if BR2_PACKAGE_XEN_TOOLS is not enabled, the
qemu-xen dependency will not be handled and the patch will fail to apply with
the following error.

Fixes: build error below
Applying 0002-Update-linker-flags.patch using patch:
patching file tools/Makefile
Hunk #1 succeeded at 36 (offset -1 lines).
Hunk #2 succeeded at 185 (offset -8 lines).
can't find file to patch at input line 76
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/tools/qemu-xen/include/hw/xen/xen_native.h b/tools/qemu-xen/include/hw/xen/xen_native.h
|index 6bcc83ba..2590904e 100644
|--- a/tools/qemu-xen/include/hw/xen/xen_native.h
|+++ b/tools/qemu-xen/include/hw/xen/xen_native.h
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
make: *** [package/pkg-generic.mk:239: output/build/xen-4.21.1/.stamp_patched] Error 1

To avoid making BR2_PACKAGE_XEN_TOOLS a required option, fix the
0002-Update-linker-flags.patch so that modifying source from the qemu-xen
package is no longer included.

Instead of patching qemu-xen, a better solution is undefining the
__XEN_INTERFACE_VERSION__ from the qemu-xen package.

To test:
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
BR2_PACKAGE_XEN=y
 # BR2_PACKAGE_XEN_TOOLS is not set

Signed-off-by: Neal Frager <neal.frager@amd.com>
Tested-by: Matt Weber <matt@thewebers.ws>
Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit f63e572432)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
Neal Frager
2026-08-26 07:46:46 +01:00
committed by Raphaël Mélotte
parent 01f4bae85b
commit 16462dee66
2 changed files with 3 additions and 16 deletions

View File

@@ -16,8 +16,7 @@ Upstream: Buildroot specific. This is a temporary patch for an intermediate bump
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
---
tools/Makefile | 29 ++++++++++++++++++++-
tools/qemu-xen/include/hw/xen/xen_native.h | 2 +-
2 files changed, 29 insertions(+), 2 deletions(-)
1 file changed, 28 insertions(+), 1 deletions(-)
diff --git a/tools/Makefile b/tools/Makefile
index a9a3196e..5d289651 100644
@@ -69,19 +68,6 @@ index a9a3196e..5d289651 100644
--bindir=$(LIBEXEC_BIN) \
--datadir=$(SHAREDIR)/qemu-xen \
--localstatedir=$(localstatedir) \
diff --git a/tools/qemu-xen/include/hw/xen/xen_native.h b/tools/qemu-xen/include/hw/xen/xen_native.h
index 6bcc83ba..2590904e 100644
--- a/tools/qemu-xen/include/hw/xen/xen_native.h
+++ b/tools/qemu-xen/include/hw/xen/xen_native.h
@@ -2,7 +2,7 @@
#define QEMU_HW_XEN_NATIVE_H
#ifdef __XEN_INTERFACE_VERSION__
-#error In Xen native files, include xen_native.h before other Xen headers
+#warning In Xen native files, include xen_native.h before other Xen headers
#endif
/*
--
2.51.0

View File

@@ -40,7 +40,8 @@ XEN_MAKE_ENV = \
CROSS_COMPILE=$(TARGET_CROSS) \
HOST_EXTRACFLAGS="-Wno-error" \
XEN_HAS_CHECKPOLICY=n \
$(TARGET_CONFIGURE_OPTS)
$(TARGET_CONFIGURE_OPTS) \
EXTRA_CFLAGS_QEMU_XEN="-U__XEN_INTERFACE_VERSION__"
ifeq ($(BR2_PACKAGE_XEN_HYPERVISOR),y)
XEN_MAKE_OPTS += dist-xen