diff mbox

package/xen: fix build failure on x86 after bump to 4.7

Message ID 1477989452-26462-1-git-send-email-yann.morin.1998@free.fr
State Accepted
Headers show

Commit Message

Yann E. MORIN Nov. 1, 2016, 8:37 a.m. UTC
Since the bump to 4.7, Xen fails to build because of a double definition
of __OBJECT_FILE__. This is due to (who would have guessed) the weirdness
of their buildsystem.

Fix that with a dirty hack: undefine the macro before defining it.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Alistair Francis <alistair.francis@xilinx.com>
[Alistair: Tested on ARMv7 (little endian) boot.]
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
---
 ...mk-fix-build-with-CFLAGS-from-environment.patch | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch

Comments

Thomas Petazzoni Nov. 1, 2016, 1:54 p.m. UTC | #1
Hello,

On Tue,  1 Nov 2016 09:37:32 +0100, Yann E. MORIN wrote:
> Since the bump to 4.7, Xen fails to build because of a double definition
> of __OBJECT_FILE__. This is due to (who would have guessed) the weirdness
> of their buildsystem.
> 
> Fix that with a dirty hack: undefine the macro before defining it.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Alistair Francis <alistair.francis@xilinx.com>
> [Alistair: Tested on ARMv7 (little endian) boot.]
> Tested-by: Alistair Francis <alistair.francis@xilinx.com>
> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
>  ...mk-fix-build-with-CFLAGS-from-environment.patch | 36 ++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>  create mode 100644 package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch

This is indeed not the prettiest solution, but it's good enough. Has
one of you reported the problem upstream to the Xen people?

I've applied Yann's patch anyway.

Thanks a lot for the investigation and workaround!

Thomas
Alistair Francis Dec. 1, 2016, 12:22 a.m. UTC | #2
On Tue, Nov 1, 2016 at 6:54 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Tue,  1 Nov 2016 09:37:32 +0100, Yann E. MORIN wrote:
>> Since the bump to 4.7, Xen fails to build because of a double definition
>> of __OBJECT_FILE__. This is due to (who would have guessed) the weirdness
>> of their buildsystem.
>>
>> Fix that with a dirty hack: undefine the macro before defining it.
>>
>> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
>> Cc: Alistair Francis <alistair.francis@xilinx.com>
>> [Alistair: Tested on ARMv7 (little endian) boot.]
>> Tested-by: Alistair Francis <alistair.francis@xilinx.com>
>> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>>  ...mk-fix-build-with-CFLAGS-from-environment.patch | 36 ++++++++++++++++++++++
>>  1 file changed, 36 insertions(+)
>>  create mode 100644 package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch
>
> This is indeed not the prettiest solution, but it's good enough. Has
> one of you reported the problem upstream to the Xen people?

Sorry about the radio silence here, I was away for a bit and then super busy.

If it's ok with you Yann I was planning on sending the two Xen patches
we have to mainline Xen and at least see what they think about this
issue. I don't have a huge amount of experience with them so I'm not
sure if they are interested in this, but I figured it is worth a try
anyway.

Thanks,

Alistair

>
> I've applied Yann's patch anyway.
>
> Thanks a lot for the investigation and workaround!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
diff mbox

Patch

diff --git a/package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch b/package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch
new file mode 100644
index 0000000..0d4e581
--- /dev/null
+++ b/package/xen/0002-xen-Rules.mk-fix-build-with-CFLAGS-from-environment.patch
@@ -0,0 +1,36 @@ 
+From 2a310549aaeaba05f640ade43488bb893101ce4a Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Date: Sat, 29 Oct 2016 16:35:26 +0200
+Subject: [PATCH] xen/Rules.mk: fix build with CFLAGS from environment
+
+When CFLAGS are passed from the environment, the first-level make
+invocation will append -D__OBJECT_FILE__ to it, then call a second
+make invocation, that will have those new CFLAGS in its environment,
+but will also append -D__OBJECT_FILE__ to those.
+
+Then, the compiler fails because __OBEJECT_FILE__ is defined twice.
+
+Just undefine it before defining it again, as a *workaround* to this
+issue.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+---
+ xen/Rules.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xen/Rules.mk b/xen/Rules.mk
+index a9fda71..09ccbfa 100644
+--- a/xen/Rules.mk
++++ b/xen/Rules.mk
+@@ -49,7 +49,7 @@ ALL_OBJS-$(CONFIG_CRYPTO)   += $(BASEDIR)/crypto/built_in.o
+ CFLAGS += -nostdinc -fno-builtin -fno-common
+ CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
+ CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
+-CFLAGS += '-D__OBJECT_FILE__="$@"'
++CFLAGS += -U__OBJECT_FILE__ '-D__OBJECT_FILE__="$@"'
+ 
+ ifneq ($(clang),y)
+ # Clang doesn't understand this command line argument, and doesn't appear to
+-- 
+2.7.4
+