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

 - do not generate unneeded top-level built-in.a

 - let git ignore O= directory entirely

 - optimize scripts/kallsyms slightly

 - exclude DWARF info from *.s regardless of config options

 - fix GCC toolchain search path for Clang to prepare ld.lld support

 - do not generate modules.order when CONFIG_MODULES is disabled

 - simplify single target rules and remove VPATH for external module
   build

 - allow to add optional flags to dpkg-buildpackage when building
   deb-pkg

 - move some compiler option tests from Makefile to Kconfig

 - various Makefile cleanups

* tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits)
  kbuild: remove scripts/basic/% build target
  kbuild: use -Werror=implicit-... instead of -Werror-implicit-...
  kbuild: clean up scripts/gcc-version.sh
  kbuild: remove cc-version macro
  kbuild: update comment block of scripts/clang-version.sh
  kbuild: remove commented-out INITRD_COMPRESS
  kbuild: move -gsplit-dwarf, -gdwarf-4 option tests to Kconfig
  kbuild: [bin]deb-pkg: add DPKG_FLAGS variable
  kbuild: move ".config not found!" message from Kconfig to Makefile
  kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing
  kbuild: simplify single target rules
  kbuild: remove empty rules for makefiles
  kbuild: make -r/-R effective in top Makefile for old Make versions
  kbuild: move tools_silent to a more relevant place
  kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
  kbuild: refactor cc-cross-prefix implementation
  kbuild: hardcode genksyms path and remove GENKSYMS variable
  scripts/gdb: refactor rules for symlink creation
  kbuild: create symlink to vmlinux-gdb.py in scripts_gdb target
  scripts/gdb: do not descend into scripts/gdb from scripts
  ...
parents 5af7f115 9250d20e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -15,7 +15,7 @@ DT_TMP_SCHEMA := processed-schema.yaml
extra-y += $(DT_TMP_SCHEMA)
extra-y += $(DT_TMP_SCHEMA)


quiet_cmd_mk_schema = SCHEMA  $@
quiet_cmd_mk_schema = SCHEMA  $@
      cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out FORCE, $^)
      cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)


DT_DOCS = $(shell \
DT_DOCS = $(shell \
	cd $(srctree)/$(src) && \
	cd $(srctree)/$(src) && \
+5 −10
Original line number Original line Diff line number Diff line
@@ -232,17 +232,12 @@ KBUILD_LDS
--------------------------------------------------
--------------------------------------------------
The linker script with full path. Assigned by the top-level Makefile.
The linker script with full path. Assigned by the top-level Makefile.


KBUILD_VMLINUX_INIT
KBUILD_VMLINUX_OBJS
--------------------------------------------------
--------------------------------------------------
All object files for the init (first) part of vmlinux.
All object files for vmlinux. They are linked to vmlinux in the same
Files specified with KBUILD_VMLINUX_INIT are linked first.
order as listed in KBUILD_VMLINUX_OBJS.

KBUILD_VMLINUX_MAIN
--------------------------------------------------
All object files for the main part of vmlinux.


KBUILD_VMLINUX_LIBS
KBUILD_VMLINUX_LIBS
--------------------------------------------------
--------------------------------------------------
All .a "lib" files for vmlinux.
All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together
together specify all the object files used to link vmlinux.
specify all the object files used to link vmlinux.
+2 −24
Original line number Original line Diff line number Diff line
@@ -154,13 +154,8 @@ more details, with real examples.


	Kbuild compiles all the $(obj-y) files.  It then calls
	Kbuild compiles all the $(obj-y) files.  It then calls
	"$(AR) rcSTP" to merge these files into one built-in.a file.
	"$(AR) rcSTP" to merge these files into one built-in.a file.
	This is a thin archive without a symbol table, which makes it
	This is a thin archive without a symbol table. It will be later
	unsuitable as a linker input.
	linked into vmlinux by scripts/link-vmlinux.sh

	The scripts/link-vmlinux.sh script later makes an aggregate
	built-in.a with "${AR} rcsTP", which creates the thin archive
	with a symbol table and an index, making it a valid input for
	the final vmlinux link passes.


	The order of files in $(obj-y) is significant.  Duplicates in
	The order of files in $(obj-y) is significant.  Duplicates in
	the lists are allowed: the first instance will be linked into
	the lists are allowed: the first instance will be linked into
@@ -504,23 +499,6 @@ more details, with real examples.
	In the above example, -Wno-unused-but-set-variable will be added to
	In the above example, -Wno-unused-but-set-variable will be added to
	KBUILD_CFLAGS only if gcc really accepts it.
	KBUILD_CFLAGS only if gcc really accepts it.


    cc-version
	cc-version returns a numerical version of the $(CC) compiler version.
	The format is <major><minor> where both are two digits. So for example
	gcc 3.41 would return 0341.
	cc-version is useful when a specific $(CC) version is faulty in one
	area, for example -mregparm=3 was broken in some gcc versions
	even though the option was accepted by gcc.

	Example:
		#arch/x86/Makefile
		cflags-y += $(shell \
		if [ $(cc-version) -ge 0300 ] ; then \
			echo "-mregparm=3"; fi ;)

	In the above example, -mregparm=3 is only used for gcc version greater
	than or equal to gcc 3.0.

    cc-ifversion
    cc-ifversion
	cc-ifversion tests the version of $(CC) and equals the fourth parameter
	cc-ifversion tests the version of $(CC) and equals the fourth parameter
	if version expression is true, or the fifth (if given) if the version
	if version expression is true, or the fifth (if given) if the version
+1 −1
Original line number Original line Diff line number Diff line
@@ -140,7 +140,7 @@ executed to make module versioning work.
		make -C $KDIR M=$PWD bar.lst
		make -C $KDIR M=$PWD bar.lst
		make -C $KDIR M=$PWD baz.o
		make -C $KDIR M=$PWD baz.o
		make -C $KDIR M=$PWD foo.ko
		make -C $KDIR M=$PWD foo.ko
		make -C $KDIR M=$PWD /
		make -C $KDIR M=$PWD ./




=== 3. Creating a Kbuild File for an External Module
=== 3. Creating a Kbuild File for an External Module
+5 −24
Original line number Original line Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
# SPDX-License-Identifier: GPL-2.0
#
#
# Kbuild for top-level directory of the kernel
# Kbuild for top-level directory of the kernel
# This file takes care of the following:
# 1) Generate bounds.h
# 2) Generate timeconst.h
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
# 4) Check for missing system calls
# 5) check atomics headers are up-to-date
# 6) Generate constants.py (may need bounds.h)


#####
#####
# 1) Generate bounds.h
# Generate bounds.h


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


@@ -21,7 +14,7 @@ $(bounds-file): kernel/bounds.s FORCE
	$(call filechk,offsets,__LINUX_BOUNDS_H__)
	$(call filechk,offsets,__LINUX_BOUNDS_H__)


#####
#####
# 2) Generate timeconst.h
# Generate timeconst.h


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


@@ -33,8 +26,7 @@ $(timeconst-file): kernel/time/timeconst.bc FORCE
	$(call filechk,gentimeconst)
	$(call filechk,gentimeconst)


#####
#####
# 3) Generate asm-offsets.h
# Generate asm-offsets.h
#


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


@@ -47,8 +39,7 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
	$(call filechk,offsets,__ASM_OFFSETS_H__)
	$(call filechk,offsets,__ASM_OFFSETS_H__)


#####
#####
# 4) Check for missing system calls
# Check for missing system calls
#


always += missing-syscalls
always += missing-syscalls
targets += missing-syscalls
targets += missing-syscalls
@@ -60,8 +51,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
	$(call cmd,syscalls)
	$(call cmd,syscalls)


#####
#####
# 5) Check atomic headers are up-to-date
# Check atomic headers are up-to-date
#


always += old-atomics
always += old-atomics
targets += old-atomics
targets += old-atomics
@@ -72,14 +62,5 @@ quiet_cmd_atomics = CALL $<
old-atomics: scripts/atomic/check-atomics.sh FORCE
old-atomics: scripts/atomic/check-atomics.sh FORCE
	$(call cmd,atomics)
	$(call cmd,atomics)


#####
# 6) Generate constants for Python GDB integration
#

extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py

build_constants_py: $(timeconst-file) $(bounds-file)
	@$(MAKE) $(build)=scripts/gdb/linux $@

# Keep these three files during make clean
# Keep these three files during make clean
no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
Loading