Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 451577f3 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'kbuild-fixes-v5.3-3' of...

Merge tag 'kbuild-fixes-v5.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - revive single target %.ko

 - do not create built-in.a where it is unneeded

 - do not create modules.order where it is unneeded

 - show a warning if subdir-y/m is used to visit a module Makefile

* tag 'kbuild-fixes-v5.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: show hint if subdir-y/m is used to visit module Makefile
  kbuild: generate modules.order only in directories visited by obj-y/m
  kbuild: fix false-positive need-builtin calculation
  kbuild: revive single target %.ko
parents 7f20fd23 c07d8d47
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1003,6 +1003,8 @@ endif

PHONY += prepare0

export MODORDER := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order

ifeq ($(KBUILD_EXTMOD),)
core-y		+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/

@@ -1772,13 +1774,22 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
	$(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.symtypes: prepare FORCE
	$(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
ifeq ($(KBUILD_EXTMOD),)
# For the single build of an in-tree module, use a temporary file to avoid
# the situation of modules_install installing an invalid modules.order.
%.ko: MODORDER := .modules.tmp
endif
%.ko: prepare FORCE
	$(Q)$(MAKE) $(build)=$(build-dir) $(build-target:.ko=.mod)
	$(Q)echo $(build-target) > $(MODORDER)
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost

# Modules
PHONY += /
/: ./

%/: prepare FORCE
	$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
	$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1

# FIXME Should go into a make.lib or something
# ===========================================================================
+10 −1
Original line number Diff line number Diff line
@@ -52,6 +52,13 @@ ifndef obj
$(warning kbuild: Makefile.build is included improperly)
endif

ifeq ($(MAKECMDGOALS)$(need-modorder),)
ifneq ($(obj-m),)
$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.)
$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.)
endif
endif

# ===========================================================================

ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
@@ -487,7 +494,9 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \

PHONY += $(subdir-ym)
$(subdir-ym):
	$(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
	$(Q)$(MAKE) $(build)=$@ \
	need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),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 −4
Original line number Diff line number Diff line
@@ -85,10 +85,8 @@ endif

include scripts/Makefile.lib

modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order

# find all modules listed in modules.order
modules := $(sort $(shell cat $(modorder)))
modules := $(sort $(shell cat $(MODORDER)))

# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
@@ -98,7 +96,7 @@ MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)

# We can go over command line length here, so be careful.
quiet_cmd_modpost = MODPOST $(words $(modules)) modules
      cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST)
      cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)

PHONY += modules-modpost
modules-modpost: