Subject: linux-next: manual merge of the kbuild tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Fri, 27 May 2022 10:08:44 +1000

Hi all,

Today's linux-next merge of the kbuild tree got a conflict in:

  scripts/Makefile.build

between commit:

  753da4179d08 ("objtool: Remove --lto and --vmlinux in favor of --link")

from Linus' tree and commits:

  3eec672cbc9b ("kbuild: do not create *.prelink.o for Clang LTO or IBT")
  7414d89fd7cd ("kbuild: make *.mod rule robust against too long argument error")

from the kbuild tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc scripts/Makefile.build
index 06400504150b,1754adba7010..000000000000
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@@ -226,23 -226,18 +230,19 @@@ objtool_args =								
  cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
  cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
  
 -endif # CONFIG_STACK_VALIDATION
 +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
+ delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
+ 
+ $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
++$(obj)/%.o: linked-object := y
  
  ifdef CONFIG_TRIM_UNUSED_KSYMS
  cmd_gen_ksymdeps = \
@@@ -421,18 -408,18 +413,19 @@@ $(obj)/modules.order: $(obj-m) FORC
  $(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): linked-object := 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))