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

 - Fix build regressions for parisc, csky, nios2, openrisc

 - Simplify module builds for CONFIG_LTO_CLANG and CONFIG_X86_KERNEL_IBT

 - Remove arch/parisc/nm, which was presumably a workaround for old
   tools

 - Check the odd combination of EXPORT_SYMBOL and 'static' precisely

 - Make external module builds robust against "too long argument error"

 - Support j, k keys for moving the cursor in nconfig

* tag 'kbuild-v5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (25 commits)
  kbuild: Allow to select bash in a modified environment
  scripts: kconfig: nconf: make nconfig accept jk keybindings
  modpost: use fnmatch() to simplify match()
  modpost: simplify mod->name allocation
  kbuild: factor out the common objtool arguments
  kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o
  kbuild: clean .tmp_* pattern by make clean
  kbuild: remove redundant cleanups in scripts/link-vmlinux.sh
  kbuild: rebuild multi-object modules when objtool is updated
  kbuild: add cmd_and_savecmd macro
  kbuild: make *.mod rule robust against too long argument error
  kbuild: make built-in.a rule robust against too long argument error
  kbuild: check static EXPORT_SYMBOL* by script instead of modpost
  parisc: remove arch/parisc/nm
  kbuild: do not create *.prelink.o for Clang LTO or IBT
  kbuild: replace $(linked-object) with CONFIG options
  kbuild: do not try to parse *.cmd files for objects provided by compiler
  kbuild: replace $(if A,A,B) with $(or A,B) in scripts/Makefile.modpost
  modpost: squash if...else-if in find_elf_symbol2()
  modpost: reuse ARRAY_SIZE() macro for section_mismatch()
  ...
parents 952923dd 42ce60aa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1490,7 +1490,7 @@ CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \

# Directories & files removed with 'make mrproper'
MRPROPER_FILES += include/config include/generated          \
		  arch/$(SRCARCH)/include/generated .tmp_objdiff \
		  arch/$(SRCARCH)/include/generated .objdiff \
		  debian snap tar-install \
		  .config .config.old .version \
		  Module.symvers \
@@ -1857,7 +1857,7 @@ clean: $(clean-dirs)
		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
		-o -name '*.asn1.[ch]' \
		-o -name '*.symtypes' -o -name 'modules.order' \
		-o -name '.tmp_*.o.*' \
		-o -name '.tmp_*' \
		-o -name '*.c.[012]*.*' \
		-o -name '*.ll' \
		-o -name '*.gcno' \
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
boot := arch/parisc/boot
KBUILD_IMAGE := $(boot)/bzImage

NM		= sh $(srctree)/arch/parisc/nm
CHECKFLAGS	+= -D__hppa__=1

ifdef CONFIG_64BIT

arch/parisc/nm

deleted100644 → 0
+0 −6
Original line number Diff line number Diff line
#!/bin/sh
##
# Hack to have an nm which removes the local symbols.  We also rely
# on this nm being hidden out of the ordinarily executable path
##
${CROSS_COMPILE}nm $* | grep -v '.LC*[0-9]*$'
+8 −2
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@ pound := \#
# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
dot-target = $(dir $@).$(notdir $@)

###
# Name of target with a '.tmp_' as filename prefix. foo/bar.o => foo/.tmp_bar.o
tmp-target = $(dir $@).tmp_$(notdir $@)

###
# The temporary file to save gcc -MMD generated dependencies must not
# contain a comma
@@ -138,9 +142,11 @@ check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequisite is missing)
if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE)

# Execute command if command has changed or prerequisite(s) are updated.
if_changed = $(if $(if-changed-cond),                                        \
if_changed = $(if $(if-changed-cond),$(cmd_and_savecmd),@:)

cmd_and_savecmd =                                                            \
	$(cmd);                                                              \
	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd

# Execute the command and also postprocess generated .d dependencies file.
if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
+38 −72
Original line number Diff line number Diff line
@@ -88,10 +88,6 @@ endif
targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \
				$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))

ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
targets-for-modules += $(patsubst %.o, %.prelink.o, $(filter %.o, $(obj-m)))
endif

ifdef need-modorder
targets-for-modules += $(obj)/modules.order
endif
@@ -152,8 +148,18 @@ $(obj)/%.ll: $(src)/%.c FORCE
# The C file is compiled and updated dependency information is generated.
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)

is-single-obj-m = $(and $(part-of-module),$(filter $@, $(obj-m)),y)

# When a module consists of a single object, there is no reason to keep LLVM IR.
# Make $(LD) covert LLVM IR to ELF here.
ifdef CONFIG_LTO_CLANG
cmd_ld_single_m = $(if $(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
endif

quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< $(cmd_objtool)
      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
		$(cmd_ld_single_m) \
		$(cmd_objtool)

ifdef CONFIG_MODVERSIONS
# When module versioning is enabled the following steps are executed:
@@ -204,54 +210,25 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),
	$(sub_cmd_record_mcount))
endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT

ifdef CONFIG_OBJTOOL

objtool := $(objtree)/tools/objtool/objtool

objtool_args =								\
	$(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label)	\
	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
	$(if $(CONFIG_RETPOLINE), --retpoline)				\
	$(if $(CONFIG_SLS), --sls)					\
	$(if $(CONFIG_STACK_VALIDATION), --stackval)			\
	$(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call)		\
	--uaccess							\
	$(if $(linked-object), --link)					\
	$(if $(part-of-module), --module)				\
	$(if $(CONFIG_GCOV_KERNEL), --no-unreachable)

cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)

endif # CONFIG_OBJTOOL

ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)

# Skip objtool for LLVM bitcode
$(obj)/%.o: objtool-enabled :=

else

# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file

$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)

endif
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))

ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_gen_ksymdeps = \
	$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
endif

cmd_check_local_export = $(srctree)/scripts/check-local-export $@

define rule_cc_o_c
	$(call cmd_and_fixdep,cc_o_c)
	$(call cmd,gen_ksymdeps)
	$(call cmd,check_local_export)
	$(call cmd,checksrc)
	$(call cmd,checkdoc)
	$(call cmd,gen_objtooldep)
@@ -262,6 +239,7 @@ endef
define rule_as_o_S
	$(call cmd_and_fixdep,as_o_S)
	$(call cmd,gen_ksymdeps)
	$(call cmd,check_local_export)
	$(call cmd,gen_objtooldep)
	$(call cmd,gen_symversions_S)
endef
@@ -271,27 +249,10 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
	$(call if_changed_rule,cc_o_c)
	$(call cmd,force_checksrc)

ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
# Module .o files may contain LLVM bitcode, compile them into native code
# before ELF processing
quiet_cmd_cc_prelink_modules = LD [M]  $@
      cmd_cc_prelink_modules =						\
	$(LD) $(ld_flags) -r -o $@					\
		--whole-archive $(filter-out FORCE,$^)			\
		$(cmd_objtool)

# objtool was skipped for LLVM bitcode, run it now that we have compiled
# modules into native code
$(obj)/%.prelink.o: objtool-enabled = y
$(obj)/%.prelink.o: part-of-module := y
$(obj)/%.prelink.o: linked-object := y

$(obj)/%.prelink.o: $(obj)/%.o FORCE
	$(call if_changed,cc_prelink_modules)
endif

cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) | \
	$(AWK) -v RS='( |\n)' '!x[$$0]++' > $@
# To make this rule robust against "Argument list too long" error,
# ensure to add $(obj)/ prefix by a shell command.
cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \
	$(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@

$(obj)/%.mod: FORCE
	$(call if_changed,mod)
@@ -299,7 +260,7 @@ $(obj)/%.mod: FORCE
# List module undefined symbols
cmd_undefined_syms = $(NM) $< | sed -n 's/^  *U //p' > $@

$(obj)/%.usyms: $(obj)/%$(mod-prelink-ext).o FORCE
$(obj)/%.usyms: $(obj)/%.o FORCE
	$(call if_changed,undefined_syms)

quiet_cmd_cc_lst_c = MKLST   $@
@@ -392,9 +353,14 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
#
# Rule to compile a set of .o files into one .a file (without symbol table)
#
# To make this rule robust against "Argument list too long" error,
# remove $(obj)/ prefix, and restore it by a shell command.

quiet_cmd_ar_builtin = AR      $@
      cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
      cmd_ar_builtin = rm -f $@; \
		echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
		sed -E 's:([^ ]+):$(obj)/\1:g' | \
		xargs $(AR) cDPrST $@

$(obj)/built-in.a: $(real-obj-y) FORCE
	$(call if_changed,ar_builtin)
@@ -421,18 +387,18 @@ $(obj)/modules.order: $(obj-m) FORCE
$(obj)/lib.a: $(lib-y) FORCE
	$(call if_changed,ar)

ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
quiet_cmd_link_multi-m = AR [M]  $@
cmd_link_multi-m =						\
	rm -f $@; 						\
	$(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@)
else
quiet_cmd_link_multi-m = LD [M]  $@
      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@)
endif
quiet_cmd_ld_multi_m = LD [M]  $@
      cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool)

define rule_ld_multi_m
	$(call cmd_and_savecmd,ld_multi_m)
	$(call cmd,gen_objtooldep)
endef

$(multi-obj-m): objtool-enabled := $(delay-objtool)
$(multi-obj-m): part-of-module := y
$(multi-obj-m): %.o: %.mod FORCE
	$(call if_changed,link_multi-m)
	$(call if_changed_rule,ld_multi_m)
$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)

targets := $(filter-out $(PHONY), $(targets))
Loading