diff mbox series

[XEN,v7,12/51] build: avoid building arm/arm/*/head.o twice

Message ID 20210824105038.1257926-13-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series xen: Build system improvements, now with out-of-tree build! | expand

Commit Message

Anthony PERARD Aug. 24, 2021, 10:49 a.m. UTC
head.o is been built twice, once because it is in $(ALL_OBJS) and a
second time because it is in $(extra-y) and thus it is rebuilt when
building "arch/arm/built_in.o".

Fix this by adding a dependency of "head.o" on the directory
"arch/arm/".

Also, we should avoid building object that are in subdirectories, so
move the declaration in there. This doesn't change anything as
"arch/arm/built_in.o" depends on "arch/arm/$subarch/built_in.o" which
depends on $(extra-y), so we still need to depend on
"arch/arm/built_in.o".

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/arch/arm/Makefile       | 7 ++++++-
 xen/arch/arm/arm32/Makefile | 1 +
 xen/arch/arm/arm64/Makefile | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Julien Grall Aug. 24, 2021, 12:53 p.m. UTC | #1
Hi Anthony,

On 24/08/2021 11:49, Anthony PERARD wrote:
> head.o is been built twice, once because it is in $(ALL_OBJS) and a
> second time because it is in $(extra-y) and thus it is rebuilt when
> building "arch/arm/built_in.o".
> 
> Fix this by adding a dependency of "head.o" on the directory
> "arch/arm/".
> 
> Also, we should avoid building object that are in subdirectories, so
> move the declaration in there. This doesn't change anything as
> "arch/arm/built_in.o" depends on "arch/arm/$subarch/built_in.o" which
> depends on $(extra-y), so we still need to depend on
> "arch/arm/built_in.o".

head.o as to be right at the beginning of the binary. Will this still be 
guaranteed with this change?

Cheers,

> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
>   xen/arch/arm/Makefile       | 7 ++++++-
>   xen/arch/arm/arm32/Makefile | 1 +
>   xen/arch/arm/arm64/Makefile | 2 ++
>   3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 3d0af8ebc93c..cc90d9796e6e 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -64,7 +64,6 @@ obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
>   obj-y += vsmc.o
>   obj-y += vpsci.o
>   obj-y += vuart.o
> -extra-y += $(TARGET_SUBARCH)/head.o
>   
>   extra-y += xen.lds
>   
> @@ -76,6 +75,12 @@ endif
>   
>   ALL_OBJS := $(TARGET_SUBARCH)/head.o $(ALL_OBJS)
>   
> +# head.o is built by descending into the sub-directory, depends on the part of
> +# $(ALL_OBJS) that will eventually recurse into $(TARGET_SUBARCH)/ and build
> +# head.o
> +$(TARGET_SUBARCH)/head.o: $(BASEDIR)/arch/arm/built_in.o
> +$(TARGET_SUBARCH)/head.o: ;
> +
>   ifdef CONFIG_LIVEPATCH
>   all_symbols = --all-symbols
>   ifdef CONFIG_FAST_SYMBOL_LOOKUP
> diff --git a/xen/arch/arm/arm32/Makefile b/xen/arch/arm/arm32/Makefile
> index 96105d238307..3040eabce3ad 100644
> --- a/xen/arch/arm/arm32/Makefile
> +++ b/xen/arch/arm/arm32/Makefile
> @@ -11,3 +11,4 @@ obj-y += smpboot.o
>   obj-y += traps.o
>   obj-y += vfp.o
>   
> +extra-y += head.o
> diff --git a/xen/arch/arm/arm64/Makefile b/xen/arch/arm/arm64/Makefile
> index 40642ff57494..0bb284dedab2 100644
> --- a/xen/arch/arm/arm64/Makefile
> +++ b/xen/arch/arm/arm64/Makefile
> @@ -13,3 +13,5 @@ obj-y += smpboot.o
>   obj-y += traps.o
>   obj-y += vfp.o
>   obj-y += vsysreg.o
> +
> +extra-y += head.o
>
Anthony PERARD Aug. 24, 2021, 3:12 p.m. UTC | #2
On Tue, Aug 24, 2021 at 01:53:11PM +0100, Julien Grall wrote:
> Hi Anthony,
> 
> On 24/08/2021 11:49, Anthony PERARD wrote:
> > head.o is been built twice, once because it is in $(ALL_OBJS) and a
> > second time because it is in $(extra-y) and thus it is rebuilt when
> > building "arch/arm/built_in.o".
> > 
> > Fix this by adding a dependency of "head.o" on the directory
> > "arch/arm/".
> > 
> > Also, we should avoid building object that are in subdirectories, so
> > move the declaration in there. This doesn't change anything as
> > "arch/arm/built_in.o" depends on "arch/arm/$subarch/built_in.o" which
> > depends on $(extra-y), so we still need to depend on
> > "arch/arm/built_in.o".
> 
> head.o as to be right at the beginning of the binary. Will this still be
> guaranteed with this change?

I guess what you want to know is: no change to the final binary.

The layout of the final binary is defined by $(ALL_OBJS), which this
patch doesn't change.

This patch only ask make that when it want to build "head.o", it need
first to build "arm/built_in.o", then "head.o" exist so we ask make to
not do anything in this Makefile.

Thanks,
Julien Grall Aug. 24, 2021, 3:20 p.m. UTC | #3
Hi Anthony,

On 24/08/2021 16:12, Anthony PERARD wrote:
> On Tue, Aug 24, 2021 at 01:53:11PM +0100, Julien Grall wrote:
>> Hi Anthony,
>>
>> On 24/08/2021 11:49, Anthony PERARD wrote:
>>> head.o is been built twice, once because it is in $(ALL_OBJS) and a
>>> second time because it is in $(extra-y) and thus it is rebuilt when
>>> building "arch/arm/built_in.o".
>>>
>>> Fix this by adding a dependency of "head.o" on the directory
>>> "arch/arm/".
>>>
>>> Also, we should avoid building object that are in subdirectories, so
>>> move the declaration in there. This doesn't change anything as
>>> "arch/arm/built_in.o" depends on "arch/arm/$subarch/built_in.o" which
>>> depends on $(extra-y), so we still need to depend on
>>> "arch/arm/built_in.o".
>>
>> head.o as to be right at the beginning of the binary. Will this still be
>> guaranteed with this change?
> 
> I guess what you want to know is: no change to the final binary.
> 
> The layout of the final binary is defined by $(ALL_OBJS), which this
> patch doesn't change.
> 
> This patch only ask make that when it want to build "head.o", it need
> first to build "arm/built_in.o", then "head.o" exist so we ask make to
> not do anything in this Makefile.

Cool. Thanks for the confirmation! You can add:

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 3d0af8ebc93c..cc90d9796e6e 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -64,7 +64,6 @@  obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
 obj-y += vsmc.o
 obj-y += vpsci.o
 obj-y += vuart.o
-extra-y += $(TARGET_SUBARCH)/head.o
 
 extra-y += xen.lds
 
@@ -76,6 +75,12 @@  endif
 
 ALL_OBJS := $(TARGET_SUBARCH)/head.o $(ALL_OBJS)
 
+# head.o is built by descending into the sub-directory, depends on the part of
+# $(ALL_OBJS) that will eventually recurse into $(TARGET_SUBARCH)/ and build
+# head.o
+$(TARGET_SUBARCH)/head.o: $(BASEDIR)/arch/arm/built_in.o
+$(TARGET_SUBARCH)/head.o: ;
+
 ifdef CONFIG_LIVEPATCH
 all_symbols = --all-symbols
 ifdef CONFIG_FAST_SYMBOL_LOOKUP
diff --git a/xen/arch/arm/arm32/Makefile b/xen/arch/arm/arm32/Makefile
index 96105d238307..3040eabce3ad 100644
--- a/xen/arch/arm/arm32/Makefile
+++ b/xen/arch/arm/arm32/Makefile
@@ -11,3 +11,4 @@  obj-y += smpboot.o
 obj-y += traps.o
 obj-y += vfp.o
 
+extra-y += head.o
diff --git a/xen/arch/arm/arm64/Makefile b/xen/arch/arm/arm64/Makefile
index 40642ff57494..0bb284dedab2 100644
--- a/xen/arch/arm/arm64/Makefile
+++ b/xen/arch/arm/arm64/Makefile
@@ -13,3 +13,5 @@  obj-y += smpboot.o
 obj-y += traps.o
 obj-y += vfp.o
 obj-y += vsysreg.o
+
+extra-y += head.o