diff mbox

[3/7] xen/Rules.mk: fix build with CFLAGS from environment

Message ID 1481928967-4130-4-git-send-email-alistair.francis@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alistair Francis Dec. 16, 2016, 10:56 p.m. UTC
From: "Yann E. MORIN" <yann.morin.1998@free.fr>

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(-)

Comments

Konrad Rzeszutek Wilk Dec. 17, 2016, 3:54 p.m. UTC | #1
On Fri, Dec 16, 2016 at 02:56:03PM -0800, Alistair Francis wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> 
> 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.

Hm, workaround?

Well that is good, but what if we just fix it in the first place?

I recall hitting this with Fedora Core and the suggested fix was
add in config/StdGNU.mk and 'EXTRA_CFLAGS' or such that would
be utilized by CFLAGS.

The rpmbuild would then use EXTRA_CFLAGS or such to set
the extra flags?
> 
> 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 24d13dc..f8b8c2c 100644
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -49,7 +49,7 @@ endif
>  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
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
Jan Beulich Dec. 19, 2016, 8:32 a.m. UTC | #2
>>> On 16.12.16 at 23:56, <alistair.francis@xilinx.com> wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> 
> When CFLAGS are passed from the environment,

But that's what shouldn't be done.

Jan
diff mbox

Patch

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 24d13dc..f8b8c2c 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -49,7 +49,7 @@  endif
 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