Files
buildroot/package/xen/0002-Update-linker-flags.patch
Neal Frager 16462dee66 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>
2026-09-23 17:54:50 +02:00

74 lines
2.6 KiB
Diff

From 2ba2eef5b11d81b801265ae92df91571c19cc8a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= <vincent.stehle@arm.com>
Date: Tue, 30 Sep 2025 11:39:54 +0200
Subject: [PATCH] Update linker flags
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The -I$(XEN_ROOT)/tools/include added to QEMU's extra-cflags causes
__XEN_INTERFACE_VERSION__ to be defined before xen_native.h is included,
triggering an include-order assertion. Downgrade to a warning since the
version is consistent in cross-compile.
Ref: https://github.com/qemu/qemu/commit/e2abfe5ec6
Upstream: Buildroot specific. This is a temporary patch for an intermediate bump.
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
---
tools/Makefile | 29 ++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletions(-)
diff --git a/tools/Makefile b/tools/Makefile
index a9a3196e..5d289651 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -37,8 +37,12 @@ SUBDIRS-$(CONFIG_X86) += xenpaging
SUBDIRS-$(CONFIG_X86) += debugger
SUBDIRS-$(CONFIG_TESTS) += tests
+# These don't cross-compile
+ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
SUBDIRS-y += python
SUBDIRS-$(CONFIG_PYGRUB) += pygrub
+endif
+
SUBDIRS-$(OCAML_TOOLS) += ocaml
ifeq ($(CONFIG_RUMP),y)
@@ -189,8 +193,31 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find
-DXC_WANT_COMPAT_GNTTAB_API=1 \
-DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \
-DXC_WANT_COMPAT_DEVICEMODEL_API=1 \
+ -I$(XEN_ROOT)/tools/include \
$(EXTRA_CFLAGS_QEMU_XEN)" \
- --extra-ldflags="$(QEMU_UPSTREAM_RPATH)" \
+ --extra-ldflags=" \
+ -L$(XEN_ROOT)/tools/libs/call \
+ -L$(XEN_ROOT)/tools/libs/ctrl \
+ -L$(XEN_ROOT)/tools/libs/devicemodel \
+ -L$(XEN_ROOT)/tools/libs/evtchn \
+ -L$(XEN_ROOT)/tools/libs/foreignmemory \
+ -L$(XEN_ROOT)/tools/libs/gnttab \
+ -L$(XEN_ROOT)/tools/libs/guest \
+ -L$(XEN_ROOT)/tools/libs/store \
+ -L$(XEN_ROOT)/tools/libs/toolcore \
+ -L$(XEN_ROOT)/tools/libs/toollog \
+ -L$(XEN_ROOT)/tools/xenstore \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/ctrl \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/devicemodel \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/evtchn \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/guest \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/store \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toolcore \
+ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \
+ $(QEMU_UPSTREAM_RPATH)" \
--bindir=$(LIBEXEC_BIN) \
--datadir=$(SHAREDIR)/qemu-xen \
--localstatedir=$(localstatedir) \
--
2.51.0