Skip to contentSkip to conversation

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

PATCH Superseded Wei Yang 2 participants 7 messages Oct 24, 2016 – Feb 22, 2017 Kbuild

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 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.

---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)
Makefile +2 -0
index addb235..546998e 100644
@@ -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
Signature · 1 line
2.5.0
author
#1 lore raw

Hi, hope someone like this :-)

Quoted 32 lines · Wei Yang

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.

---
Makefile | 2 ++

1 file changed, 2 insertions(+)
Makefile +0 -0
index addb235..546998e 100644
@@ -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

Makefile +1 -0
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

# Modules
/: prepare scripts FORCE

Signature · 1 line
2.5.0
Signature · 2 lines
Wei Yang
Help you, Help me
#2 lore raw
In reply to Wei Yang

Makefile endif · line 1631

Quoted 10 lines · Wei Yang
Makefile +2 -0
index addb235..546998e 100644
@@ -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

author
#3 lore raw
Quoted 15 lines · Michal Marek

Makefile endif · line 1631

Quoted 10 lines · Wei Yang
Makefile +2 -0
index addb235..546998e 100644
@@ -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

Quoted 4 lines
  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.

Quoted 4 lines

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

Quoted 1 line

Michal

Signature · 2 lines
Wei Yang
Help you, Help me
author
#4 lore raw

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

In reply to Wei Yang

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.

---
v2
. add FORCE in prerequest

---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)
Makefile +2 -0
index f97f786..9c65498 100644
@@ -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
Signature · 1 line
2.5.0
author
#5 lore raw

Hi ~

Quoted 37 lines · Wei Yang

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.

---
v2
. add FORCE in prerequest

---
Makefile | 2 ++

1 file changed, 2 insertions(+)
Makefile +0 -0
index f97f786..9c65498 100644
@@ -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

Makefile +1 -0
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

# Modules
/: prepare scripts FORCE

Signature · 1 line
2.5.0
Signature · 2 lines
Wei Yang
Help you, Help me
author
#6 lore raw
In reply to Wei Yang

Hi, haven't get any feedback for a looong time.

Someone would like this change ? :-)

Quoted 37 lines · Wei Yang

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.

---
v2
. add FORCE in prerequest

---
Makefile | 2 ++

1 file changed, 2 insertions(+)
Makefile +0 -0
index f97f786..9c65498 100644
@@ -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

Makefile +1 -0
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

# Modules
/: prepare scripts FORCE

Signature · 1 line
2.5.0
Signature · 2 lines
Wei Yang
Help you, Help me