Merge tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 8 May 2021 17:00:11 +0000 (10:00 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 8 May 2021 17:00:11 +0000 (10:00 -0700)
Pull more Kbuild updates from Masahiro Yamada:

 - Convert sh and sparc to use generic shell scripts to generate the
   syscall headers

 - refactor .gitignore files

 - Update kernel/config_data.gz only when the content of the .config
   is really changed, which avoids the unneeded re-link of vmlinux

 - move "remove stale files" workarounds to scripts/remove-stale-files

 - suppress unused-but-set-variable warnings by default for Clang
   as well

 - fix locale setting LANG=C to LC_ALL=C

 - improve 'make distclean'

 - always keep intermediate objects from scripts/link-vmlinux.sh

 - move IF_ENABLED out of <linux/kconfig.h> to make it self-contained

 - misc cleanups

* tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (25 commits)
  linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h>
  kbuild: Don't remove link-vmlinux temporary files on exit/signal
  kbuild: remove the unneeded comments for external module builds
  kbuild: make distclean remove tag files in sub-directories
  kbuild: make distclean work against $(objtree) instead of $(srctree)
  kbuild: refactor modname-multi by using suffix-search
  kbuild: refactor fdtoverlay rule
  kbuild: parameterize the .o part of suffix-search
  arch: use cross_compiling to check whether it is a cross build or not
  kbuild: remove ARCH=sh64 support from top Makefile
  .gitignore: prefix local generated files with a slash
  kbuild: replace LANG=C with LC_ALL=C
  Makefile: Move -Wno-unused-but-set-variable out of GCC only block
  kbuild: add a script to remove stale generated files
  kbuild: update config_data.gz only when the content of .config is changed
  .gitignore: ignore only top-level modules.builtin
  .gitignore: move tags and TAGS close to other tag files
  kernel/.gitgnore: remove stale timeconst.h and hz.bc
  usr/include: refactor .gitignore
  genksyms: fix stale comment
  ...

1  2 
Makefile
arch/arm/boot/compressed/Makefile
include/linux/kernel.h
scripts/recordmcount.pl

diff --combined Makefile
index 72af8e423f1178042360d89bae417e2382afe55e,9b9a003bd88f308ff8670c43ab2845f7945860d2..15b6476d0f89c5eb42643704420914e5fc270945
+++ b/Makefile
@@@ -399,11 -399,6 +399,6 @@@ ifeq ($(ARCH),sparc64
         SRCARCH := sparc
  endif
  
- # Additional ARCH settings for sh
- ifeq ($(ARCH),sh64)
-        SRCARCH := sh
- endif
  export cross_compiling :=
  ifneq ($(SRCARCH),$(SUBARCH))
  cross_compiling := 1
@@@ -792,16 -787,16 +787,16 @@@ KBUILD_CFLAGS += -Wno-gn
  KBUILD_CFLAGS += -mno-global-merge
  else
  
- # These warnings generated too much noise in a regular build.
- # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
- KBUILD_CFLAGS += -Wno-unused-but-set-variable
  # Warn about unmarked fall-throughs in switch statement.
  # Disabled for clang while comment to attribute conversion happens and
  # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
  KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
  endif
  
+ # These warnings generated too much noise in a regular build.
+ # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
  KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
  ifdef CONFIG_FRAME_POINTER
  KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
@@@ -1225,7 -1220,7 +1220,7 @@@ PHONY += prepare archprepar
  
  archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
        asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
-       include/generated/autoconf.h
+       include/generated/autoconf.h remove-stale-files
  
  prepare0: archprepare
        $(Q)$(MAKE) $(build)=scripts/mod
  # All the preparing..
  prepare: prepare0 prepare-objtool prepare-resolve_btfids
  
+ PHONY += remove-stale-files
+ remove-stale-files:
+       $(Q)$(srctree)/scripts/remove-stale-files
  # Support for using generic headers in asm-generic
  asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
  
@@@ -1507,14 -1506,11 +1506,11 @@@ MRPROPER_FILES += include/config includ
                  debian snap tar-install \
                  .config .config.old .version \
                  Module.symvers \
 -                signing_key.pem signing_key.priv signing_key.x509     \
 -                x509.genkey extra_certificates signing_key.x509.keyid \
 -                signing_key.x509.signer vmlinux-gdb.py \
 +                certs/signing_key.pem certs/signing_key.x509 \
 +                certs/x509.genkey \
 +                vmlinux-gdb.py \
                  *.spec
  
- # Directories & files removed with 'make distclean'
- DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
  # clean - Delete most, but leave enough to build external modules
  #
  clean: rm-files := $(CLEAN_FILES)
@@@ -1541,16 -1537,14 +1537,14 @@@ mrproper: clean $(mrproper-dirs
  
  # distclean
  #
- distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
  PHONY += distclean
  
  distclean: mrproper
-       $(call cmd,rmfiles)
-       @find $(srctree) $(RCS_FIND_IGNORE) \
+       @find . $(RCS_FIND_IGNORE) \
                \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
                -o -name '*.bak' -o -name '#*#' -o -name '*%' \
-               -o -name 'core' \) \
+               -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
+               -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
                -type f -print | xargs rm -f
  
  
@@@ -1717,17 -1711,7 +1711,7 @@@ else # KBUILD_EXTMO
  # When building external modules the kernel used as basis is considered
  # read-only, and no consistency checks are made and the make
  # system is not used on the basis kernel. If updates are required
- # in the basis kernel ordinary make commands (without M=...) must
- # be used.
- #
- # The following are the only valid targets when building external
- # modules.
- # make M=dir clean     Delete all automatically generated files
- # make M=dir modules   Make all modules in specified dir
- # make M=dir         Same as 'make M=dir modules'
- # make M=dir modules_install
- #                      Install the modules built in the module directory
- #                      Assumes install directory is already created
+ # in the basis kernel ordinary make commands (without M=...) must be used.
  
  # We are always building only modules.
  KBUILD_BUILTIN :=
index c1f80476862190f3fc674c55f156edf6d92afd30,182b300e3f8a65eefe28869394dc6fe982341301..8eb70c1febce3399fe4d9dc19f5668c0d1e3ba2f
@@@ -96,13 -96,6 +96,6 @@@ endi
  $(foreach o, $(libfdt_objs) atags_to_fdt.o fdt_check_mem_start.o, \
        $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector))
  
- # These were previously generated C files. When you are building the kernel
- # with O=, make sure to remove the stale files in the output tree. Otherwise,
- # the build system wrongly compiles the stale ones.
- ifdef building_out_of_srctree
- $(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c))
- endif
  targets       := vmlinux vmlinux.lds piggy_data piggy.o \
                 lib1funcs.o ashldi3.o bswapsdi2.o \
                 head.o $(OBJS)
@@@ -118,8 -111,8 +111,8 @@@ asflags-y := -DZIMAG
  
  # Supply kernel BSS size to the decompressor via a linker symbol.
  KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
 -              sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
 -                     -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
 +              sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \
 +                     -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) )
  LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
  # Supply ZRELADDR to the decompressor via a linker symbol.
  ifneq ($(CONFIG_AUTO_ZRELADDR),y)
diff --combined include/linux/kernel.h
index 09035ac67d4b06ddac9595907d6f37ece4f394d2,2f9d15410c933617d93fc144675de4df17ff955c..15d8bad3d2f22ea71b9655a3573b8d54379170a6
@@@ -3,7 -3,6 +3,7 @@@
  #define _LINUX_KERNEL_H
  
  #include <stdarg.h>
 +#include <linux/align.h>
  #include <linux/limits.h>
  #include <linux/linkage.h>
  #include <linux/stddef.h>
   */
  #define REPEAT_BYTE(x)        ((~0ul / 0xff) * (x))
  
 -/* @a is a power of 2 value */
 -#define ALIGN(x, a)           __ALIGN_KERNEL((x), (a))
 -#define ALIGN_DOWN(x, a)      __ALIGN_KERNEL((x) - ((a) - 1), (a))
 -#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
 -#define PTR_ALIGN(p, a)               ((typeof(p))ALIGN((unsigned long)(p), (a)))
 -#define PTR_ALIGN_DOWN(p, a)  ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
 -#define IS_ALIGNED(x, a)              (((x) & ((typeof(x))(a) - 1)) == 0)
 -
  /* generic data direction definitions */
  #define READ                  0
  #define WRITE                 1
@@@ -41,6 -48,8 +41,8 @@@
   */
  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
  
+ #define PTR_IF(cond, ptr)     ((cond) ? (ptr) : NULL)
  #define u64_to_user_ptr(x) (          \
  {                                     \
        typecheck(u64, (x));            \
diff --combined scripts/recordmcount.pl
index 5053b78da19eb3bb4117751c9af4a8fa3a69aa5e,0a7fc9507d6fe076e0039b83a6baae1124b6c16c..c17e48020ec37c4f341b6870e4cfa68cfc6eaf38
@@@ -266,9 -266,9 +266,9 @@@ if ($arch eq "x86_64") 
      # force flags for this arch
      $ld .= " -m shlelf_linux";
      if ($endian eq "big") {
 -        $objcopy .= " -O elf32-shbig-linux";
 +      $objcopy .= " -O elf32-shbig-linux";
      } else {
 -        $objcopy .= " -O elf32-sh-linux";
 +      $objcopy .= " -O elf32-sh-linux";
      }
  
  } elsif ($arch eq "powerpc") {
            $ldemulation = "lppc"
      }
      if ($bits == 64) {
 -        $type = ".quad";
 -        $cc .= " -m64 ";
 -        $ld .= " -m elf64".$ldemulation." ";
 +      $type = ".quad";
 +      $cc .= " -m64 ";
 +      $ld .= " -m elf64".$ldemulation." ";
      } else {
 -        $cc .= " -m32 ";
 -        $ld .= " -m elf32".$ldemulation." ";
 +      $cc .= " -m32 ";
 +      $ld .= " -m elf32".$ldemulation." ";
      }
  
  } elsif ($arch eq "arm") {
      $type = "data8";
  
      if ($is_module eq "0") {
 -        $cc .= " -mconstant-gp";
 +      $cc .= " -mconstant-gp";
      }
  } elsif ($arch eq "sparc64") {
      # In the objdump output there are giblets like:
      $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
  } elsif ($arch eq "riscv") {
      $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
 -    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$";
 +    $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL(_PLT)?\\s_?mcount\$";
      $type = ".quad";
      $alignment = 2;
  } elsif ($arch eq "nds32") {
@@@ -497,7 -497,7 +497,7 @@@ sub update_func
  #
  # Step 2: find the sections and mcount call sites
  #
- open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
+ open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump";
  
  my $text;
  
@@@ -530,10 -530,10 +530,10 @@@ while (<IN>) 
        $read_function = defined($text_sections{$1});
        if (!$read_function) {
            foreach my $prefix (keys %text_section_prefixes) {
 -              if (substr($1, 0, length $prefix) eq $prefix) {
 -                  $read_function = 1;
 -                  last;
 -              }
 +              if (substr($1, 0, length $prefix) eq $prefix) {
 +                  $read_function = 1;
 +                  last;
 +              }
            }
        }
        # print out any recorded offsets
@@@ -642,5 -642,3 +642,5 @@@ if ($#converts >= 0) 
  `$rm $mcount_o $mcount_s`;
  
  exit(0);
 +
 +# vim: softtabstop=4