* [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target
@ 2020-05-22 1:59 Masahiro Yamada
2020-05-22 1:59 ` [PATCH 2/5] kbuild: clear KBUILD_MODULES in top Makefile if CONFIG_MODULES=n Masahiro Yamada
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-22 1:59 UTC (permalink / raw)
To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel
I do not see a good reason to add ifdef here.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 3665b1a0bc8e..9af88f4cacb8 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -384,16 +384,14 @@ $(obj)/%/built-in.a: $(obj)/% ;
#
# Rule to compile a set of .o files into one .a file (without symbol table)
#
-ifdef builtin-target
quiet_cmd_ar_builtin = AR $@
cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
-$(builtin-target): $(real-obj-y) FORCE
+$(obj)/built-in.a: $(real-obj-y) FORCE
$(call if_changed,ar_builtin)
targets += $(builtin-target)
-endif # builtin-target
#
# Rule to create modules.order file
@@ -408,15 +406,11 @@ $(modorder-target): $(subdir-ym) FORCE
#
# Rule to compile a set of .o files into one .a file (with symbol table)
#
-ifdef lib-target
-
-$(lib-target): $(lib-y) FORCE
+$(obj)/lib.a: $(lib-y) FORCE
$(call if_changed,ar)
targets += $(lib-target)
-endif
-
# NOTE:
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
# module is turned into a multi object module, $^ will contain header file
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] kbuild: clear KBUILD_MODULES in top Makefile if CONFIG_MODULES=n
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
@ 2020-05-22 1:59 ` Masahiro Yamada
2020-05-22 2:00 ` [PATCH 3/5] kbuild: move subdir-obj-y to scripts/Makefile.build Masahiro Yamada
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-22 1:59 UTC (permalink / raw)
To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel
Do not try to build any module-related artifacts when CONFIG_MODULES
is disabled.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 4 ++++
scripts/Makefile.build | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 1f5bbfb31103..72eb55a36545 100644
--- a/Makefile
+++ b/Makefile
@@ -1724,6 +1724,10 @@ build-dirs := $(foreach d, $(build-dirs), \
endif
+ifndef CONFIG_MODULES
+KBUILD_MODULES :=
+endif
+
# Handle descending into subdirectories listed in $(build-dirs)
# Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 9af88f4cacb8..f46d25441804 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -77,7 +77,7 @@ ifdef need-builtin
builtin-target := $(obj)/built-in.a
endif
-ifeq ($(CONFIG_MODULES)$(need-modorder),y1)
+ifdef need-modorder
modorder-target := $(obj)/modules.order
endif
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] kbuild: move subdir-obj-y to scripts/Makefile.build
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
2020-05-22 1:59 ` [PATCH 2/5] kbuild: clear KBUILD_MODULES in top Makefile if CONFIG_MODULES=n Masahiro Yamada
@ 2020-05-22 2:00 ` Masahiro Yamada
2020-05-22 2:00 ` [PATCH 4/5] kbuild: rename subdir-obj-y to subdir-builtin Masahiro Yamada
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-22 2:00 UTC (permalink / raw)
To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel
Save $(addprefix ...) for subdir-obj-y.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 2 ++
scripts/Makefile.lib | 5 -----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f46d25441804..ee283efc1b45 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -69,6 +69,8 @@ endif
# ===========================================================================
+subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
+
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a
endif
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 52299d5dba28..a41a4bbd20e2 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -62,10 +62,6 @@ multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m
multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
multi-used := $(multi-used-y) $(multi-used-m)
-# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
-# tell kbuild to descend
-subdir-obj-y := $(filter %/built-in.a, $(obj-y))
-
# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -91,7 +87,6 @@ targets := $(addprefix $(obj)/,$(targets))
modorder := $(addprefix $(obj)/,$(modorder))
obj-m := $(addprefix $(obj)/,$(obj-m))
lib-y := $(addprefix $(obj)/,$(lib-y))
-subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] kbuild: rename subdir-obj-y to subdir-builtin
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
2020-05-22 1:59 ` [PATCH 2/5] kbuild: clear KBUILD_MODULES in top Makefile if CONFIG_MODULES=n Masahiro Yamada
2020-05-22 2:00 ` [PATCH 3/5] kbuild: move subdir-obj-y to scripts/Makefile.build Masahiro Yamada
@ 2020-05-22 2:00 ` Masahiro Yamada
2020-05-22 2:00 ` [PATCH 5/5] kbuild: make modules.order rule consistent with built-in.a Masahiro Yamada
2020-05-26 10:29 ` [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-22 2:00 UTC (permalink / raw)
To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel
I think subdir-builtin is clearer.
While I was here, I made its build rule explicit.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index ee283efc1b45..323264607b9f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -69,7 +69,8 @@ endif
# ===========================================================================
-subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
+# subdir-builtin may contain duplications. Use $(sort ...)
+subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a
@@ -356,7 +357,7 @@ endif
$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(call if_changed_rule,as_o_S)
-targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
+targets += $(filter-out $(subdir-builtin), $(real-obj-y)) $(real-obj-m) $(lib-y)
targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
# Linker scripts preprocessor (.lds.S -> .lds)
@@ -381,7 +382,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
# ---------------------------------------------------------------------------
# To build objects in subdirs, we need to descend into the directories
-$(obj)/%/built-in.a: $(obj)/% ;
+$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
#
# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -489,7 +490,7 @@ PHONY += $(subdir-ym)
$(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \
$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
- need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \
+ need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] kbuild: make modules.order rule consistent with built-in.a
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
` (2 preceding siblings ...)
2020-05-22 2:00 ` [PATCH 4/5] kbuild: rename subdir-obj-y to subdir-builtin Masahiro Yamada
@ 2020-05-22 2:00 ` Masahiro Yamada
2020-05-26 10:29 ` [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-22 2:00 UTC (permalink / raw)
To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel
built-in.a contains the built-in object paths from the current and sub
directories.
module.order collects the module paths from the current and sub
directories.
Make their build rules look more symmetrical.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 10 ++++++----
scripts/Makefile.lib | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 323264607b9f..ee9a817e19a3 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -69,8 +69,9 @@ endif
# ===========================================================================
-# subdir-builtin may contain duplications. Use $(sort ...)
+# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
+subdir-modorder := $(sort $(filter %/modules.order, $(modorder)))
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a
@@ -383,6 +384,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
# To build objects in subdirs, we need to descend into the directories
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
+$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
#
# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -401,9 +403,9 @@ targets += $(builtin-target)
#
# Create commands to either record .ko file or cat modules.order from
# a subdirectory
-$(modorder-target): $(subdir-ym) FORCE
+$(obj)/modules.order: $(subdir-modorder) FORCE
$(Q){ $(foreach m, $(modorder), \
- $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
+ $(if $(filter $^, $m), cat $m, echo $m);) :; } \
| $(AWK) '!x[$$0]++' - > $@
#
@@ -491,7 +493,7 @@ $(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \
$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
- need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
+ need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1)
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a41a4bbd20e2..0d931cc0df94 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -35,7 +35,9 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
# Determine modorder.
# Unfortunately, we don't have information about ordering between -y
# and -m subdirs. Just put -y's first.
+ifdef need-modorder
modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
+endif
# Handle objects in subdirs
# ---------------------------------------------------------------------------
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
` (3 preceding siblings ...)
2020-05-22 2:00 ` [PATCH 5/5] kbuild: make modules.order rule consistent with built-in.a Masahiro Yamada
@ 2020-05-26 10:29 ` Masahiro Yamada
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-05-26 10:29 UTC (permalink / raw)
To: Linux Kbuild mailing list; +Cc: Michal Marek, Linux Kernel Mailing List
On Fri, May 22, 2020 at 11:00 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> I do not see a good reason to add ifdef here.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Applied to linux-kbuild.
> scripts/Makefile.build | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 3665b1a0bc8e..9af88f4cacb8 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -384,16 +384,14 @@ $(obj)/%/built-in.a: $(obj)/% ;
> #
> # Rule to compile a set of .o files into one .a file (without symbol table)
> #
> -ifdef builtin-target
>
> quiet_cmd_ar_builtin = AR $@
> cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
>
> -$(builtin-target): $(real-obj-y) FORCE
> +$(obj)/built-in.a: $(real-obj-y) FORCE
> $(call if_changed,ar_builtin)
>
> targets += $(builtin-target)
> -endif # builtin-target
>
> #
> # Rule to create modules.order file
> @@ -408,15 +406,11 @@ $(modorder-target): $(subdir-ym) FORCE
> #
> # Rule to compile a set of .o files into one .a file (with symbol table)
> #
> -ifdef lib-target
> -
> -$(lib-target): $(lib-y) FORCE
> +$(obj)/lib.a: $(lib-y) FORCE
> $(call if_changed,ar)
>
> targets += $(lib-target)
>
> -endif
> -
> # NOTE:
> # Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
> # module is turned into a multi object module, $^ will contain header file
> --
> 2.25.1
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-05-26 10:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 1:59 [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
2020-05-22 1:59 ` [PATCH 2/5] kbuild: clear KBUILD_MODULES in top Makefile if CONFIG_MODULES=n Masahiro Yamada
2020-05-22 2:00 ` [PATCH 3/5] kbuild: move subdir-obj-y to scripts/Makefile.build Masahiro Yamada
2020-05-22 2:00 ` [PATCH 4/5] kbuild: rename subdir-obj-y to subdir-builtin Masahiro Yamada
2020-05-22 2:00 ` [PATCH 5/5] kbuild: make modules.order rule consistent with built-in.a Masahiro Yamada
2020-05-26 10:29 ` [PATCH 1/5] kbuild: remove ifdef builtin-target / lib-target Masahiro Yamada
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.