diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-11-07 11:31:46 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-11-17 21:38:58 -0500 |
commit | f7adc3124da019878186f1ebe98a13a1af041afd (patch) | |
tree | 5519de53ba24c13fd6591efb49b861756178238c | |
parent | 16f8259ca77d04f95e5ca90be1b1894ed45816c0 (diff) |
kbuild: create built-in.o automatically if parent directory wants it
"obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory
and link built-in.o from that directory. This means foo/Makefile is
responsible for creating built-in.o even if there is no object to
link (in this case, built-in.o is an empty archive).
We have had several fixups like commit 4b024242e8a4 ("kbuild: Fix
linking error built-in.o no such file or directory"), then ended up
with a complex condition as follows:
ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
builtin-target := $(obj)/built-in.o
endif
We still have more cases not covered by the above, so we need to add
obj- := dummy.o
in several places just for creating empty built-in.o.
A key point is, the parent Makefile knows whether built-in.o is needed
or not. If a subdirectory needs to create built-in.o, its parent can
tell the fact when descending.
If non-empty $(need-builtin) flag is passed from the parent, built-in.o
should be created. $(obj-y) should be still checked to support the
single target "%/". All of ugly tricks will go away.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | scripts/Makefile.build | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -1009,7 +1009,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; | |||
1009 | 1009 | ||
1010 | PHONY += $(vmlinux-dirs) | 1010 | PHONY += $(vmlinux-dirs) |
1011 | $(vmlinux-dirs): prepare scripts | 1011 | $(vmlinux-dirs): prepare scripts |
1012 | $(Q)$(MAKE) $(build)=$@ | 1012 | $(Q)$(MAKE) $(build)=$@ need-builtin=1 |
1013 | 1013 | ||
1014 | define filechk_kernel.release | 1014 | define filechk_kernel.release |
1015 | echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" | 1015 | echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f171225383cc..fc7f312bc0a7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -76,7 +76,7 @@ lib-target := $(obj)/lib.a | |||
76 | obj-y += $(obj)/lib-ksyms.o | 76 | obj-y += $(obj)/lib-ksyms.o |
77 | endif | 77 | endif |
78 | 78 | ||
79 | ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) | 79 | ifneq ($(strip $(obj-y) $(need-builtin)),) |
80 | builtin-target := $(obj)/built-in.o | 80 | builtin-target := $(obj)/built-in.o |
81 | endif | 81 | endif |
82 | 82 | ||
@@ -561,7 +561,7 @@ targets := $(filter-out $(PHONY), $(targets)) | |||
561 | 561 | ||
562 | PHONY += $(subdir-ym) | 562 | PHONY += $(subdir-ym) |
563 | $(subdir-ym): | 563 | $(subdir-ym): |
564 | $(Q)$(MAKE) $(build)=$@ | 564 | $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1) |
565 | 565 | ||
566 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. | 566 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. |
567 | # --------------------------------------------------------------------------- | 567 | # --------------------------------------------------------------------------- |