Merge tag 'clang-lto-v5.12-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Feb 2021 18:08:50 +0000 (10:08 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Feb 2021 18:08:50 +0000 (10:08 -0800)
Pull clang LTO fixes from Kees Cook:
 "This gets parisc building again and moves LTO artifact caching cleanup
  from the 'distclean' build target to 'clean'.

  Summary:

   - Fix parisc build for ftrace vs mcount (Sami Tolvanen)

   - Move .thinlto-cache remove to "clean" from "distclean" (Masahiro Yamada)"

* tag 'clang-lto-v5.12-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  kbuild: Move .thinlto-cache removal to 'make clean'
  parisc: select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY

1  2 
Makefile
arch/parisc/Kconfig

diff --combined Makefile
+++ b/Makefile
@@@ -2,8 -2,8 +2,8 @@@
  VERSION = 5
  PATCHLEVEL = 11
  SUBLEVEL = 0
 -EXTRAVERSION = -rc2
 -NAME = Kleptomaniac Octopus
 +EXTRAVERSION =
 +NAME = ðŸ’• Valentine's Day Edition ðŸ’•
  
  # *DOCUMENTATION*
  # To see a list of typical targets execute "make help"
@@@ -100,36 -100,6 +100,36 @@@ endi
  
  export quiet Q KBUILD_VERBOSE
  
 +# Call a source code checker (by default, "sparse") as part of the
 +# C compilation.
 +#
 +# Use 'make C=1' to enable checking of only re-compiled files.
 +# Use 'make C=2' to enable checking of *all* source files, regardless
 +# of whether they are re-compiled or not.
 +#
 +# See the file "Documentation/dev-tools/sparse.rst" for more details,
 +# including where to get the "sparse" utility.
 +
 +ifeq ("$(origin C)", "command line")
 +  KBUILD_CHECKSRC = $(C)
 +endif
 +ifndef KBUILD_CHECKSRC
 +  KBUILD_CHECKSRC = 0
 +endif
 +
 +export KBUILD_CHECKSRC
 +
 +# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
 +# directory of external module to build. Setting M= takes precedence.
 +ifeq ("$(origin M)", "command line")
 +  KBUILD_EXTMOD := $(M)
 +endif
 +
 +$(if $(word 2, $(KBUILD_EXTMOD)), \
 +      $(error building multiple external modules is not supported))
 +
 +export KBUILD_EXTMOD
 +
  # Kbuild will save output files in the current working directory.
  # This does not need to match to the root of the kernel source tree.
  #
@@@ -175,8 -145,7 +175,8 @@@ els
  need-sub-make := 1
  endif
  
 -abs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
 +this-makefile := $(lastword $(MAKEFILE_LIST))
 +abs_srctree := $(realpath $(dir $(this-makefile)))
  
  ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
  $(error source directory cannot contain spaces or colons)
@@@ -191,6 -160,8 +191,6 @@@ MAKEFLAGS += --include-dir=$(abs_srctre
  need-sub-make := 1
  endif
  
 -this-makefile := $(lastword $(MAKEFILE_LIST))
 -
  ifneq ($(filter 3.%,$(MAKE_VERSION)),)
  # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
  # We need to invoke sub-make to avoid implicit rules in the top Makefile.
@@@ -224,6 -195,36 +224,6 @@@ ifeq ($(need-sub-make),
  # so that IDEs/editors are able to understand relative filenames.
  MAKEFLAGS += --no-print-directory
  
 -# Call a source code checker (by default, "sparse") as part of the
 -# C compilation.
 -#
 -# Use 'make C=1' to enable checking of only re-compiled files.
 -# Use 'make C=2' to enable checking of *all* source files, regardless
 -# of whether they are re-compiled or not.
 -#
 -# See the file "Documentation/dev-tools/sparse.rst" for more details,
 -# including where to get the "sparse" utility.
 -
 -ifeq ("$(origin C)", "command line")
 -  KBUILD_CHECKSRC = $(C)
 -endif
 -ifndef KBUILD_CHECKSRC
 -  KBUILD_CHECKSRC = 0
 -endif
 -
 -# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
 -# directory of external module to build. Setting M= takes precedence.
 -ifeq ("$(origin M)", "command line")
 -  KBUILD_EXTMOD := $(M)
 -endif
 -
 -$(if $(word 2, $(KBUILD_EXTMOD)), \
 -      $(error building multiple external modules is not supported))
 -
 -export KBUILD_CHECKSRC KBUILD_EXTMOD
 -
 -extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
 -
  ifeq ($(abs_srctree),$(abs_objtree))
          # building in the source tree
          srctree := .
@@@ -256,6 -257,7 +256,6 @@@ export building_out_of_srctree srctree 
  # of make so .config is not included in this case either (for *config).
  
  version_h := include/generated/uapi/linux/version.h
 -old_version_h := include/linux/version.h
  
  clean-targets := %clean mrproper cleandocs
  no-dot-config-targets := $(clean-targets) \
@@@ -450,6 -452,7 +450,6 @@@ AWK                = aw
  INSTALLKERNEL  := installkernel
  DEPMOD                = depmod
  PERL          = perl
 -PYTHON                = python
  PYTHON3               = python3
  CHECK         = sparse
  BASH          = bash
@@@ -505,7 -508,7 +505,7 @@@ CLANG_FLAGS :
  
  export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
  export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
 -export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
 +export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
  export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
  export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
  
@@@ -556,13 -559,7 +556,13 @@@ ifdef building_out_of_srctre
        { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
  endif
  
 -ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 +# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
 +# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
 +# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
 +# and from include/config/auto.conf.cmd to detect the compiler upgrade.
 +CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g')
 +
 +ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
  ifneq ($(CROSS_COMPILE),)
  CLANG_FLAGS   += --target=$(notdir $(CROSS_COMPILE:%-=%))
  GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
@@@ -581,6 -578,12 +581,6 @@@ KBUILD_AFLAGS     += $(CLANG_FLAGS
  export CLANG_FLAGS
  endif
  
 -# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
 -# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
 -# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
 -# and from include/config/auto.conf.cmd to detect the compiler upgrade.
 -CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
 -
  ifdef config-build
  # ===========================================================================
  # *config targets only - make sure prerequisites are updated, and descend
@@@ -646,8 -649,7 +646,8 @@@ ifeq ($(KBUILD_EXTMOD),
  core-y                := init/ usr/
  drivers-y     := drivers/ sound/
  drivers-$(CONFIG_SAMPLES) += samples/
 -drivers-y     += net/ virt/
 +drivers-$(CONFIG_NET) += net/
 +drivers-y     += virt/
  libs-y                := lib/
  endif # KBUILD_EXTMOD
  
@@@ -810,12 -812,10 +810,12 @@@ KBUILD_CFLAGS   += -ftrivial-auto-var-ini
  KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
  endif
  
 +DEBUG_CFLAGS  :=
 +
  # Workaround for GCC versions < 5.0
  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
  ifdef CONFIG_CC_IS_GCC
 -DEBUG_CFLAGS  := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 +DEBUG_CFLAGS  += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
  endif
  
  ifdef CONFIG_DEBUG_INFO
@@@ -830,10 -830,8 +830,10 @@@ ifneq ($(LLVM_IAS),1
  KBUILD_AFLAGS += -Wa,-gdwarf-2
  endif
  
 -ifdef CONFIG_DEBUG_INFO_DWARF4
 -DEBUG_CFLAGS  += -gdwarf-4
 +ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
 +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
 +DEBUG_CFLAGS  += -gdwarf-$(dwarf-version-y)
  endif
  
  ifdef CONFIG_DEBUG_INFO_REDUCED
@@@ -968,6 -966,12 +968,6 @@@ KBUILD_CFLAGS   += $(call cc-option,-We
  # change __FILE__ to the relative path from the srctree
  KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
  
 -# ensure -fcf-protection is disabled when using retpoline as it is
 -# incompatible with -mindirect-branch=thunk-extern
 -ifdef CONFIG_RETPOLINE
 -KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
 -endif
 -
  # include additional Makefiles when needed
  include-y                     := scripts/Makefile.extrawarn
  include-$(CONFIG_KASAN)               += scripts/Makefile.kasan
@@@ -1072,7 -1076,7 +1072,7 @@@ ifdef CONFIG_MODULE_COMPRES
      mod_compress_cmd = $(KGZIP) -n -f
    endif # CONFIG_MODULE_COMPRESS_GZIP
    ifdef CONFIG_MODULE_COMPRESS_XZ
 -    mod_compress_cmd = $(XZ) -f
 +    mod_compress_cmd = $(XZ) --lzma2=dict=2MiB -f
    endif # CONFIG_MODULE_COMPRESS_XZ
  endif # CONFIG_MODULE_COMPRESS
  export mod_compress_cmd
@@@ -1100,17 -1104,6 +1100,17 @@@ ifdef CONFIG_STACK_VALIDATIO
    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)
@@@ -1123,7 -1116,6 +1123,7 @@@ endif # CONFIG_BP
  
  PHONY += prepare0
  
 +extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
  export MODORDER := $(extmod-prefix)modules.order
  export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
  
@@@ -1281,22 -1273,14 +1281,22 @@@ define filechk_utsrelease.
  endef
  
  define filechk_version.h
 -      echo \#define LINUX_VERSION_CODE $(shell                         \
 -      expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
 -      echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'
 +      if [ $(SUBLEVEL) -gt 255 ]; then                                 \
 +              echo \#define LINUX_VERSION_CODE $(shell                 \
 +              expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
 +      else                                                             \
 +              echo \#define LINUX_VERSION_CODE $(shell                 \
 +              expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
 +      fi;                                                              \
 +      echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) +  \
 +      ((c) > 255 ? 255 : (c)))';                                       \
 +      echo \#define LINUX_VERSION_MAJOR $(VERSION);                    \
 +      echo \#define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL);            \
 +      echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
  endef
  
  $(version_h): FORCE
        $(call filechk,version.h)
 -      $(Q)rm -f $(old_version_h)
  
  include/generated/utsrelease.h: include/config/kernel.release FORCE
        $(call filechk,utsrelease.h)
@@@ -1375,9 -1359,6 +1375,9 @@@ ifneq ($(dtstree),
  %.dtb: include/config/kernel.release scripts_dtc
        $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
  
 +%.dtbo: include/config/kernel.release scripts_dtc
 +      $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
 +
  PHONY += dtbs dtbs_install dtbs_check
  dtbs: include/config/kernel.release scripts_dtc
        $(Q)$(MAKE) $(build)=$(dtstree)
@@@ -1510,7 -1491,7 +1510,7 @@@ endif # CONFIG_MODULE
  # Directories & files removed with 'make clean'
  CLEAN_FILES += include/ksym vmlinux.symvers \
               modules.builtin modules.builtin.modinfo modules.nsdeps \
-              compile_commands.json
+              compile_commands.json .thinlto-cache
  
  # Directories & files removed with 'make mrproper'
  MRPROPER_FILES += include/config include/generated          \
                  *.spec
  
  # Directories & files removed with 'make distclean'
- DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS .thinlto-cache
+ DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
  
  # clean - Delete most, but leave enough to build external modules
  #
@@@ -1536,7 -1517,7 +1536,7 @@@ vmlinuxclean
        $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
        $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
  
 -clean: archclean vmlinuxclean
 +clean: archclean vmlinuxclean resolve_btfids_clean
  
  # mrproper - Delete all generated files, including .config
  #
@@@ -1857,7 -1838,7 +1857,7 @@@ clean: $(clean-dirs
        @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
                \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '*.ko.*' \
 -              -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
 +              -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
                -o -name '*.dwo' -o -name '*.lst' \
                -o -name '*.su' -o -name '*.mod' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
diff --combined arch/parisc/Kconfig
@@@ -4,6 -4,7 +4,6 @@@ config PARIS
        select ARCH_32BIT_OFF_T if !64BIT
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select HAVE_IDE
 -      select HAVE_OPROFILE
        select HAVE_FUNCTION_TRACER
        select HAVE_FUNCTION_GRAPH_TRACER
        select HAVE_SYSCALL_TRACEPOINTS
@@@ -34,7 -35,6 +34,7 @@@
        select GENERIC_SMP_IDLE_THREAD
        select GENERIC_CPU_DEVICES
        select GENERIC_STRNCPY_FROM_USER
 +      select GENERIC_LIB_DEVMEM_IS_ALLOWED
        select SYSCTL_ARCH_UNALIGN_ALLOW
        select SYSCTL_EXCEPTION_TRACE
        select HAVE_MOD_ARCH_SPECIFIC
        select HAVE_KRETPROBES
        select HAVE_DYNAMIC_FTRACE if $(cc-option,-fpatchable-function-entry=1,1)
        select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE
+       select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
        select HAVE_KPROBES_ON_FTRACE
        select HAVE_DYNAMIC_FTRACE_WITH_REGS
 +      select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS
        select SET_FS
  
        help
@@@ -203,8 -203,9 +204,8 @@@ config PREFETC
        depends on PA8X00 || PA7200
  
  config MLONGCALLS
 -      bool "Enable the -mlong-calls compiler option for big kernels"
 -      default y if !MODULES || UBSAN || FTRACE
 -      default n
 +      def_bool y if !MODULES || UBSAN || FTRACE
 +      bool "Enable the -mlong-calls compiler option for big kernels" if MODULES && !UBSAN && !FTRACE
        depends on PA8X00
        help
          If you configure the kernel to include many drivers built-in instead
@@@ -312,16 -313,6 +313,16 @@@ config IRQSTACK
          for handling hard and soft interrupts.  This can help avoid
          overflowing the process kernel stacks.
  
 +config TLB_PTLOCK
 +      bool "Use page table locks in TLB fault handler"
 +      depends on SMP
 +      default n
 +      help
 +        Select this option to enable page table locking in the TLB
 +        fault handler. This ensures that page table entries are
 +        updated consistently on SMP machines at the expense of some
 +        loss in performance.
 +
  config HOTPLUG_CPU
        bool
        default y if SMP
@@@ -346,6 -337,7 +347,6 @@@ source "kernel/Kconfig.hz
  config COMPAT
        def_bool y
        depends on 64BIT
 -      select COMPAT_BINFMT_ELF if BINFMT_ELF
  
  config SYSVIPC_COMPAT
        def_bool y