2016-10-24 12:45:38

by Wei Yang

[permalink] [raw]
Subject: [PATCH] kbuild: add %/built-in.o target in top Makefile

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 <[email protected]>
---
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


2016-11-01 15:53:39

by Wei Yang

[permalink] [raw]
Subject: Re: [PATCH] kbuild: add %/built-in.o target in top Makefile

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 <[email protected]>
>---
> 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

--
Wei Yang
Help you, Help me

2016-11-01 16:27:38

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild: add %/built-in.o target in top Makefile

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

2016-11-01 22:59:10

by Wei Yang

[permalink] [raw]
Subject: Re: [PATCH] kbuild: add %/built-in.o target in top Makefile

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

--
Wei Yang
Help you, Help me

2016-11-06 22:34:03

by Wei Yang

[permalink] [raw]
Subject: [PATCH V2] kbuild: add %/built-in.o target in top Makefile

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 <[email protected]>

---
v2
. add FORCE in prerequest

---
Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index f97f786..9c65498 100644
--- a/Makefile
+++ b/Makefile
@@ -1638,6 +1638,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 FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

# Modules
/: prepare scripts FORCE
--
2.5.0

2016-11-28 22:06:40

by Wei Yang

[permalink] [raw]
Subject: Re: [PATCH V2] kbuild: add %/built-in.o target in top Makefile

Hi ~

On Sun, Nov 06, 2016 at 10:18:32PM +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 <[email protected]>
>
>---
>v2
> . add FORCE in prerequest
>
>---
> Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/Makefile b/Makefile
>index f97f786..9c65498 100644
>--- a/Makefile
>+++ b/Makefile
>@@ -1638,6 +1638,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 FORCE
>+ $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
>
> # Modules
> /: prepare scripts FORCE
>--
>2.5.0

--
Wei Yang
Help you, Help me