Skip to content

Commit

Permalink
Merge tag 'kbuild-v5.14' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

 - Increase the -falign-functions alignment for the debug option.

 - Remove ugly libelf checks from the top Makefile.

 - Make the silent build (-s) more silent.

 - Re-compile the kernel if KBUILD_BUILD_TIMESTAMP is specified.

 - Various script cleanups

* tag 'kbuild-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (27 commits)
  scripts: add generic syscallnr.sh
  scripts: check duplicated syscall number in syscall table
  sparc: syscalls: use pattern rules to generate syscall headers
  parisc: syscalls: use pattern rules to generate syscall headers
  nds32: add arch/nds32/boot/.gitignore
  kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set
  kbuild: modpost: Explicitly warn about unprototyped symbols
  kbuild: remove trailing slashes from $(KBUILD_EXTMOD)
  kconfig.h: explain IS_MODULE(), IS_ENABLED()
  kconfig: constify long_opts
  scripts/setlocalversion: simplify the short version part
  scripts/setlocalversion: factor out 12-chars hash construction
  scripts/setlocalversion: add more comments to -dirty flag detection
  scripts/setlocalversion: remove workaround for old make-kpkg
  scripts/setlocalversion: remove mercurial, svn and git-svn supports
  kbuild: clean up ${quiet} checks in shell scripts
  kbuild: sink stdout from cmd for silent build
  init: use $(call cmd,) for generating include/generated/compile.h
  kbuild: merge scripts/mkmakefile to top Makefile
  sh: move core-y in arch/sh/Makefile to arch/sh/Kbuild
  ...
  • Loading branch information
torvalds committed Jul 10, 2021
2 parents e98e03d + 27932b6 commit 81361b8
Show file tree
Hide file tree
Showing 47 changed files with 215 additions and 252 deletions.
130 changes: 55 additions & 75 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ endif
$(if $(word 2, $(KBUILD_EXTMOD)), \
$(error building multiple external modules is not supported))

# Remove trailing slashes
ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
endif

export KBUILD_EXTMOD

# Kbuild will save output files in the current working directory.
Expand Down Expand Up @@ -544,14 +549,21 @@ scripts_basic:
$(Q)rm -f .tmp_quiet_recordmcount

PHONY += outputmakefile
ifdef building_out_of_srctree
# Before starting out-of-tree build, make sure the source tree is clean.
# outputmakefile generates a Makefile in the output directory, if using a
# separate output directory. This allows convenient use of make in the
# output directory.
# At the same time when output Makefile generated, generate .gitignore to
# ignore whole output directory

quiet_cmd_makefile = GEN Makefile
cmd_makefile = { \
echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
echo "include $(srctree)/Makefile"; \
} > Makefile

outputmakefile:
ifdef building_out_of_srctree
$(Q)if [ -f $(srctree)/.config -o \
-d $(srctree)/include/config -o \
-d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
Expand All @@ -562,7 +574,7 @@ ifdef building_out_of_srctree
false; \
fi
$(Q)ln -fsn $(srctree) source
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
$(call cmd,makefile)
$(Q)test -e .gitignore || \
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
endif
Expand Down Expand Up @@ -658,7 +670,7 @@ endif

ifeq ($(KBUILD_EXTMOD),)
# Objects we will link into vmlinux / subdirs we need to visit
core-y := init/ usr/
core-y := init/ usr/ arch/$(SRCARCH)/
drivers-y := drivers/ sound/
drivers-$(CONFIG_SAMPLES) += samples/
drivers-$(CONFIG_NET) += net/
Expand Down Expand Up @@ -961,8 +973,8 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI)
export CC_FLAGS_CFI
endif

ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B
KBUILD_CFLAGS += -falign-functions=32
ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B
KBUILD_CFLAGS += -falign-functions=64
endif

# arch Makefile may override CC so keep this after arch Makefile is included
Expand Down Expand Up @@ -1089,41 +1101,6 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
export MODLIB

HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)

has_libelf = $(call try-run,\
echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)

ifdef CONFIG_STACK_VALIDATION
ifeq ($(has_libelf),1)
objtool_target := tools/objtool FORCE
else
SKIP_STACK_VALIDATION := 1
export SKIP_STACK_VALIDATION
endif
endif

PHONY += resolve_btfids_clean

resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids

# tools/bpf/resolve_btfids directory might not exist
# in output directory, skip its clean in that case
resolve_btfids_clean:
ifneq ($(wildcard $(resolve_btfids_O)),)
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
endif

ifdef CONFIG_BPF
ifdef CONFIG_DEBUG_INFO_BTF
ifeq ($(has_libelf),1)
resolve_btfids_target := tools/bpf/resolve_btfids FORCE
else
ERROR_RESOLVE_BTFIDS := 1
endif
endif # CONFIG_DEBUG_INFO_BTF
endif # CONFIG_BPF

PHONY += prepare0

export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
Expand Down Expand Up @@ -1235,7 +1212,7 @@ prepare0: archprepare
$(Q)$(MAKE) $(build)=.

# All the preparing..
prepare: prepare0 prepare-objtool prepare-resolve_btfids
prepare: prepare0

PHONY += remove-stale-files
remove-stale-files:
Expand All @@ -1252,26 +1229,6 @@ uapi-asm-generic:
$(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
generic=include/uapi/asm-generic

PHONY += prepare-objtool prepare-resolve_btfids
prepare-objtool: $(objtool_target)
ifeq ($(SKIP_STACK_VALIDATION),1)
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
@echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
@false
endif
ifdef CONFIG_UNWINDER_ORC
@echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
@false
else
@echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
endif
endif

prepare-resolve_btfids: $(resolve_btfids_target)
ifeq ($(ERROR_RESOLVE_BTFIDS),1)
@echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
@false
endif
# Generate some files
# ---------------------------------------------------------------------------

Expand Down Expand Up @@ -1359,6 +1316,43 @@ PHONY += scripts_unifdef
scripts_unifdef: scripts_basic
$(Q)$(MAKE) $(build)=scripts scripts/unifdef

# ---------------------------------------------------------------------------
# Tools

ifdef CONFIG_STACK_VALIDATION
prepare: tools/objtool
endif

ifdef CONFIG_BPF
ifdef CONFIG_DEBUG_INFO_BTF
prepare: tools/bpf/resolve_btfids
endif
endif

PHONY += resolve_btfids_clean

resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids

# tools/bpf/resolve_btfids directory might not exist
# in output directory, skip its clean in that case
resolve_btfids_clean:
ifneq ($(wildcard $(resolve_btfids_O)),)
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
endif

# Clear a bunch of variables before executing the submake
ifeq ($(quiet),silent_)
tools_silent=s
endif

tools/: FORCE
$(Q)mkdir -p $(objtree)/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 $(srctree)/tools/ $*

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

Expand Down Expand Up @@ -1959,20 +1953,6 @@ kernelversion:
image_name:
@echo $(KBUILD_IMAGE)

# Clear a bunch of variables before executing the submake

ifeq ($(quiet),silent_)
tools_silent=s
endif

tools/: FORCE
$(Q)mkdir -p $(objtree)/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 $(srctree)/tools/ $*

quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
cmd_rmfiles = rm -rf $(rm-files)

Expand Down
3 changes: 3 additions & 0 deletions arch/alpha/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/
obj-$(CONFIG_MATHEMU) += math-emu/
2 changes: 0 additions & 2 deletions arch/alpha/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6

head-y := arch/alpha/kernel/head.o

core-y += arch/alpha/kernel/ arch/alpha/mm/
core-$(CONFIG_MATHEMU) += arch/alpha/math-emu/
libs-y += arch/alpha/lib/

# export what is needed by arch/alpha/boot/Makefile
Expand Down
3 changes: 0 additions & 3 deletions arch/arc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ KBUILD_LDFLAGS += $(ldflags-y)

head-y := arch/arc/kernel/head.o

# See arch/arc/Kbuild for content of core part of the kernel
core-y += arch/arc/

# w/o this dtb won't embed into kernel binary
core-y += arch/arc/boot/dts/

Expand Down
1 change: 0 additions & 1 deletion arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ endif

export TEXT_OFFSET GZFLAGS MMUEXT

core-y += arch/arm/
# If we have a machine-specific directory, then include it in the build.
core-y += $(machdirs) $(platdirs)

Expand Down
1 change: 0 additions & 1 deletion arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)

core-y += arch/arm64/
libs-y := arch/arm64/lib/ $(libs-y)
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a

Expand Down
1 change: 1 addition & 0 deletions arch/csky/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
2 changes: 2 additions & 0 deletions arch/h8300/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ boot/dts/
3 changes: 0 additions & 3 deletions arch/h8300/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
endif

core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
core-y += arch/$(ARCH)/boot/dts/

libs-y += arch/$(ARCH)/lib/

boot := arch/h8300/boot
Expand Down
2 changes: 2 additions & 0 deletions arch/hexagon/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ lib/
4 changes: 0 additions & 4 deletions arch/hexagon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)

head-y := arch/hexagon/kernel/head.o

core-y += arch/hexagon/kernel/ \
arch/hexagon/mm/ \
arch/hexagon/lib/
1 change: 1 addition & 0 deletions arch/ia64/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
1 change: 0 additions & 1 deletion arch/m68k/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ head-$(CONFIG_SUN3) := arch/m68k/kernel/sun3-head.o
head-$(CONFIG_M68000) := arch/m68k/68000/head.o
head-$(CONFIG_COLDFIRE) := arch/m68k/coldfire/head.o

core-y += arch/m68k/
libs-y += arch/m68k/lib/


Expand Down
1 change: 1 addition & 0 deletions arch/microblaze/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
3 changes: 0 additions & 3 deletions arch/mips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ head-y := arch/mips/kernel/head.o
libs-y += arch/mips/lib/
libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/

# See arch/mips/Kbuild for content of core part of the kernel
core-y += arch/mips/

drivers-y += arch/mips/crypto/

# suspend and hibernation support
Expand Down
1 change: 1 addition & 0 deletions arch/nds32/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
2 changes: 2 additions & 0 deletions arch/nds32/boot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
/Image
1 change: 1 addition & 0 deletions arch/nios2/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
1 change: 0 additions & 1 deletion arch/openrisc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ endif

head-y := arch/openrisc/kernel/head.o

core-y += arch/openrisc/
libs-y += $(LIBGCC)

PHONY += vmlinux.bin
Expand Down
1 change: 1 addition & 0 deletions arch/parisc/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: GPL-2.0-only
18 changes: 4 additions & 14 deletions arch/parisc/kernel/syscalls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,15 @@ syshdr := $(srctree)/scripts/syscallhdr.sh
systbl := $(srctree)/scripts/syscalltbl.sh

quiet_cmd_syshdr = SYSHDR $@
cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr --abis $(abis) $< $@
cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr --abis common,$* $< $@

quiet_cmd_systbl = SYSTBL $@
cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@
cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis common,$* $< $@

$(uapi)/unistd_32.h: abis := common,32
$(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE
$(uapi)/unistd_%.h: $(syscall) $(syshdr) FORCE
$(call if_changed,syshdr)

$(uapi)/unistd_64.h: abis := common,64
$(uapi)/unistd_64.h: $(syscall) $(syshdr) FORCE
$(call if_changed,syshdr)

$(kapi)/syscall_table_32.h: abis := common,32
$(kapi)/syscall_table_32.h: $(syscall) $(systbl) FORCE
$(call if_changed,systbl)

$(kapi)/syscall_table_64.h: abis := common,64
$(kapi)/syscall_table_64.h: $(syscall) $(systbl) FORCE
$(kapi)/syscall_table_%.h: $(syscall) $(systbl) FORCE
$(call if_changed,systbl)

uapisyshdr-y += unistd_32.h unistd_64.h
Expand Down
3 changes: 0 additions & 3 deletions arch/powerpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@ head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o

# See arch/powerpc/Kbuild for content of core part of the kernel
core-y += arch/powerpc/

# Default to zImage, override when needed
all: zImage

Expand Down
1 change: 0 additions & 1 deletion arch/riscv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ endif

head-y := arch/riscv/kernel/head.o

core-y += arch/riscv/
core-$(CONFIG_RISCV_ERRATA_ALTERNATIVE) += arch/riscv/errata/

libs-y += arch/riscv/lib/
Expand Down
3 changes: 0 additions & 3 deletions arch/s390/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ OBJCOPYFLAGS := -O binary

head-y := arch/s390/kernel/head64.o

# See arch/s390/Kbuild for content of core part of the kernel
core-y += arch/s390/

libs-y += arch/s390/lib/
drivers-y += drivers/s390/

Expand Down
4 changes: 4 additions & 0 deletions arch/sh/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ boards/
obj-$(CONFIG_SH_FPU_EMU) += math-emu/
obj-$(CONFIG_USE_BUILTIN_DTB) += boot/dts/
5 changes: 0 additions & 5 deletions arch/sh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ export ld-bfd

head-y := arch/sh/kernel/head_32.o

core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/

core-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/

# Mach groups
machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ endif

head-y := arch/sparc/kernel/head_$(BITS).o

# See arch/sparc/Kbuild for the core part of the kernel
core-y += arch/sparc/

libs-y += arch/sparc/prom/
libs-y += arch/sparc/lib/

Expand Down
Loading

0 comments on commit 81361b8

Please sign in to comment.