Skip to content

Commit 81361b8

Browse files
committed
Merge tag 'kbuild-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/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 ...
2 parents e98e03d + 27932b6 commit 81361b8

47 files changed

Lines changed: 215 additions & 252 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 55 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ endif
129129
$(if $(word 2, $(KBUILD_EXTMOD)), \
130130
$(error building multiple external modules is not supported))
131131

132+
# Remove trailing slashes
133+
ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
134+
KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
135+
endif
136+
132137
export KBUILD_EXTMOD
133138

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

546551
PHONY += outputmakefile
552+
ifdef building_out_of_srctree
547553
# Before starting out-of-tree build, make sure the source tree is clean.
548554
# outputmakefile generates a Makefile in the output directory, if using a
549555
# separate output directory. This allows convenient use of make in the
550556
# output directory.
551557
# At the same time when output Makefile generated, generate .gitignore to
552558
# ignore whole output directory
559+
560+
quiet_cmd_makefile = GEN Makefile
561+
cmd_makefile = { \
562+
echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
563+
echo "include $(srctree)/Makefile"; \
564+
} > Makefile
565+
553566
outputmakefile:
554-
ifdef building_out_of_srctree
555567
$(Q)if [ -f $(srctree)/.config -o \
556568
-d $(srctree)/include/config -o \
557569
-d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
@@ -562,7 +574,7 @@ ifdef building_out_of_srctree
562574
false; \
563575
fi
564576
$(Q)ln -fsn $(srctree) source
565-
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
577+
$(call cmd,makefile)
566578
$(Q)test -e .gitignore || \
567579
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
568580
endif
@@ -658,7 +670,7 @@ endif
658670

659671
ifeq ($(KBUILD_EXTMOD),)
660672
# Objects we will link into vmlinux / subdirs we need to visit
661-
core-y := init/ usr/
673+
core-y := init/ usr/ arch/$(SRCARCH)/
662674
drivers-y := drivers/ sound/
663675
drivers-$(CONFIG_SAMPLES) += samples/
664676
drivers-$(CONFIG_NET) += net/
@@ -961,8 +973,8 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI)
961973
export CC_FLAGS_CFI
962974
endif
963975

964-
ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B
965-
KBUILD_CFLAGS += -falign-functions=32
976+
ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B
977+
KBUILD_CFLAGS += -falign-functions=64
966978
endif
967979

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

1092-
HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
1093-
1094-
has_libelf = $(call try-run,\
1095-
echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
1096-
1097-
ifdef CONFIG_STACK_VALIDATION
1098-
ifeq ($(has_libelf),1)
1099-
objtool_target := tools/objtool FORCE
1100-
else
1101-
SKIP_STACK_VALIDATION := 1
1102-
export SKIP_STACK_VALIDATION
1103-
endif
1104-
endif
1105-
1106-
PHONY += resolve_btfids_clean
1107-
1108-
resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
1109-
1110-
# tools/bpf/resolve_btfids directory might not exist
1111-
# in output directory, skip its clean in that case
1112-
resolve_btfids_clean:
1113-
ifneq ($(wildcard $(resolve_btfids_O)),)
1114-
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1115-
endif
1116-
1117-
ifdef CONFIG_BPF
1118-
ifdef CONFIG_DEBUG_INFO_BTF
1119-
ifeq ($(has_libelf),1)
1120-
resolve_btfids_target := tools/bpf/resolve_btfids FORCE
1121-
else
1122-
ERROR_RESOLVE_BTFIDS := 1
1123-
endif
1124-
endif # CONFIG_DEBUG_INFO_BTF
1125-
endif # CONFIG_BPF
1126-
11271104
PHONY += prepare0
11281105

11291106
export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
@@ -1235,7 +1212,7 @@ prepare0: archprepare
12351212
$(Q)$(MAKE) $(build)=.
12361213

12371214
# All the preparing..
1238-
prepare: prepare0 prepare-objtool prepare-resolve_btfids
1215+
prepare: prepare0
12391216

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

1255-
PHONY += prepare-objtool prepare-resolve_btfids
1256-
prepare-objtool: $(objtool_target)
1257-
ifeq ($(SKIP_STACK_VALIDATION),1)
1258-
ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
1259-
@echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
1260-
@false
1261-
endif
1262-
ifdef CONFIG_UNWINDER_ORC
1263-
@echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
1264-
@false
1265-
else
1266-
@echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
1267-
endif
1268-
endif
1269-
1270-
prepare-resolve_btfids: $(resolve_btfids_target)
1271-
ifeq ($(ERROR_RESOLVE_BTFIDS),1)
1272-
@echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
1273-
@false
1274-
endif
12751232
# Generate some files
12761233
# ---------------------------------------------------------------------------
12771234

@@ -1359,6 +1316,43 @@ PHONY += scripts_unifdef
13591316
scripts_unifdef: scripts_basic
13601317
$(Q)$(MAKE) $(build)=scripts scripts/unifdef
13611318

1319+
# ---------------------------------------------------------------------------
1320+
# Tools
1321+
1322+
ifdef CONFIG_STACK_VALIDATION
1323+
prepare: tools/objtool
1324+
endif
1325+
1326+
ifdef CONFIG_BPF
1327+
ifdef CONFIG_DEBUG_INFO_BTF
1328+
prepare: tools/bpf/resolve_btfids
1329+
endif
1330+
endif
1331+
1332+
PHONY += resolve_btfids_clean
1333+
1334+
resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
1335+
1336+
# tools/bpf/resolve_btfids directory might not exist
1337+
# in output directory, skip its clean in that case
1338+
resolve_btfids_clean:
1339+
ifneq ($(wildcard $(resolve_btfids_O)),)
1340+
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1341+
endif
1342+
1343+
# Clear a bunch of variables before executing the submake
1344+
ifeq ($(quiet),silent_)
1345+
tools_silent=s
1346+
endif
1347+
1348+
tools/: FORCE
1349+
$(Q)mkdir -p $(objtree)/tools
1350+
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1351+
1352+
tools/%: FORCE
1353+
$(Q)mkdir -p $(objtree)/tools
1354+
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1355+
13621356
# ---------------------------------------------------------------------------
13631357
# Kernel selftest
13641358

@@ -1959,20 +1953,6 @@ kernelversion:
19591953
image_name:
19601954
@echo $(KBUILD_IMAGE)
19611955

1962-
# Clear a bunch of variables before executing the submake
1963-
1964-
ifeq ($(quiet),silent_)
1965-
tools_silent=s
1966-
endif
1967-
1968-
tools/: FORCE
1969-
$(Q)mkdir -p $(objtree)/tools
1970-
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1971-
1972-
tools/%: FORCE
1973-
$(Q)mkdir -p $(objtree)/tools
1974-
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1975-
19761956
quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
19771957
cmd_rmfiles = rm -rf $(rm-files)
19781958

arch/alpha/Kbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
obj-y += kernel/ mm/
3+
obj-$(CONFIG_MATHEMU) += math-emu/

arch/alpha/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6
3838

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

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

4543
# export what is needed by arch/alpha/boot/Makefile

arch/arc/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ KBUILD_LDFLAGS += $(ldflags-y)
8585

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

88-
# See arch/arc/Kbuild for content of core part of the kernel
89-
core-y += arch/arc/
90-
9188
# w/o this dtb won't embed into kernel binary
9289
core-y += arch/arc/boot/dts/
9390

arch/arm/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ endif
252252

253253
export TEXT_OFFSET GZFLAGS MMUEXT
254254

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

arch/arm64/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
149149
KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
150150
KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
151151

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

arch/csky/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# SPDX-License-Identifier: GPL-2.0-only

arch/h8300/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
obj-y += kernel/ mm/ boot/dts/

arch/h8300/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ ifeq ($(CROSS_COMPILE),)
3030
CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
3131
endif
3232

33-
core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
34-
core-y += arch/$(ARCH)/boot/dts/
35-
3633
libs-y += arch/$(ARCH)/lib/
3734

3835
boot := arch/h8300/boot

arch/hexagon/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
obj-y += kernel/ mm/ lib/

0 commit comments

Comments
 (0)