Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Aug 2014 17:14:29 +0000 (11:14 -0600)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Aug 2014 17:14:29 +0000 (11:14 -0600)
Pull misc kbuild updates from Michal Marek:
 "This is the non-critical part of kbuild for 3.17-rc1:

   - make help hint to use make -s with make kernelrelease et al.
   - moved a kbuild document to Documentation/kbuild where it belongs
   - four new Coccinelle scripts, one dropped and one fixed
   - new make kselftest target to run various tests on the kernel"

* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
  kbuild: kselftest - new make target to build and run kernel selftests
  Coccinelle: Script to replace if and BUG with BUG_ON
  Coccinelle: Script to detect incorrect argument to sizeof
  Coccinelle: Script to use ARRAY_SIZE instead of division of two sizeofs
  Coccinelle: Script to detect cast after memory allocation
  coccinelle/null: solve parse error
  Documentation: headers_install.txt is part of kbuild
  kbuild: make -s should be used with kernelrelease/kernelversion/image_name

1  2 
Makefile

diff --combined Makefile
index ada00f0d2a11730746f87e4ff5213eb2819c827d,2ca7d189618df08095524746fe14ca332514b78f..6aace6750567ba113388cdf43312d3a46d011c1b
+++ b/Makefile
@@@ -1,7 -1,7 +1,7 @@@
  VERSION = 3
  PATCHLEVEL = 16
  SUBLEVEL = 0
 -EXTRAVERSION = -rc1
 +EXTRAVERSION =
  NAME = Shuffling Zombie Juror
  
  # *DOCUMENTATION*
@@@ -41,29 -41,6 +41,29 @@@ unexport GREP_OPTION
  # descending is started. They are now explicitly listed as the
  # prepare rule.
  
 +# Beautify output
 +# ---------------------------------------------------------------------------
 +#
 +# Normally, we echo the whole command before executing it. By making
 +# that echo $($(quiet)$(cmd)), we now have the possibility to set
 +# $(quiet) to choose other forms of output instead, e.g.
 +#
 +#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
 +#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
 +#
 +# If $(quiet) is empty, the whole command will be printed.
 +# If it is set to "quiet_", only the short version will be printed.
 +# If it is set to "silent_", nothing will be printed at all, since
 +# the variable $(silent_cmd_cc_o_c) doesn't exist.
 +#
 +# A simple variant is to prefix commands with $(Q) - that's useful
 +# for commands that shall be hidden in non-verbose mode.
 +#
 +#     $(Q)ln $@ :<
 +#
 +# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
 +# If KBUILD_VERBOSE equals 1 then the above command is displayed.
 +#
  # To put more focus on warnings, be less verbose as default
  # Use 'make V=1' to see the full commands
  
@@@ -74,29 -51,6 +74,29 @@@ ifndef KBUILD_VERBOS
    KBUILD_VERBOSE = 0
  endif
  
 +ifeq ($(KBUILD_VERBOSE),1)
 +  quiet =
 +  Q =
 +else
 +  quiet=quiet_
 +  Q = @
 +endif
 +
 +# If the user is running make -s (silent mode), suppress echoing of
 +# commands
 +
 +ifneq ($(filter 4.%,$(MAKE_VERSION)),)        # make-4
 +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
 +  quiet=silent_
 +endif
 +else                                  # make-3.8x
 +ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
 +  quiet=silent_
 +endif
 +endif
 +
 +export quiet Q KBUILD_VERBOSE
 +
  # Call a source code checker (by default, "sparse") as part of the
  # C compilation.
  #
@@@ -172,13 -126,7 +172,13 @@@ PHONY += $(MAKECMDGOALS) sub-mak
  $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
        @:
  
 +# Fake the "Entering directory" message once, so that IDEs/editors are
 +# able to understand relative filenames.
 +       echodir := @echo
 + quiet_echodir := @echo
 +silent_echodir := @:
  sub-make: FORCE
 +      $($(quiet)echodir) "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
        $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
        KBUILD_SRC=$(CURDIR) \
        KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
@@@ -341,6 -289,52 +341,6 @@@ endi
  export KBUILD_MODULES KBUILD_BUILTIN
  export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
  
 -# Beautify output
 -# ---------------------------------------------------------------------------
 -#
 -# Normally, we echo the whole command before executing it. By making
 -# that echo $($(quiet)$(cmd)), we now have the possibility to set
 -# $(quiet) to choose other forms of output instead, e.g.
 -#
 -#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
 -#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
 -#
 -# If $(quiet) is empty, the whole command will be printed.
 -# If it is set to "quiet_", only the short version will be printed.
 -# If it is set to "silent_", nothing will be printed at all, since
 -# the variable $(silent_cmd_cc_o_c) doesn't exist.
 -#
 -# A simple variant is to prefix commands with $(Q) - that's useful
 -# for commands that shall be hidden in non-verbose mode.
 -#
 -#     $(Q)ln $@ :<
 -#
 -# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
 -# If KBUILD_VERBOSE equals 1 then the above command is displayed.
 -
 -ifeq ($(KBUILD_VERBOSE),1)
 -  quiet =
 -  Q =
 -else
 -  quiet=quiet_
 -  Q = @
 -endif
 -
 -# If the user is running make -s (silent mode), suppress echoing of
 -# commands
 -
 -ifneq ($(filter 4.%,$(MAKE_VERSION)),)        # make-4
 -ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
 -  quiet=silent_
 -endif
 -else                                  # make-3.8x
 -ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
 -  quiet=silent_
 -endif
 -endif
 -
 -export quiet Q KBUILD_VERBOSE
 -
  ifneq ($(CC),)
  ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
  COMPILER := clang
@@@ -372,7 -366,6 +372,7 @@@ GENKSYMS   = scripts/genksyms/genksym
  INSTALLKERNEL  := installkernel
  DEPMOD                = /sbin/depmod
  PERL          = perl
 +PYTHON                = python
  CHECK         = sparse
  
  CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
@@@ -423,7 -416,7 +423,7 @@@ KERNELVERSION = $(VERSION)$(if $(PATCHL
  export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
  export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
  export CPP AR NM STRIP OBJCOPY OBJDUMP
 -export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
 +export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
  export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
  
  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
@@@ -622,9 -615,6 +622,9 @@@ els
  KBUILD_CFLAGS += -O2
  endif
  
 +# Tell gcc to never replace conditional load with a non-conditional one
 +KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
 +
  ifdef CONFIG_READABLE_ASM
  # Disable optimizations that make assembler listings hard to read.
  # reorder blocks reorders the control in the function
@@@ -640,22 -630,6 +640,22 @@@ KBUILD_CFLAGS += $(call cc-option,-Wfra
  endif
  
  # Handle stack protector mode.
 +#
 +# Since kbuild can potentially perform two passes (first with the old
 +# .config values and then with updated .config values), we cannot error out
 +# if a desired compiler option is unsupported. If we were to error, kbuild
 +# could never get to the second pass and actually notice that we changed
 +# the option to something that was supported.
 +#
 +# Additionally, we don't want to fallback and/or silently change which compiler
 +# flags will be used, since that leads to producing kernels with different
 +# security feature characteristics depending on the compiler used. ("But I
 +# selected CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!")
 +#
 +# The middle ground is to warn here so that the failed option is obvious, but
 +# to let the build fail with bad compiler flags so that we can't produce a
 +# kernel when there is a CONFIG and compiler mismatch.
 +#
  ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
    stackp-flag := -fstack-protector
    ifeq ($(call cc-option, $(stackp-flag)),)
@@@ -688,7 -662,6 +688,7 @@@ KBUILD_CFLAGS += $(call cc-disable-warn
  # source of a reference will be _MergedGlobals and not on of the whitelisted names.
  # See modpost pattern 2
  KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
  else
  
  # This warning generated too much noise in a regular build.
@@@ -709,19 -682,10 +709,19 @@@ KBUILD_CFLAGS   += -fomit-frame-pointe
  endif
  endif
  
 +KBUILD_CFLAGS   += $(call cc-option, -fno-var-tracking-assignments)
 +
  ifdef CONFIG_DEBUG_INFO
 +ifdef CONFIG_DEBUG_INFO_SPLIT
 +KBUILD_CFLAGS   += $(call cc-option, -gsplit-dwarf, -g)
 +else
  KBUILD_CFLAGS += -g
 +endif
  KBUILD_AFLAGS += -Wa,-gdwarf-2
  endif
 +ifdef CONFIG_DEBUG_INFO_DWARF4
 +KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
 +endif
  
  ifdef CONFIG_DEBUG_INFO_REDUCED
  KBUILD_CFLAGS         += $(call cc-option, -femit-struct-debug-baseonly) \
@@@ -1063,6 -1027,13 +1063,13 @@@ headers_check: headers_instal
        $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
        $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1
  
+ # ---------------------------------------------------------------------------
+ # Kernel selftest
+ PHONY += kselftest
+ kselftest:
+       $(Q)$(MAKE) -C tools/testing/selftests run_tests
  # ---------------------------------------------------------------------------
  # Modules
  
@@@ -1206,7 -1177,7 +1213,7 @@@ distclean: mrprope
  # Packaging of the kernel to various formats
  # ---------------------------------------------------------------------------
  # rpm target kept for backward compatibility
 -package-dir   := $(srctree)/scripts/package
 +package-dir   := scripts/package
  
  %src-pkg: FORCE
        $(Q)$(MAKE) $(build)=$(package-dir) $@
@@@ -1250,9 -1221,9 +1257,9 @@@ help
        @echo  '  tags/TAGS       - Generate tags file for editors'
        @echo  '  cscope          - Generate cscope index'
        @echo  '  gtags           - Generate GNU GLOBAL index'
-       @echo  '  kernelrelease   - Output the release version string'
-       @echo  '  kernelversion   - Output the version stored in Makefile'
-       @echo  '  image_name      - Output the image name'
+       @echo  '  kernelrelease   - Output the release version string (use with make -s)'
+       @echo  '  kernelversion   - Output the version stored in Makefile (use with make -s)'
+       @echo  '  image_name      - Output the image name (use with make -s)'
        @echo  '  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
         echo  '                    (default: $(INSTALL_HDR_PATH))'; \
         echo  ''
        @echo  '  headerdep       - Detect inclusion cycles in headers'
        @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help
        @echo  ''
+       @echo  'Kernel selftest'
+       @echo  '  kselftest       - Build and run kernel selftest (run as root)'
+       @echo  '                    Build, install, and boot kernel before'
+       @echo  '                    running kselftest on it'
+       @echo  ''
        @echo  'Kernel packaging:'
        @$(MAKE) $(build)=$(package-dir) help
        @echo  ''
@@@ -1407,7 -1383,6 +1419,7 @@@ clean: $(clean-dirs
        @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '*.ko.*' \
 +              -o -name '*.dwo'  \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
                -o -name '*.symtypes' -o -name 'modules.order' \
                -o -name modules.builtin -o -name '.tmp_*.o.*' \