Commit 89a47dd1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull more Kbuild updates from Masahiro Yamada:

 - fix randconfig to generate a sane .config

 - rename hostprogs-y / always to hostprogs / always-y, which are more
   natual syntax.

 - optimize scripts/kallsyms

 - fix yes2modconfig and mod2yesconfig

 - make multiple directory targets ('make foo/ bar/') work

* tag 'kbuild-v5.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: make multiple directory targets work
  kconfig: Invalidate all symbols after changing to y or m.
  kallsyms: fix type of kallsyms_token_table[]
  scripts/kallsyms: change table to store (strcut sym_entry *)
  scripts/kallsyms: rename local variables in read_symbol()
  kbuild: rename hostprogs-y/always to hostprogs/always-y
  kbuild: fix the document to use extra-y for vmlinux.lds
  kconfig: fix broken dependency in randconfig-generated .config
parents 380a129e f566e1fb
Loading
Loading
Loading
Loading
+18 −35
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ This document describes the Linux kernel Makefiles.
	   --- 4.3 Using C++ for host programs
	   --- 4.4 Controlling compiler options for host programs
	   --- 4.5 When host programs are actually built
	   --- 4.6 Using hostprogs-$(CONFIG_FOO)

	=== 5 Kbuild clean infrastructure

@@ -595,11 +594,11 @@ compilation stage.
Two steps are required in order to use a host executable.

The first step is to tell kbuild that a host program exists. This is
done utilising the variable hostprogs-y.
done utilising the variable "hostprogs".

The second step is to add an explicit dependency to the executable.
This can be done in two ways. Either add the dependency in a rule,
or utilise the variable $(always).
or utilise the variable "always-y".
Both possibilities are described in the following.

4.1 Simple Host Program
@@ -612,7 +611,7 @@ Both possibilities are described in the following.

	Example::

		hostprogs-y := bin2hex
		hostprogs := bin2hex

	Kbuild assumes in the above example that bin2hex is made from a single
	c-source file named bin2hex.c located in the same directory as
@@ -630,7 +629,7 @@ Both possibilities are described in the following.
	Example::

		#scripts/lxdialog/Makefile
		hostprogs-y   := lxdialog
		hostprogs     := lxdialog
		lxdialog-objs := checklist.o lxdialog.o

	Objects with extension .o are compiled from the corresponding .c
@@ -650,7 +649,7 @@ Both possibilities are described in the following.
	Example::

		#scripts/kconfig/Makefile
		hostprogs-y   := qconf
		hostprogs     := qconf
		qconf-cxxobjs := qconf.o

	In the example above the executable is composed of the C++ file
@@ -662,7 +661,7 @@ Both possibilities are described in the following.
	Example::

		#scripts/kconfig/Makefile
		hostprogs-y   := qconf
		hostprogs     := qconf
		qconf-cxxobjs := qconf.o
		qconf-objs    := check.o

@@ -710,7 +709,7 @@ Both possibilities are described in the following.
	Example::

		#drivers/pci/Makefile
		hostprogs-y := gen-devlist
		hostprogs := gen-devlist
		$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
			( cd $(obj); ./gen-devlist ) < $<

@@ -718,47 +717,31 @@ Both possibilities are described in the following.
	$(obj)/gen-devlist is updated. Note that references to
	the host programs in special rules must be prefixed with $(obj).

	(2) Use $(always)
	(2) Use always-y

	When there is no suitable special rule, and the host program
	shall be built when a makefile is entered, the $(always)
	shall be built when a makefile is entered, the always-y
	variable shall be used.

	Example::

		#scripts/lxdialog/Makefile
		hostprogs-y   := lxdialog
		always        := $(hostprogs-y)
		hostprogs     := lxdialog
		always-y      := $(hostprogs)

	This will tell kbuild to build lxdialog even if not referenced in
	any rule.

4.6 Using hostprogs-$(CONFIG_FOO)
---------------------------------

	A typical pattern in a Kbuild file looks like this:

	Example::

		#scripts/Makefile
		hostprogs-$(CONFIG_KALLSYMS) += kallsyms

	Kbuild knows about both 'y' for built-in and 'm' for module.
	So if a config symbol evaluates to 'm', kbuild will still build
	the binary. In other words, Kbuild handles hostprogs-m exactly
	like hostprogs-y. But only hostprogs-y is recommended to be used
	when no CONFIG symbols are involved.

5 Kbuild clean infrastructure
=============================

"make clean" deletes most generated files in the obj tree where the kernel
is compiled. This includes generated files such as host programs.
Kbuild knows targets listed in $(hostprogs-y), $(hostprogs-m), $(always),
$(extra-y) and $(targets). They are all deleted during "make clean".
Files matching the patterns "*.[oas]", "*.ko", plus some additional files
generated by kbuild are deleted all over the kernel src tree when
"make clean" is executed.
Kbuild knows targets listed in $(hostprogs), $(always-y), $(always-m),
$(always-), $(extra-y), $(extra-) and $(targets). They are all deleted
during "make clean". Files matching the patterns "*.[oas]", "*.ko", plus
some additional files generated by kbuild are deleted all over the kernel
source tree when "make clean" is executed.

Additional files or directories can be specified in kbuild makefiles by use of
$(clean-files).
@@ -1269,12 +1252,12 @@ When kbuild executes, the following steps are followed (roughly):
	Example::

		#arch/x86/kernel/Makefile
		always := vmlinux.lds
		extra-y := vmlinux.lds

		#Makefile
		export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)

	The assignment to $(always) is used to tell kbuild to build the
	The assignment to extra-y is used to tell kbuild to build the
	target vmlinux.lds.
	The assignment to $(CPPFLAGS_vmlinux.lds) tells kbuild to use the
	specified options when building the target vmlinux.lds.
+4 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@

bounds-file := include/generated/bounds.h

always  := $(bounds-file)
always-y := $(bounds-file)
targets := kernel/bounds.s

$(bounds-file): kernel/bounds.s FORCE
@@ -28,7 +28,7 @@ $(timeconst-file): kernel/time/timeconst.bc FORCE

offsets-file := include/generated/asm-offsets.h

always  += $(offsets-file)
always-y += $(offsets-file)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s

arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
@@ -39,7 +39,7 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
#####
# Check for missing system calls

always += missing-syscalls
always-y += missing-syscalls

quiet_cmd_syscalls = CALL    $<
      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
@@ -50,7 +50,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
#####
# Check atomic headers are up-to-date

always += old-atomics
always-y += old-atomics

quiet_cmd_atomics = CALL    $<
      cmd_atomics = $(CONFIG_SHELL) $<
+1 −1
Original line number Diff line number Diff line
@@ -1679,7 +1679,7 @@ PHONY += descend $(build-dirs)
descend: $(build-dirs)
$(build-dirs): prepare
	$(Q)$(MAKE) $(build)=$@ \
	single-build=$(if $(filter-out $@/, $(single-no-ko)),1) \
	single-build=$(if $(filter-out $@/, $(filter $@/%, $(single-no-ko))),1) \
	need-builtin=1 need-modorder=1

clean-dirs := $(addprefix _clean_, $(clean-dirs))
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
# Copyright (C) 1994 by Linus Torvalds
#

hostprogs-y	:= tools/mkbb tools/objstrip
hostprogs	:= tools/mkbb tools/objstrip
targets		:= vmlinux.gz vmlinux \
		   vmlinux.nh tools/lxboot tools/bootlx tools/bootph \
		   tools/bootpzh bootloader bootpheader bootpzheader 
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
include $(srctree)/lib/vdso/Makefile

hostprogs-y := vdsomunge
hostprogs := vdsomunge

obj-vdso := vgettimeofday.o datapage.o note.o

Loading