[XEN PATCH v8 39/47] RFC, no-VPATH: x86/boot: workaround gcc including the wrong file

Anthony PERARD posted 47 patches 3 years ago
There is a newer version of this series
[XEN PATCH v8 39/47] RFC, no-VPATH: x86/boot: workaround gcc including the wrong file
Posted by Anthony PERARD 3 years ago
From: Anthony PERARD <anthony.perard@gmail.com>

we generate cmdline.S and reloc.S, so we should include those
generated file as presented in the build tree, but for file included
with quote, gcc will first look into the directory where the source
file is, that is where head.S is located and thus include cmdline.S
that is present in the source tree when it is dirty. But that the
wrong file as we want to include the file from the build tree. Work
around by using <> to include those file as if the come from the
system, as gcc will first look in directories listed with '-I' on the
command line.

So now we also need to add -I when building in the source tree.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/arch/x86/boot/Makefile | 4 +++-
 xen/arch/x86/boot/head.S   | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
index 04ee9da83333..4fc6b1d8ffc2 100644
--- a/xen/arch/x86/boot/Makefile
+++ b/xen/arch/x86/boot/Makefile
@@ -8,7 +8,9 @@ targets += $(head-objs:.S=.o)
 head-objs := $(addprefix $(obj)/, $(head-objs))
 
 ifdef building_out_of_srctree
-$(obj)/head.o: CFLAGS-y += -iquote $(obj)
+$(obj)/head.o: CFLAGS-y += -I$(obj)
+else
+$(obj)/head.o: CFLAGS-y += -I$(src)
 endif
 $(obj)/head.o: $(head-objs)
 
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index dd1bea0d10b3..66acd2e9bfc0 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -772,10 +772,10 @@ trampoline_setup:
         lret
 
 cmdline_parse_early:
-#include "cmdline.S"
+#include <cmdline.S>
 
 reloc:
-#include "reloc.S"
+#include <reloc.S>
 
 ENTRY(trampoline_start)
 #include "trampoline.S"
-- 
Anthony PERARD