[Buildroot] [PATCH v1 1/1] package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled

Neal Frager via buildroot <[email protected]> Mon, 3 Aug 2026 08:39:48 +0100
Newsgroups net.busybox.buildroot
Message-ID <[email protected]>
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, move the xen
dependency list out of the if statement, so that the qemu-xen will always build
before xen and make sure the XEN_INSTALL_QEMU_XEN_SRC runs so the qemu-xen
sources get included in the xen source tree before applying
0002-Update-linker-flags.patch.

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

Signed-off-by: Neal Frager <[email protected]>
---
 package/xen/xen.mk | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/package/xen/xen.mk b/package/xen/xen.mk
index 75252d1123..b7b6561e1b 100644
--- a/package/xen/xen.mk
+++ b/package/xen/xen.mk
@@ -52,7 +52,6 @@ else
 XEN_CONF_OPTS += --disable-xen
 endif
 
-ifeq ($(BR2_PACKAGE_XEN_TOOLS),y)
 XEN_DEPENDENCIES += \
 	dtc \
 	libaio \
@@ -64,12 +63,6 @@ XEN_DEPENDENCIES += \
 	slirp \
 	util-linux \
 	yajl
-ifeq ($(BR2_PACKAGE_ARGP_STANDALONE),y)
-XEN_DEPENDENCIES += argp-standalone
-endif
-XEN_INSTALL_TARGET_OPTS += DESTDIR=$(TARGET_DIR) install-tools
-XEN_MAKE_OPTS += dist-tools
-XEN_CONF_OPTS += --with-extra-qemuu-configure-args="--disable-sdl --disable-opengl"
 
 # Place the pre-downloaded qemu-xen source where the Xen build expects it.
 # This prevents Xen from trying to git-clone qemu-xen during the build.
@@ -80,6 +73,14 @@ define XEN_INSTALL_QEMU_XEN_SRC
 endef
 XEN_POST_EXTRACT_HOOKS += XEN_INSTALL_QEMU_XEN_SRC
 
+ifeq ($(BR2_PACKAGE_XEN_TOOLS),y)
+ifeq ($(BR2_PACKAGE_ARGP_STANDALONE),y)
+XEN_DEPENDENCIES += argp-standalone
+endif
+XEN_INSTALL_TARGET_OPTS += DESTDIR=$(TARGET_DIR) install-tools
+XEN_MAKE_OPTS += dist-tools
+XEN_CONF_OPTS += --with-extra-qemuu-configure-args="--disable-sdl --disable-opengl"
+
 define XEN_INSTALL_INIT_SYSV
 	mv $(TARGET_DIR)/etc/init.d/xencommons $(TARGET_DIR)/etc/init.d/S50xencommons
 	mv $(TARGET_DIR)/etc/init.d/xen-watchdog $(TARGET_DIR)/etc/init.d/S50xen-watchdog
-- 
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot