diff mbox

kbuild: add %/built-in.o target in top Makefile

Message ID 1477313111-25205-1-git-send-email-richard.weiyang@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yang Oct. 24, 2016, 12:45 p.m. UTC
Current kbuild just supports building built-in.o in second directory level
individually. There is no rule to build those built-in.o targets below
third directory level.

Even current kbuild system could achieve this with rule "%/", while this
not only builds built-in targes but also lib target, extra target and
module objects.

This patch adds the "%/built-in.o" rule so that each built-in.o in the
kernel tree could be the build target, which looks more consistent for the
kbuild system.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

Comments

Wei Yang Nov. 1, 2016, 3:53 p.m. UTC | #1
Hi, hope someone like this :-)

On Mon, Oct 24, 2016 at 12:45:11PM +0000, Wei Yang wrote:
>Current kbuild just supports building built-in.o in second directory level
>individually. There is no rule to build those built-in.o targets below
>third directory level.
>
>Even current kbuild system could achieve this with rule "%/", while this
>not only builds built-in targes but also lib target, extra target and
>module objects.
>
>This patch adds the "%/built-in.o" rule so that each built-in.o in the
>kernel tree could be the build target, which looks more consistent for the
>kbuild system.
>
>Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>---
> Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/Makefile b/Makefile
>index addb235..546998e 100644
>--- a/Makefile
>+++ b/Makefile
>@@ -1627,6 +1627,8 @@ endif
> 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
> %.symtypes: %.c prepare scripts FORCE
> 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>+%/built-in.o: prepare scripts
>+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
> 
> # Modules
> /: prepare scripts FORCE
>-- 
>2.5.0
Michal Marek Nov. 1, 2016, 4:27 p.m. UTC | #2
On 2016-10-24 14:45, Wei Yang wrote:

> diff --git a/Makefile b/Makefile
> index addb235..546998e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1627,6 +1627,8 @@ endif
>  	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>  %.symtypes: %.c prepare scripts FORCE
>  	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
> +%/built-in.o: prepare scripts
> +	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

This rule gets in the way of

   975  # The actual objects are generated when descending,
   976  # make sure no implicit rule kicks in
   977  $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;

Quickly looking at the Makefile, it may be fine, but it needs to be
confirmed. This also explains why the current behavior with */built-in.o
is inconsistent.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wei Yang Nov. 1, 2016, 10:59 p.m. UTC | #3
On Tue, Nov 01, 2016 at 05:27:34PM +0100, Michal Marek wrote:
>On 2016-10-24 14:45, Wei Yang wrote:
>
>> diff --git a/Makefile b/Makefile
>> index addb235..546998e 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1627,6 +1627,8 @@ endif
>>  	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>>  %.symtypes: %.c prepare scripts FORCE
>>  	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>> +%/built-in.o: prepare scripts
>> +	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>
>This rule gets in the way of
>
>   975  # The actual objects are generated when descending,
>   976  # make sure no implicit rule kicks in
>   977  $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
>

Yes, second level built-in.o is built because of this rule, while for deeper
level built-in.o we don't have a rule now. This patch is trying to add a rule
for those deeper level built-in.o.

>Quickly looking at the Makefile, it may be fine, but it needs to be
>confirmed. This also explains why the current behavior with */built-in.o
>is inconsistent.
>

Agree with you. 

One of my concern is whether it is necessary to add "FORCE" to the prerequest.
I have tried on my machine, it works fine without "FORCE", while maybe it
won't work fine with some version of "make".

This is what I want to confirm. Any other potential issue, just let me know.

Thanks for your comment :-)

>Michal
diff mbox

Patch

diff --git a/Makefile b/Makefile
index addb235..546998e 100644
--- a/Makefile
+++ b/Makefile
@@ -1627,6 +1627,8 @@  endif
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.symtypes: %.c prepare scripts FORCE
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+%/built-in.o: prepare scripts
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 
 # Modules
 /: prepare scripts FORCE