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

 - remove headers_{install,check}_all targets

 - remove unreasonable 'depends on !UML' from CONFIG_SAMPLES

 - re-implement 'make headers_install' more cleanly

 - add new header-test-y syntax to compile-test headers

 - compile-test exported headers to ensure they are compilable in
   user-space

 - compile-test headers under include/ to ensure they are self-contained

 - remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value
   flags

 - add -Werror=unknown-warning-option for Clang

 - add 128-bit built-in types support to genksyms

 - fix missed rebuild of modules.builtin

 - propagate 'No space left on device' error in fixdep to Make

 - allow Clang to use its integrated assembler

 - improve some coccinelle scripts

 - add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
   path for $(srctree).

 - do not ignore errors when compression utility is missing

 - misc cleanups

* tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits)
  kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix
  kbuild: Inform user to pass ARCH= for make mrproper
  kbuild: fix compression errors getting ignored
  kbuild: add a flag to force absolute path for srctree
  kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
  kbuild: remove src and obj from the top Makefile
  scripts/tags.sh: remove unused environment variables from comments
  scripts/tags.sh: drop SUBARCH support for ARM
  kbuild: compile-test kernel headers to ensure they are self-contained
  kheaders: include only headers into kheaders_data.tar.xz
  kheaders: remove meaningless -R option of 'ls'
  kbuild: support header-test-pattern-y
  kbuild: do not create wrappers for header-test-y
  kbuild: compile-test exported headers to ensure they are self-contained
  init/Kconfig: add CONFIG_CC_CAN_LINK
  kallsyms: exclude kasan local symbols on s390
  kbuild: add more hints about SUBDIRS replacement
  coccinelle: api/stream_open: treat all wait_.*() calls as blocking
  coccinelle: put_device: Add a cast to an expression for an assignment
  coccinelle: put_device: Adjust a message construction
  ...
parents 5f26f114 d4a74bbf
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -40,12 +40,5 @@ INSTALL_HDR_PATH indicates where to install the headers. It defaults to
An 'include' directory is automatically created inside INSTALL_HDR_PATH and
headers are installed in 'INSTALL_HDR_PATH/include'.

The command "make headers_install_all" exports headers for all architectures
simultaneously.  (This is mostly of interest to distribution maintainers,
who create an architecture-independent tarball from the resulting include
directory.)  You also can use HDR_ARCH_LIST to specify list of architectures.
Remember to provide the appropriate linux/asm directory via "mv" or "ln -s"
before building a C library with headers exported this way.

The kernel header export infrastructure is maintained by David Woodhouse
<dwmw2@infradead.org>.
+9 −0
Original line number Diff line number Diff line
@@ -200,6 +200,15 @@ The output directory is often set using "O=..." on the commandline.

The value can be overridden in which case the default value is ignored.

KBUILD_ABS_SRCTREE
--------------------------------------------------
Kbuild uses a relative path to point to the tree when possible. For instance,
when building in the source tree, the source tree path is '.'

Setting this flag requests Kbuild to use absolute path to the source tree.
There are some useful cases to do so, like when generating tag files with
absolute path entries etc.

KBUILD_SIGN_PIN
---------------
This variable allows a passphrase or PIN to be passed to the sign-file
+17 −5
Original line number Diff line number Diff line
@@ -999,11 +999,7 @@ When kbuild executes, the following steps are followed (roughly):
------------------------------------

	The archheaders: rule is used to generate header files that
	may be installed into user space by "make header_install" or
	"make headers_install_all".  In order to support
	"make headers_install_all", this target has to be able to run
	on an unconfigured tree, or a tree configured for another
	architecture.
	may be installed into user space by "make header_install".

	It is run before "make archprepare" when run on the
	architecture itself.
@@ -1140,6 +1136,22 @@ When kbuild executes, the following steps are followed (roughly):
	In this example, extra-y is used to list object files that
	shall be built, but shall not be linked as part of built-in.a.

    header-test-y

	header-test-y specifies headers (*.h) in the current directory that
	should be compile tested to ensure they are self-contained,
	i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
	this builds them as part of extra-y.

    header-test-pattern-y

	This works as a weaker version of header-test-y, and accepts wildcard
	patterns. The typical usage is:

		  header-test-pattern-y += *.h

	This specifies all the files that matches to '*.h' in the current
	directory, but the files in 'header-test-' are excluded.

6.7 Commands useful for building a boot image
---------------------------------------------
+66 −51
Original line number Diff line number Diff line
@@ -212,6 +212,13 @@ endif
ifdef SUBDIRS
  $(warning ================= WARNING ================)
  $(warning 'SUBDIRS' will be removed after Linux 5.3)
  $(warning )
  $(warning If you are building an individual subdirectory)
  $(warning in the kernel tree, you can do like this:)
  $(warning $$ make path/to/dir/you/want/to/build/)
  $(warning (Do not forget the trailing slash))
  $(warning )
  $(warning If you are building an external module,)
  $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
  $(warning ==========================================)
  KBUILD_EXTMOD ?= $(SUBDIRS)
@@ -221,9 +228,12 @@ ifeq ("$(origin M)", "command line")
  KBUILD_EXTMOD := $(M)
endif

export KBUILD_CHECKSRC KBUILD_EXTMOD

ifeq ($(abs_srctree),$(abs_objtree))
        # building in the source tree
        srctree := .
	building_out_of_srctree :=
else
        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
                # building in a subdirectory of the source tree
@@ -231,22 +241,17 @@ else
        else
                srctree := $(abs_srctree)
        endif

	# TODO:
	# KBUILD_SRC is only used to distinguish in-tree/out-of-tree build.
	# Replace it with $(srctree) or something.
	KBUILD_SRC := $(abs_srctree)
	building_out_of_srctree := 1
endif

export KBUILD_CHECKSRC KBUILD_EXTMOD KBUILD_SRC
ifneq ($(KBUILD_ABS_SRCTREE),)
srctree := $(abs_srctree)
endif

objtree		:= .
src		:= $(srctree)
obj		:= $(objtree)

VPATH		:= $(srctree)

export srctree objtree VPATH
export building_out_of_srctree srctree objtree VPATH

# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -262,7 +267,7 @@ old_version_h := include/linux/version.h
clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
			 cscope gtags TAGS tags help% %docs check% coccicheck \
			 $(version_h) headers_% archheaders archscripts \
			 $(version_h) headers headers_% archheaders archscripts \
			 %asm-generic kernelversion %src-pkg
no-sync-config-targets := $(no-dot-config-targets) install %install \
			   kernelrelease
@@ -449,7 +454,7 @@ USERINCLUDE := \
LINUXINCLUDE    := \
		-I$(srctree)/arch/$(SRCARCH)/include \
		-I$(objtree)/arch/$(SRCARCH)/include/generated \
		$(if $(filter .,$(srctree)),,-I$(srctree)/include) \
		$(if $(building_out_of_srctree),-I$(srctree)/include) \
		-I$(objtree)/include \
		$(USERINCLUDE)

@@ -510,7 +515,7 @@ PHONY += outputmakefile
# At the same time when output Makefile generated, generate .gitignore to
# ignore whole output directory
outputmakefile:
ifneq ($(srctree),.)
ifdef building_out_of_srctree
	$(Q)ln -fsn $(srctree) source
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
	$(Q)test -e .gitignore || \
@@ -527,7 +532,10 @@ endif
ifneq ($(GCC_TOOLCHAIN),)
CLANG_FLAGS	+= --gcc-toolchain=$(GCC_TOOLCHAIN)
endif
ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),)
CLANG_FLAGS	+= -no-integrated-as
endif
CLANG_FLAGS	+= -Werror=unknown-warning-option
KBUILD_CFLAGS	+= $(CLANG_FLAGS)
KBUILD_AFLAGS	+= $(CLANG_FLAGS)
export CLANG_FLAGS
@@ -608,6 +616,7 @@ ifeq ($(KBUILD_EXTMOD),)
init-y		:= init/
drivers-y	:= drivers/ sound/
drivers-$(CONFIG_SAMPLES) += samples/
drivers-$(CONFIG_KERNEL_HEADER_TEST) += include/
net-y		:= net/
libs-y		:= lib/
core-y		:= usr/
@@ -1053,9 +1062,6 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE

targets := vmlinux

# Some samples need headers_install.
samples: headers_install

# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
@@ -1096,12 +1102,12 @@ PHONY += prepare archprepare prepare1 prepare3
# and if so do:
# 1) Check that make has not been executed in the kernel src $(srctree)
prepare3: include/config/kernel.release
ifneq ($(srctree),.)
ifdef building_out_of_srctree
	@$(kecho) '  Using $(srctree) as source for kernel'
	$(Q)if [ -f $(srctree)/.config -o \
		 -d $(srctree)/include/config -o \
		 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
		echo >&2 "  $(srctree) is not clean, please run 'make mrproper'"; \
		echo >&2 "  $(srctree) is not clean, please run 'make ARCH=$(ARCH) mrproper'"; \
		echo >&2 "  in the '$(srctree)' directory.";\
		/bin/false; \
	fi;
@@ -1181,39 +1187,44 @@ headerdep:
#Default location for installed headers
export INSTALL_HDR_PATH = $(objtree)/usr

# If we do an all arch process set dst to include/arch-$(SRCARCH)
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/arch-$(SRCARCH), dst=include)
quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
      cmd_headers_install = \
	mkdir -p $(INSTALL_HDR_PATH); \
	rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
	usr/include $(INSTALL_HDR_PATH)

PHONY += archheaders archscripts
PHONY += headers_install
headers_install: headers
	$(call cmd,headers_install)

PHONY += __headers
__headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts
	$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += archheaders archscripts

PHONY += headers_install_all
headers_install_all:
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj

PHONY += headers_install
headers_install: __headers
PHONY += headers
headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
	$(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
	  $(error Headers not exportable for the $(SRCARCH) architecture))
	$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include
	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst)

PHONY += headers_check_all
headers_check_all: headers_install_all
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
	$(Q)$(MAKE) $(hdr-inst)=include/uapi
	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi

PHONY += headers_check
headers_check: headers_install
	$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1
headers_check: headers
	$(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi HDRCHECK=1

ifdef CONFIG_HEADERS_INSTALL
prepare: headers
endif

ifdef CONFIG_HEADERS_CHECK
all: headers_check
endif

PHONY += scripts_unifdef
scripts_unifdef: scripts_basic
	$(Q)$(MAKE) $(build)=scripts scripts/unifdef

# ---------------------------------------------------------------------------
# Kernel selftest

@@ -1283,18 +1294,24 @@ all: modules
# using awk while concatenating to the final file.

PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
	$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
	@$(kecho) '  Building modules, stage 2.';
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh

modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
	$(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
modules.order: $(vmlinux-dirs)
	$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@

modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs))

%/modules.builtin: include/config/auto.conf include/config/tristate.conf
	$(Q)$(MAKE) $(modbuiltin)=$*
modules.builtin: $(modbuiltin-dirs)
	$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@

PHONY += $(modbuiltin-dirs)
# tristate.conf is not included from this Makefile. Add it as a prerequisite
# here to make it self-healing in case somebody accidentally removes it.
$(modbuiltin-dirs): include/config/tristate.conf
	$(Q)$(MAKE) $(modbuiltin)=$(patsubst _modbuiltin_%,%,$@)

# Target to prepare building external modules
PHONY += modules_prepare
@@ -1360,7 +1377,7 @@ CLEAN_DIRS += $(MODVERDIR) include/ksym
CLEAN_FILES += modules.builtin.modinfo

# Directories & files removed with 'make mrproper'
MRPROPER_DIRS  += include/config usr/include include/generated          \
MRPROPER_DIRS  += include/config include/generated          \
		  arch/$(SRCARCH)/include/generated .tmp_objdiff
MRPROPER_FILES += .config .config.old .version \
		  Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
@@ -1551,7 +1568,7 @@ $(DOC_TARGETS): scripts_basic FORCE
# ---------------------------------------------------------------------------

PHONY += scripts_gdb
scripts_gdb: prepare
scripts_gdb: prepare0
	$(Q)$(MAKE) $(build)=scripts/gdb
	$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)

@@ -1698,7 +1715,7 @@ CHECKSTACK_ARCH := $(ARCH)
endif
checkstack:
	$(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
	$(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
	$(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)

kernelrelease:
	@echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1717,11 +1734,11 @@ endif

tools/: FORCE
	$(Q)mkdir -p $(objtree)/tools
	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/
	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/

tools/%: FORCE
	$(Q)mkdir -p $(objtree)/tools
	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $*
	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*

# Single targets
# ---------------------------------------------------------------------------
@@ -1755,8 +1772,6 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
PHONY += /
/: ./

# Make sure the latest headers are built for Documentation
Documentation/ samples/: headers_install
%/: prepare FORCE
	$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)

+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ ifdef CONFIG_ARC_CURR_IN_REG
# any kernel headers, and missing the r25 global register
# Can't do unconditionally because of recursive include issues
# due to <linux/thread_info.h>
LINUXINCLUDE	+=  -include ${src}/arch/arc/include/asm/current.h
LINUXINCLUDE	+=  -include $(srctree)/arch/arc/include/asm/current.h
endif

cflags-y				+= -fsection-anchors
Loading