All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stewart Hildebrand via buildroot <buildroot@buildroot.org>
To: Neal Frager <neal.frager@amd.com>, buildroot@buildroot.org
Cc: alistair@alistair23.me, stefano.stabellini@amd.com,
	ibai.erkiaga-elorza@amd.com, luca.ceresoli@bootlin.com,
	micheal.saleab@amd.com, yann.morin@orange.com,
	matthew.l.weber3@boeing.com, brandon.maier@collins.com,
	john.ernberg@actia.se, brian.j.wood2@boeing.com, ju.o@free.fr,
	thomas.petazzoni@bootlin.com, romain.naour@smile.fr,
	michal.simek@amd.com, romain.naour@gmail.com
Subject: Re: [Buildroot] [PATCH v5 1/4] package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled
Date: Fri, 28 Aug 2026 12:36:51 +0200	[thread overview]
Message-ID: <a8920732-5a16-49ba-82f5-c9405d210d5d@amd.com> (raw)
In-Reply-To: <20260826064649.292291-1-neal.frager@amd.com>

On 8/26/26 08:46, Neal Frager wrote:
> 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>

Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>

Thank you for this. I just want to provide a few more details for future
reference.

__XEN_INTERFACE_VERSION__ being defined is a side-effect of including either
xen.git/xen/include/public/xen.h (via #include <xen/xen.h>) or
qemu.git/include/hw/xen/xen.h (via #include "hw/xen/xen.h"). In Qemu, we could
have considered changing the check in xen_native.h to
#if defined(__XEN_PUBLIC_XEN_H__) || defined(QEMU_HW_XEN_H)
Then we'd be checking for the header inclusion directly instead of relying on a
side-effect, and that would also allow passing -D__XEN_INTERFACE_VERSION__=...
as buildroot was doing. But this approach is not strictly necessary IMO, and it
would be better to find a solution without maintaining a patch for qemu.

For context, when building Xen tools, we define __XEN_INTERFACE_VERSION__ on the
command line via CFLAGS - see xen.git/tools/Rules.mk:
CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__

Xen tools has a build target for qemu
(xen.git/tools/Makefile:subdir-all-qemu-xen-dir), and it typically invokes the
qemu build with a fresh set of CFLAGS, i.e. the -D__XEN_INTERFACE_VERSION__=...
should be dropped. However, buildroot somehow propagates the
-D__XEN_INTERFACE_VERSION__=... when building qemu-xen, hence triggering the
include order assertion in qemu.git/include/hw/xen/xen_native.h.

So the fix herein is to undo the __XEN_INTERFACE_VERSION__ define on the command
line when building qemu. Thus, __XEN_INTERFACE_VERSION__ will be defined in the
usual manner when including the appropriate header.

> ---
> V1->V2:
> - changed method to modify patches instead of xen.mk
> V2->V3:
> - removed text from commit message which appears as start of patch
> V3->V4:
> - merged into patch series as the first patch
> V4->V5:
> - removed qemu-xen patch
> - undefined __XEN_INTERFACE_VERSION__ from qemu-xen
> ---
>  package/xen/0002-Update-linker-flags.patch | 16 +---------------
>  package/xen/xen.mk                         |  3 ++-
>  2 files changed, 3 insertions(+), 16 deletions(-)
> 
> diff --git a/package/xen/0002-Update-linker-flags.patch b/package/xen/0002-Update-linker-flags.patch
> index ac02722781..3ba678cd9b 100644
> --- a/package/xen/0002-Update-linker-flags.patch
> +++ b/package/xen/0002-Update-linker-flags.patch
> @@ -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
>  
> diff --git a/package/xen/xen.mk b/package/xen/xen.mk
> index 75252d1123..bddfdbba38 100644
> --- a/package/xen/xen.mk
> +++ b/package/xen/xen.mk
> @@ -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

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2026-08-28 10:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  6:46 [Buildroot] [PATCH v5 1/4] package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled Neal Frager via buildroot
2026-08-26  6:46 ` [Buildroot] [PATCH v5 2/4] package/xen: add custom version support Neal Frager via buildroot
2026-08-27  0:45   ` Matthew Weber
2026-08-26  6:46 ` [Buildroot] [PATCH v5 3/4] package/xen: add custom tarball support Neal Frager via buildroot
2026-08-27  0:46   ` Matthew Weber
2026-08-28 10:45   ` Stewart Hildebrand via buildroot
2026-08-26  6:46 ` [Buildroot] [PATCH v5 4/4] package/xen: add custom git support Neal Frager via buildroot
2026-08-27  0:47   ` Matthew Weber
2026-08-27  0:43 ` [Buildroot] [PATCH v5 1/4] package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled Matthew Weber
2026-08-28 10:36 ` Stewart Hildebrand via buildroot [this message]
2026-09-11  5:21   ` Frager, Neal via buildroot
2026-09-16  6:51 ` Peter Korsgaard
2026-09-25 14:43 ` Raphaël Mélotte via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8920732-5a16-49ba-82f5-c9405d210d5d@amd.com \
    --to=buildroot@buildroot.org \
    --cc=alistair@alistair23.me \
    --cc=brandon.maier@collins.com \
    --cc=brian.j.wood2@boeing.com \
    --cc=ibai.erkiaga-elorza@amd.com \
    --cc=john.ernberg@actia.se \
    --cc=ju.o@free.fr \
    --cc=luca.ceresoli@bootlin.com \
    --cc=matthew.l.weber3@boeing.com \
    --cc=michal.simek@amd.com \
    --cc=micheal.saleab@amd.com \
    --cc=neal.frager@amd.com \
    --cc=romain.naour@gmail.com \
    --cc=romain.naour@smile.fr \
    --cc=stefano.stabellini@amd.com \
    --cc=stewart.hildebrand@amd.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=yann.morin@orange.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.