mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 17:23:36 +00:00
kbuild: list sub-directories in ./Kbuild
Use the ordinary obj-y syntax to list subdirectories.
Note1:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y
was linked before drivers-y when CONFIG_MODULES=y, otherwise after
drivers-y. This was a bug of commit 7273ad2b08
("kbuild: link lib-y
objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a
big deal after all. Now, all objects listed in lib-y are linked last,
irrespective of CONFIG_MODULES.
Note2:
Finally, the single target build in arch/*/lib/ works correctly. There was
a bug report about this. [1]
$ make ARCH=arm arch/arm/lib/findbit.o
CALL scripts/checksyscalls.sh
AS arch/arm/lib/findbit.o
[1]: https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%2FU6@shell.armlinux.org.uk/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
This commit is contained in:
parent
88b61e3bff
commit
5750121ae7
24
Kbuild
24
Kbuild
@ -72,3 +72,27 @@ $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
|
|||||||
PHONY += prepare
|
PHONY += prepare
|
||||||
prepare: $(offsets-file) missing-syscalls $(atomic-checks)
|
prepare: $(offsets-file) missing-syscalls $(atomic-checks)
|
||||||
@:
|
@:
|
||||||
|
|
||||||
|
# Ordinary directory descending
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
obj-y += init/
|
||||||
|
obj-y += usr/
|
||||||
|
obj-y += arch/$(SRCARCH)/
|
||||||
|
obj-y += $(ARCH_CORE)
|
||||||
|
obj-y += kernel/
|
||||||
|
obj-y += certs/
|
||||||
|
obj-y += mm/
|
||||||
|
obj-y += fs/
|
||||||
|
obj-y += ipc/
|
||||||
|
obj-y += security/
|
||||||
|
obj-y += crypto/
|
||||||
|
obj-$(CONFIG_BLOCK) += block/
|
||||||
|
obj-$(CONFIG_IO_URING) += io_uring/
|
||||||
|
obj-y += $(ARCH_LIB)
|
||||||
|
obj-y += drivers/
|
||||||
|
obj-y += sound/
|
||||||
|
obj-$(CONFIG_SAMPLES) += samples/
|
||||||
|
obj-$(CONFIG_NET) += net/
|
||||||
|
obj-y += virt/
|
||||||
|
obj-y += $(ARCH_DRIVERS)
|
||||||
|
63
Makefile
63
Makefile
@ -676,11 +676,8 @@ endif
|
|||||||
|
|
||||||
ifeq ($(KBUILD_EXTMOD),)
|
ifeq ($(KBUILD_EXTMOD),)
|
||||||
# Objects we will link into vmlinux / subdirs we need to visit
|
# Objects we will link into vmlinux / subdirs we need to visit
|
||||||
core-y := init/ usr/ arch/$(SRCARCH)/
|
core-y :=
|
||||||
drivers-y := drivers/ sound/
|
drivers-y :=
|
||||||
drivers-$(CONFIG_SAMPLES) += samples/
|
|
||||||
drivers-$(CONFIG_NET) += net/
|
|
||||||
drivers-y += virt/
|
|
||||||
libs-y := lib/
|
libs-y := lib/
|
||||||
endif # KBUILD_EXTMOD
|
endif # KBUILD_EXTMOD
|
||||||
|
|
||||||
@ -1099,31 +1096,24 @@ export MODORDER := $(extmod_prefix)modules.order
|
|||||||
export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
|
export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
|
||||||
|
|
||||||
ifeq ($(KBUILD_EXTMOD),)
|
ifeq ($(KBUILD_EXTMOD),)
|
||||||
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/
|
|
||||||
core-$(CONFIG_BLOCK) += block/
|
|
||||||
core-$(CONFIG_IO_URING) += io_uring/
|
|
||||||
|
|
||||||
vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
|
build-dir := .
|
||||||
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
|
clean-dirs := $(sort . Documentation \
|
||||||
$(libs-y) $(libs-m)))
|
|
||||||
|
|
||||||
build-dirs := $(vmlinux-dirs)
|
|
||||||
clean-dirs := $(sort $(vmlinux-dirs) Documentation . \
|
|
||||||
$(patsubst %/,%,$(filter %/, $(core-) \
|
$(patsubst %/,%,$(filter %/, $(core-) \
|
||||||
$(drivers-) $(libs-))))
|
$(drivers-) $(libs-))))
|
||||||
|
|
||||||
subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
|
export ARCH_CORE := $(core-y)
|
||||||
|
export ARCH_LIB := $(filter %/, $(libs-y))
|
||||||
|
export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
|
||||||
# Externally visible symbols (used by link-vmlinux.sh)
|
# Externally visible symbols (used by link-vmlinux.sh)
|
||||||
KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
|
|
||||||
KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
|
KBUILD_VMLINUX_OBJS := $(head-y) ./built-in.a
|
||||||
ifdef CONFIG_MODULES
|
ifdef CONFIG_MODULES
|
||||||
KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
|
KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
|
||||||
KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
|
KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
|
||||||
else
|
else
|
||||||
KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
|
KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
|
||||||
endif
|
endif
|
||||||
KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
|
|
||||||
|
|
||||||
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
|
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
|
||||||
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
|
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
|
||||||
@ -1138,7 +1128,7 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS
|
|||||||
# (this can be evaluated only once include/config/auto.conf has been included)
|
# (this can be evaluated only once include/config/auto.conf has been included)
|
||||||
KBUILD_MODULES := 1
|
KBUILD_MODULES := 1
|
||||||
|
|
||||||
autoksyms_recursive: descend modules.order
|
autoksyms_recursive: $(build-dir) modules.order
|
||||||
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
|
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
|
||||||
"$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
|
"$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
|
||||||
endif
|
endif
|
||||||
@ -1166,7 +1156,7 @@ targets := vmlinux
|
|||||||
|
|
||||||
# The actual objects are generated when descending,
|
# The actual objects are generated when descending,
|
||||||
# make sure no implicit rule kicks in
|
# make sure no implicit rule kicks in
|
||||||
$(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
|
$(sort $(vmlinux-deps)): . ;
|
||||||
|
|
||||||
filechk_kernel.release = \
|
filechk_kernel.release = \
|
||||||
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
|
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
|
||||||
@ -1437,13 +1427,6 @@ endif
|
|||||||
|
|
||||||
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
|
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
|
||||||
|
|
||||||
cmd_modules_order = cat $(real-prereqs) > $@
|
|
||||||
|
|
||||||
modules.order: $(subdir-modorder) FORCE
|
|
||||||
$(call if_changed,modules_order)
|
|
||||||
|
|
||||||
targets += modules.order
|
|
||||||
|
|
||||||
# Target to prepare building external modules
|
# Target to prepare building external modules
|
||||||
modules_prepare: prepare
|
modules_prepare: prepare
|
||||||
$(Q)$(MAKE) $(build)=scripts scripts/module.lds
|
$(Q)$(MAKE) $(build)=scripts scripts/module.lds
|
||||||
@ -1714,9 +1697,7 @@ else # KBUILD_EXTMOD
|
|||||||
KBUILD_BUILTIN :=
|
KBUILD_BUILTIN :=
|
||||||
KBUILD_MODULES := 1
|
KBUILD_MODULES := 1
|
||||||
|
|
||||||
build-dirs := $(KBUILD_EXTMOD)
|
build-dir := $(KBUILD_EXTMOD)
|
||||||
$(MODORDER): descend
|
|
||||||
@:
|
|
||||||
|
|
||||||
compile_commands.json: $(extmod_prefix)compile_commands.json
|
compile_commands.json: $(extmod_prefix)compile_commands.json
|
||||||
PHONY += compile_commands.json
|
PHONY += compile_commands.json
|
||||||
@ -1754,6 +1735,9 @@ PHONY += modules modules_install modules_prepare
|
|||||||
|
|
||||||
ifdef CONFIG_MODULES
|
ifdef CONFIG_MODULES
|
||||||
|
|
||||||
|
$(MODORDER): $(build-dir)
|
||||||
|
@:
|
||||||
|
|
||||||
modules: modules_check
|
modules: modules_check
|
||||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
|
||||||
|
|
||||||
@ -1807,7 +1791,7 @@ single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
|
|||||||
|
|
||||||
$(single-ko): single_modpost
|
$(single-ko): single_modpost
|
||||||
@:
|
@:
|
||||||
$(single-no-ko): descend
|
$(single-no-ko): $(build-dir)
|
||||||
@:
|
@:
|
||||||
|
|
||||||
# Remove MODORDER when done because it is not the real one.
|
# Remove MODORDER when done because it is not the real one.
|
||||||
@ -1817,24 +1801,17 @@ single_modpost: $(single-no-ko) modules_prepare
|
|||||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
|
||||||
$(Q)rm -f $(MODORDER)
|
$(Q)rm -f $(MODORDER)
|
||||||
|
|
||||||
single-goals := $(addprefix $(extmod_prefix), $(single-no-ko))
|
single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
|
||||||
|
|
||||||
# trim unrelated directories
|
|
||||||
build-dirs := $(foreach d, $(build-dirs), \
|
|
||||||
$(if $(filter $d/%, $(single-goals)), $d))
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Handle descending into subdirectories listed in $(build-dirs)
|
|
||||||
# Preset locale variables to speed up the build process. Limit locale
|
# Preset locale variables to speed up the build process. Limit locale
|
||||||
# tweaks to this spot to avoid wrong language settings when running
|
# tweaks to this spot to avoid wrong language settings when running
|
||||||
# make menuconfig etc.
|
# make menuconfig etc.
|
||||||
# Error messages still appears in the original language
|
# Error messages still appears in the original language
|
||||||
PHONY += descend $(build-dirs)
|
PHONY += $(build-dir)
|
||||||
descend: $(build-dirs)
|
$(build-dir): prepare
|
||||||
$(build-dirs): prepare
|
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
|
||||||
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 \
|
|
||||||
$(filter $@/%, $(single-goals))
|
|
||||||
|
|
||||||
clean-dirs := $(addprefix _clean_, $(clean-dirs))
|
clean-dirs := $(addprefix _clean_, $(clean-dirs))
|
||||||
PHONY += $(clean-dirs) clean
|
PHONY += $(clean-dirs) clean
|
||||||
|
@ -89,6 +89,7 @@ always-y += $(dtb-y)
|
|||||||
|
|
||||||
# Add subdir path
|
# Add subdir path
|
||||||
|
|
||||||
|
ifneq ($(obj),.)
|
||||||
extra-y := $(addprefix $(obj)/,$(extra-y))
|
extra-y := $(addprefix $(obj)/,$(extra-y))
|
||||||
always-y := $(addprefix $(obj)/,$(always-y))
|
always-y := $(addprefix $(obj)/,$(always-y))
|
||||||
targets := $(addprefix $(obj)/,$(targets))
|
targets := $(addprefix $(obj)/,$(targets))
|
||||||
@ -100,6 +101,7 @@ multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
|
|||||||
multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
|
multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
|
||||||
real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
|
real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
|
||||||
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
|
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
|
||||||
|
endif
|
||||||
|
|
||||||
# Finds the multi-part object the current object will be linked into.
|
# Finds the multi-part object the current object will be linked into.
|
||||||
# If the object belongs to two or more multi-part objects, list them all.
|
# If the object belongs to two or more multi-part objects, list them all.
|
||||||
|
Loading…
Reference in New Issue
Block a user