浏览代码

Merge tag 'kbuild-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

 - verify depmod is installed before modules_install

 - support build salt in case build ids must be unique between builds

 - allow users to specify additional host compiler flags via HOST*FLAGS,
   and rename internal variables to KBUILD_HOST*FLAGS

 - update buildtar script to drop vax support, add arm64 support

 - update builddeb script for better debarch support

 - document the pit-fall of if_changed usage

 - fix parallel build of UML with O= option

 - make 'samples' target depend on headers_install to fix build errors

 - remove deprecated host-progs variable

 - add a new coccinelle script for refcount_t vs atomic_t check

 - improve double-test coccinelle script

 - misc cleanups and fixes

* tag 'kbuild-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (41 commits)
  coccicheck: return proper error code on fail
  Coccinelle: doubletest: reduce side effect false positives
  kbuild: remove deprecated host-progs variable
  kbuild: make samples really depend on headers_install
  um: clean up archheaders recipe
  kbuild: add %asm-generic to no-dot-config-targets
  um: fix parallel building with O= option
  scripts: Add Python 3 support to tracing/draw_functrace.py
  builddeb: Add automatic support for sh{3,4}{,eb} architectures
  builddeb: Add automatic support for riscv* architectures
  builddeb: Add automatic support for m68k architecture
  builddeb: Add automatic support for or1k architecture
  builddeb: Add automatic support for sparc64 architecture
  builddeb: Add automatic support for mips{,64}r6{,el} architectures
  builddeb: Add automatic support for mips64el architecture
  builddeb: Add automatic support for ppc64 and powerpcspe architectures
  builddeb: Introduce functions to simplify kconfig tests in set_debarch
  builddeb: Drop check for 32-bit s390
  builddeb: Change architecture detection fallback to use dpkg-architecture
  builddeb: Skip architecture detection when KBUILD_DEBARCH is set
  ...
Linus Torvalds 7 年之前
父节点
当前提交
e026bcc561
共有 51 个文件被更改,包括 373 次插入169 次删除
  1. 16 0
      Documentation/kbuild/kbuild.txt
  2. 7 1
      Documentation/kbuild/makefiles.txt
  3. 7 12
      Documentation/process/changes.rst
  4. 13 11
      Makefile
  5. 1 1
      arch/alpha/boot/Makefile
  6. 0 3
      arch/arm/Makefile
  7. 0 25
      arch/arm/mach-at91/Makefile
  8. 3 0
      arch/arm64/kernel/vdso/note.S
  9. 0 1
      arch/openrisc/Makefile
  10. 3 0
      arch/powerpc/kernel/vdso32/note.S
  11. 1 2
      arch/powerpc/purgatory/Makefile
  12. 0 1
      arch/riscv/Makefile
  13. 3 3
      arch/s390/kernel/syscalls/Makefile
  14. 1 2
      arch/s390/purgatory/Makefile
  15. 2 9
      arch/um/Makefile
  16. 2 2
      arch/um/drivers/Makefile
  17. 0 2
      arch/x86/Makefile.um
  18. 3 0
      arch/x86/entry/vdso/vdso-note.S
  19. 3 0
      arch/x86/entry/vdso/vdso32/note.S
  20. 1 2
      arch/x86/purgatory/Makefile
  21. 1 2
      arch/xtensa/boot/Makefile
  22. 20 0
      include/linux/build-salt.h
  23. 9 0
      init/Kconfig
  24. 3 0
      init/version.c
  25. 1 1
      kernel/Makefile
  26. 2 2
      net/bpfilter/Makefile
  27. 11 11
      samples/bpf/Makefile
  28. 3 3
      samples/seccomp/Makefile
  29. 1 0
      scripts/.gitignore
  30. 2 2
      scripts/Kbuild.include
  31. 3 2
      scripts/Makefile
  32. 0 7
      scripts/Makefile.build
  33. 0 1
      scripts/Makefile.clean
  34. 12 12
      scripts/Makefile.host
  35. 3 4
      scripts/Makefile.lib
  36. 0 1
      scripts/basic/.gitignore
  37. 0 1
      scripts/basic/Makefile
  38. 0 0
      scripts/bin2c.c
  39. 3 2
      scripts/coccicheck
  40. 129 0
      scripts/coccinelle/api/atomic_as_refcounter.cocci
  41. 26 8
      scripts/coccinelle/tests/doubletest.cocci
  42. 7 1
      scripts/depmod.sh
  43. 4 4
      scripts/kconfig/Makefile
  44. 3 0
      scripts/mod/modpost.c
  45. 8 4
      scripts/package/buildtar
  46. 50 18
      scripts/package/mkdebian
  47. 1 1
      scripts/tracing/draw_functrace.py
  48. 1 1
      security/tomoyo/Makefile
  49. 1 1
      tools/build/Build.include
  50. 1 1
      tools/build/Makefile
  51. 2 2
      tools/objtool/Makefile

+ 16 - 0
Documentation/kbuild/kbuild.txt

@@ -50,6 +50,22 @@ LDFLAGS_MODULE
 --------------------------------------------------
 --------------------------------------------------
 Additional options used for $(LD) when linking modules.
 Additional options used for $(LD) when linking modules.
 
 
+HOSTCFLAGS
+--------------------------------------------------
+Additional flags to be passed to $(HOSTCC) when building host programs.
+
+HOSTCXXFLAGS
+--------------------------------------------------
+Additional flags to be passed to $(HOSTCXX) when building host programs.
+
+HOSTLDFLAGS
+--------------------------------------------------
+Additional flags to be passed when linking host programs.
+
+HOSTLDLIBS
+--------------------------------------------------
+Additional libraries to link against when building host programs.
+
 KBUILD_KCONFIG
 KBUILD_KCONFIG
 --------------------------------------------------
 --------------------------------------------------
 Set the top-level Kconfig file to the value of this environment
 Set the top-level Kconfig file to the value of this environment

+ 7 - 1
Documentation/kbuild/makefiles.txt

@@ -661,7 +661,7 @@ Both possibilities are described in the following.
 
 
 	When compiling host programs, it is possible to set specific flags.
 	When compiling host programs, it is possible to set specific flags.
 	The programs will always be compiled utilising $(HOSTCC) passed
 	The programs will always be compiled utilising $(HOSTCC) passed
-	the options specified in $(HOSTCFLAGS).
+	the options specified in $(KBUILD_HOSTCFLAGS).
 	To set flags that will take effect for all host programs created
 	To set flags that will take effect for all host programs created
 	in that Makefile, use the variable HOST_EXTRACFLAGS.
 	in that Makefile, use the variable HOST_EXTRACFLAGS.
 
 
@@ -1105,6 +1105,12 @@ When kbuild executes, the following steps are followed (roughly):
 		target: source(s) FORCE
 		target: source(s) FORCE
 	#WRONG!#	$(call if_changed, ld/objcopy/gzip/...)
 	#WRONG!#	$(call if_changed, ld/objcopy/gzip/...)
 
 
+        Note: if_changed should not be used more than once per target.
+              It stores the executed command in a corresponding .cmd
+        file and multiple calls would result in overwrites and
+        unwanted results when the target is up to date and only the
+        tests on changed commands trigger execution of commands.
+
     ld
     ld
 	Link target. Often, LDFLAGS_$@ is used to set specific options to ld.
 	Link target. Often, LDFLAGS_$@ is used to set specific options to ld.
 
 

+ 7 - 12
Documentation/process/changes.rst

@@ -35,7 +35,7 @@ binutils               2.20             ld -v
 flex                   2.5.35           flex --version
 flex                   2.5.35           flex --version
 bison                  2.0              bison --version
 bison                  2.0              bison --version
 util-linux             2.10o            fdformat --version
 util-linux             2.10o            fdformat --version
-module-init-tools      0.9.10           depmod -V
+kmod                   13               depmod -V
 e2fsprogs              1.41.4           e2fsck -V
 e2fsprogs              1.41.4           e2fsck -V
 jfsutils               1.1.3            fsck.jfs -V
 jfsutils               1.1.3            fsck.jfs -V
 reiserfsprogs          3.6.3            reiserfsck -V
 reiserfsprogs          3.6.3            reiserfsck -V
@@ -156,12 +156,6 @@ is not build with ``CONFIG_KALLSYMS`` and you have no way to rebuild and
 reproduce the Oops with that option, then you can still decode that Oops
 reproduce the Oops with that option, then you can still decode that Oops
 with ksymoops.
 with ksymoops.
 
 
-Module-Init-Tools
------------------
-
-A new module loader is now in the kernel that requires ``module-init-tools``
-to use.  It is backward compatible with the 2.4.x series kernels.
-
 Mkinitrd
 Mkinitrd
 --------
 --------
 
 
@@ -371,16 +365,17 @@ Util-linux
 
 
 - <https://www.kernel.org/pub/linux/utils/util-linux/>
 - <https://www.kernel.org/pub/linux/utils/util-linux/>
 
 
+Kmod
+----
+
+- <https://www.kernel.org/pub/linux/utils/kernel/kmod/>
+- <https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git>
+
 Ksymoops
 Ksymoops
 --------
 --------
 
 
 - <https://www.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/>
 - <https://www.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/>
 
 
-Module-Init-Tools
------------------
-
-- <https://www.kernel.org/pub/linux/utils/kernel/module-init-tools/>
-
 Mkinitrd
 Mkinitrd
 --------
 --------
 
 

+ 13 - 11
Makefile

@@ -224,7 +224,7 @@ clean-targets := %clean mrproper cleandocs
 no-dot-config-targets := $(clean-targets) \
 no-dot-config-targets := $(clean-targets) \
 			 cscope gtags TAGS tags help% %docs check% coccicheck \
 			 cscope gtags TAGS tags help% %docs check% coccicheck \
 			 $(version_h) headers_% archheaders archscripts \
 			 $(version_h) headers_% archheaders archscripts \
-			 kernelversion %src-pkg
+			 %asm-generic kernelversion %src-pkg
 
 
 config-targets := 0
 config-targets := 0
 mixed-targets  := 0
 mixed-targets  := 0
@@ -359,11 +359,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 
 
 HOSTCC       = gcc
 HOSTCC       = gcc
 HOSTCXX      = g++
 HOSTCXX      = g++
-HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
-		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS)
-HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS)
-HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS)
-HOST_LOADLIBES := $(HOST_LFS_LIBS)
+KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
+		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
+		$(HOSTCFLAGS)
+KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
+KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
 
 # Make variables (CC, etc...)
 # Make variables (CC, etc...)
 AS		= $(CROSS_COMPILE)as
 AS		= $(CROSS_COMPILE)as
@@ -429,10 +430,10 @@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
 LDFLAGS :=
 LDFLAGS :=
 GCC_PLUGINS_CFLAGS :=
 GCC_PLUGINS_CFLAGS :=
 
 
-export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
-export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
+export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
+export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
 export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
 export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
-export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
+export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
 
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
@@ -1009,9 +1010,10 @@ ifdef CONFIG_GDB_SCRIPTS
 endif
 endif
 	+$(call if_changed,link-vmlinux)
 	+$(call if_changed,link-vmlinux)
 
 
-# Build samples along the rest of the kernel
+# Build samples along the rest of the kernel. This needs headers_install.
 ifdef CONFIG_SAMPLES
 ifdef CONFIG_SAMPLES
 vmlinux-dirs += samples
 vmlinux-dirs += samples
+samples: headers_install
 endif
 endif
 
 
 # The actual objects are generated when descending,
 # The actual objects are generated when descending,
@@ -1116,7 +1118,7 @@ define filechk_version.h
 	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
 	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
 endef
 endef
 
 
-$(version_h): $(srctree)/Makefile FORCE
+$(version_h): FORCE
 	$(call filechk,version.h)
 	$(call filechk,version.h)
 	$(Q)rm -f $(old_version_h)
 	$(Q)rm -f $(old_version_h)
 
 

+ 1 - 1
arch/alpha/boot/Makefile

@@ -14,7 +14,7 @@ targets		:= vmlinux.gz vmlinux \
 		   tools/bootpzh bootloader bootpheader bootpzheader 
 		   tools/bootpzh bootloader bootpheader bootpzheader 
 OBJSTRIP	:= $(obj)/tools/objstrip
 OBJSTRIP	:= $(obj)/tools/objstrip
 
 
-HOSTCFLAGS	:= -Wall -I$(objtree)/usr/include
+KBUILD_HOSTCFLAGS := -Wall -I$(objtree)/usr/include
 BOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
 BOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
 
 
 # SRM bootable image.  Copy to offset 512 of a partition.
 # SRM bootable image.  Copy to offset 512 of a partition.

+ 0 - 3
arch/arm/Makefile

@@ -10,9 +10,6 @@
 #
 #
 # Copyright (C) 1995-2001 by Russell King
 # Copyright (C) 1995-2001 by Russell King
 
 
-# Ensure linker flags are correct
-LDFLAGS		:=
-
 LDFLAGS_vmlinux	:=-p --no-undefined -X --pic-veneer
 LDFLAGS_vmlinux	:=-p --no-undefined -X --pic-veneer
 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
 LDFLAGS_vmlinux	+= --be8
 LDFLAGS_vmlinux	+= --be8

+ 0 - 25
arch/arm/mach-at91/Makefile

@@ -19,31 +19,6 @@ ifeq ($(CONFIG_PM_DEBUG),y)
 CFLAGS_pm.o += -DDEBUG
 CFLAGS_pm.o += -DDEBUG
 endif
 endif
 
 
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
-	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}"
-endef
-
-# Use filechk to avoid rebuilds when a header changes, but the resulting file
-# does not
-define filechk_offsets
-	(set -e; \
-	 echo "#ifndef $2"; \
-	 echo "#define $2"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne $(sed-y); \
-	 echo ""; \
-	 echo "#endif" )
-endef
-
 arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c
 arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c
 	$(call if_changed_dep,cc_s_c)
 	$(call if_changed_dep,cc_s_c)
 
 

+ 3 - 0
arch/arm64/kernel/vdso/note.S

@@ -22,7 +22,10 @@
 #include <linux/uts.h>
 #include <linux/uts.h>
 #include <linux/version.h>
 #include <linux/version.h>
 #include <linux/elfnote.h>
 #include <linux/elfnote.h>
+#include <linux/build-salt.h>
 
 
 ELFNOTE_START(Linux, 0, "a")
 ELFNOTE_START(Linux, 0, "a")
 	.long LINUX_VERSION_CODE
 	.long LINUX_VERSION_CODE
 ELFNOTE_END
 ELFNOTE_END
+
+BUILD_SALT

+ 0 - 1
arch/openrisc/Makefile

@@ -19,7 +19,6 @@
 
 
 KBUILD_DEFCONFIG := or1ksim_defconfig
 KBUILD_DEFCONFIG := or1ksim_defconfig
 
 
-LDFLAGS         :=
 OBJCOPYFLAGS    := -O binary -R .note -R .comment -S
 OBJCOPYFLAGS    := -O binary -R .note -R .comment -S
 LDFLAGS_vmlinux :=
 LDFLAGS_vmlinux :=
 LIBGCC 		:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 LIBGCC 		:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)

+ 3 - 0
arch/powerpc/kernel/vdso32/note.S

@@ -5,6 +5,7 @@
 
 
 #include <linux/uts.h>
 #include <linux/uts.h>
 #include <linux/version.h>
 #include <linux/version.h>
+#include <linux/build-salt.h>
 
 
 #define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type)			      \
 #define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type)			      \
 	.section name, flags;						      \
 	.section name, flags;						      \
@@ -23,3 +24,5 @@
 	ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0)
 	ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0)
 	.long LINUX_VERSION_CODE
 	.long LINUX_VERSION_CODE
 	ASM_ELF_NOTE_END
 	ASM_ELF_NOTE_END
+
+BUILD_SALT

+ 1 - 2
arch/powerpc/purgatory/Makefile

@@ -6,9 +6,8 @@ LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined
 $(obj)/purgatory.ro: $(obj)/trampoline.o FORCE
 $(obj)/purgatory.ro: $(obj)/trampoline.o FORCE
 		$(call if_changed,ld)
 		$(call if_changed,ld)
 
 
-CMD_BIN2C = $(objtree)/scripts/basic/bin2c
 quiet_cmd_bin2c = BIN2C   $@
 quiet_cmd_bin2c = BIN2C   $@
-      cmd_bin2c = $(CMD_BIN2C) kexec_purgatory < $< > $@
+      cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
 
 
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 	$(call if_changed,bin2c)
 	$(call if_changed,bin2c)

+ 0 - 1
arch/riscv/Makefile

@@ -8,7 +8,6 @@
 # for more details.
 # for more details.
 #
 #
 
 
-LDFLAGS         :=
 OBJCOPYFLAGS    := -O binary
 OBJCOPYFLAGS    := -O binary
 LDFLAGS_vmlinux :=
 LDFLAGS_vmlinux :=
 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)

+ 3 - 3
arch/s390/kernel/syscalls/Makefile

@@ -25,15 +25,15 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
 	  $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
 	  $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
 
 
 define filechk_syshdr
 define filechk_syshdr
-	$(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2"
+	$(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2" < $<
 endef
 endef
 
 
 define filechk_sysnr
 define filechk_sysnr
-	$(CONFIG_SHELL) '$(systbl)' -N -a $(sysnr_abi_$(basetarget))
+	$(CONFIG_SHELL) '$(systbl)' -N -a $(sysnr_abi_$(basetarget)) < $<
 endef
 endef
 
 
 define filechk_syscalls
 define filechk_syscalls
-	$(CONFIG_SHELL) '$(systbl)' -S
+	$(CONFIG_SHELL) '$(systbl)' -S < $<
 endef
 endef
 
 
 syshdr_abi_unistd_32 := common,32
 syshdr_abi_unistd_32 := common,32

+ 1 - 2
arch/s390/purgatory/Makefile

@@ -28,9 +28,8 @@ KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
 		$(call if_changed,ld)
 		$(call if_changed,ld)
 
 
-CMD_BIN2C = $(objtree)/scripts/basic/bin2c
 quiet_cmd_bin2c = BIN2C   $@
 quiet_cmd_bin2c = BIN2C   $@
-      cmd_bin2c = $(CMD_BIN2C) kexec_purgatory < $< > $@
+      cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
 
 
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 	$(call if_changed,bin2c)
 	$(call if_changed,bin2c)

+ 2 - 9
arch/um/Makefile

@@ -116,14 +116,7 @@ endef
 KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
 KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
 
 
 archheaders:
 archheaders:
-	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
-	            kbuild-file=$(HOST_DIR)/include/asm/Kbuild \
-		    obj=$(HOST_DIR)/include/generated/asm
-	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
-	            kbuild-file=$(HOST_DIR)/include/uapi/asm/Kbuild \
-		    obj=$(HOST_DIR)/include/generated/uapi/asm
-	$(Q)$(MAKE) KBUILD_SRC= ARCH=$(HEADER_ARCH) archheaders
-
+	$(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders
 
 
 archprepare: include/generated/user_constants.h
 archprepare: include/generated/user_constants.h
 
 
@@ -169,7 +162,7 @@ define filechk_gen-asm-offsets
          echo " *"; \
          echo " *"; \
          echo " */"; \
          echo " */"; \
          echo ""; \
          echo ""; \
-         sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
+         sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" < $<; \
          echo ""; )
          echo ""; )
 endef
 endef
 
 

+ 2 - 2
arch/um/drivers/Makefile

@@ -25,10 +25,10 @@ LDFLAGS_vde.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a)
 targets := pcap_kern.o pcap_user.o vde_kern.o vde_user.o
 targets := pcap_kern.o pcap_user.o vde_kern.o vde_user.o
 
 
 $(obj)/pcap.o: $(obj)/pcap_kern.o $(obj)/pcap_user.o
 $(obj)/pcap.o: $(obj)/pcap_kern.o $(obj)/pcap_user.o
-	$(LD) -r -dp -o $@ $^ $(LDFLAGS) $(LDFLAGS_pcap.o)
+	$(LD) -r -dp -o $@ $^ $(ld_flags)
 
 
 $(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o
 $(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o
-	$(LD) -r -dp -o $@ $^ $(LDFLAGS) $(LDFLAGS_vde.o)
+	$(LD) -r -dp -o $@ $^ $(ld_flags)
 
 
 #XXX: The call below does not work because the flags are added before the
 #XXX: The call below does not work because the flags are added before the
 # object name, so nothing from the library gets linked.
 # object name, so nothing from the library gets linked.

+ 0 - 2
arch/x86/Makefile.um

@@ -13,8 +13,6 @@ KBUILD_CFLAGS		+= $(call cc-option,-m32)
 KBUILD_AFLAGS		+= $(call cc-option,-m32)
 KBUILD_AFLAGS		+= $(call cc-option,-m32)
 LINK-y			+= $(call cc-option,-m32)
 LINK-y			+= $(call cc-option,-m32)
 
 
-export LDFLAGS
-
 LDS_EXTRA		:= -Ui386
 LDS_EXTRA		:= -Ui386
 export LDS_EXTRA
 export LDS_EXTRA
 
 

+ 3 - 0
arch/x86/entry/vdso/vdso-note.S

@@ -3,6 +3,7 @@
  * Here we can supply some information useful to userland.
  * Here we can supply some information useful to userland.
  */
  */
 
 
+#include <linux/build-salt.h>
 #include <linux/uts.h>
 #include <linux/uts.h>
 #include <linux/version.h>
 #include <linux/version.h>
 #include <linux/elfnote.h>
 #include <linux/elfnote.h>
@@ -10,3 +11,5 @@
 ELFNOTE_START(Linux, 0, "a")
 ELFNOTE_START(Linux, 0, "a")
 	.long LINUX_VERSION_CODE
 	.long LINUX_VERSION_CODE
 ELFNOTE_END
 ELFNOTE_END
+
+BUILD_SALT

+ 3 - 0
arch/x86/entry/vdso/vdso32/note.S

@@ -4,6 +4,7 @@
  * Here we can supply some information useful to userland.
  * Here we can supply some information useful to userland.
  */
  */
 
 
+#include <linux/build-salt.h>
 #include <linux/version.h>
 #include <linux/version.h>
 #include <linux/elfnote.h>
 #include <linux/elfnote.h>
 
 
@@ -14,6 +15,8 @@ ELFNOTE_START(Linux, 0, "a")
 	.long LINUX_VERSION_CODE
 	.long LINUX_VERSION_CODE
 ELFNOTE_END
 ELFNOTE_END
 
 
+BUILD_SALT
+
 #ifdef CONFIG_XEN
 #ifdef CONFIG_XEN
 /*
 /*
  * Add a special note telling glibc's dynamic linker a fake hardware
  * Add a special note telling glibc's dynamic linker a fake hardware

+ 1 - 2
arch/x86/purgatory/Makefile

@@ -28,9 +28,8 @@ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
 
 
 targets += kexec-purgatory.c
 targets += kexec-purgatory.c
 
 
-CMD_BIN2C = $(objtree)/scripts/basic/bin2c
 quiet_cmd_bin2c = BIN2C   $@
 quiet_cmd_bin2c = BIN2C   $@
-      cmd_bin2c = $(CMD_BIN2C) kexec_purgatory < $< > $@
+      cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
 
 
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
 	$(call if_changed,bin2c)
 	$(call if_changed,bin2c)

+ 1 - 2
arch/xtensa/boot/Makefile

@@ -30,8 +30,7 @@ Image: boot-elf
 zImage: boot-redboot
 zImage: boot-redboot
 uImage: $(obj)/uImage
 uImage: $(obj)/uImage
 
 
-boot-elf boot-redboot: $(addprefix $(obj)/,$(subdir-y)) \
-		       $(addprefix $(obj)/,$(host-progs))
+boot-elf boot-redboot: $(addprefix $(obj)/,$(subdir-y))
 	$(Q)$(MAKE) $(build)=$(obj)/$@ $(MAKECMDGOALS)
 	$(Q)$(MAKE) $(build)=$(obj)/$@ $(MAKECMDGOALS)
 
 
 OBJCOPYFLAGS = --strip-all -R .comment -R .note.gnu.build-id -O binary
 OBJCOPYFLAGS = --strip-all -R .comment -R .note.gnu.build-id -O binary

+ 20 - 0
include/linux/build-salt.h

@@ -0,0 +1,20 @@
+#ifndef __BUILD_SALT_H
+#define __BUILD_SALT_H
+
+#include <linux/elfnote.h>
+
+#define LINUX_ELFNOTE_BUILD_SALT       0x100
+
+#ifdef __ASSEMBLER__
+
+#define BUILD_SALT \
+       ELFNOTE(Linux, LINUX_ELFNOTE_BUILD_SALT, .asciz CONFIG_BUILD_SALT)
+
+#else
+
+#define BUILD_SALT \
+       ELFNOTE32("Linux", LINUX_ELFNOTE_BUILD_SALT, CONFIG_BUILD_SALT)
+
+#endif
+
+#endif /* __BUILD_SALT_H */

+ 9 - 0
init/Kconfig

@@ -107,6 +107,15 @@ config LOCALVERSION_AUTO
 
 
 	  which is done within the script "scripts/setlocalversion".)
 	  which is done within the script "scripts/setlocalversion".)
 
 
+config BUILD_SALT
+       string "Build ID Salt"
+       default ""
+       help
+          The build ID is used to link binaries and their debug info. Setting
+          this option will use the value in the calculation of the build id.
+          This is mostly useful for distributions which want to ensure the
+          build is unique between builds. It's safe to leave the default.
+
 config HAVE_KERNEL_GZIP
 config HAVE_KERNEL_GZIP
 	bool
 	bool
 
 

+ 3 - 0
init/version.c

@@ -7,6 +7,7 @@
  */
  */
 
 
 #include <generated/compile.h>
 #include <generated/compile.h>
+#include <linux/build-salt.h>
 #include <linux/export.h>
 #include <linux/export.h>
 #include <linux/uts.h>
 #include <linux/uts.h>
 #include <linux/utsname.h>
 #include <linux/utsname.h>
@@ -49,3 +50,5 @@ const char linux_proc_banner[] =
 	"%s version %s"
 	"%s version %s"
 	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
 	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
 	" (" LINUX_COMPILER ") %s\n";
 	" (" LINUX_COMPILER ") %s\n";
+
+BUILD_SALT;

+ 1 - 1
kernel/Makefile

@@ -123,7 +123,7 @@ targets += config_data.gz
 $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
 $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
 	$(call if_changed,gzip)
 	$(call if_changed,gzip)
 
 
-      filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
+      filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/bin2c; echo "MAGIC_END;")
 targets += config_data.h
 targets += config_data.h
 $(obj)/config_data.h: $(obj)/config_data.gz FORCE
 $(obj)/config_data.h: $(obj)/config_data.gz FORCE
 	$(call filechk,ikconfiggz)
 	$(call filechk,ikconfiggz)

+ 2 - 2
net/bpfilter/Makefile

@@ -5,14 +5,14 @@
 
 
 hostprogs-y := bpfilter_umh
 hostprogs-y := bpfilter_umh
 bpfilter_umh-objs := main.o
 bpfilter_umh-objs := main.o
-HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
+KBUILD_HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
 HOSTCC := $(CC)
 HOSTCC := $(CC)
 
 
 ifeq ($(CONFIG_BPFILTER_UMH), y)
 ifeq ($(CONFIG_BPFILTER_UMH), y)
 # builtin bpfilter_umh should be compiled with -static
 # builtin bpfilter_umh should be compiled with -static
 # since rootfs isn't mounted at the time of __init
 # since rootfs isn't mounted at the time of __init
 # function is called and do_execv won't find elf interpreter
 # function is called and do_execv won't find elf interpreter
-HOSTLDFLAGS += -static
+KBUILD_HOSTLDFLAGS += -static
 endif
 endif
 
 
 $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
 $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh

+ 11 - 11
samples/bpf/Makefile

@@ -164,11 +164,11 @@ always += xdpsock_kern.o
 always += xdp_fwd_kern.o
 always += xdp_fwd_kern.o
 always += task_fd_query_kern.o
 always += task_fd_query_kern.o
 
 
-HOSTCFLAGS += -I$(objtree)/usr/include
-HOSTCFLAGS += -I$(srctree)/tools/lib/
-HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
-HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
-HOSTCFLAGS += -I$(srctree)/tools/perf
+KBUILD_HOSTCFLAGS += -I$(objtree)/usr/include
+KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/
+KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
+KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
+KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf
 
 
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
 HOSTCFLAGS_trace_helpers.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_trace_helpers.o += -I$(srctree)/tools/lib/bpf/
@@ -180,12 +180,12 @@ HOSTCFLAGS_trace_event_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_sampleip_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_sampleip_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_task_fd_query_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_task_fd_query_user.o += -I$(srctree)/tools/lib/bpf/
 
 
-HOST_LOADLIBES		+= $(LIBBPF) -lelf
-HOSTLOADLIBES_tracex4		+= -lrt
-HOSTLOADLIBES_trace_output	+= -lrt
-HOSTLOADLIBES_map_perf_test	+= -lrt
-HOSTLOADLIBES_test_overhead	+= -lrt
-HOSTLOADLIBES_xdpsock		+= -pthread
+KBUILD_HOSTLDLIBS		+= $(LIBBPF) -lelf
+HOSTLDLIBS_tracex4		+= -lrt
+HOSTLDLIBS_trace_output	+= -lrt
+HOSTLDLIBS_map_perf_test	+= -lrt
+HOSTLDLIBS_test_overhead	+= -lrt
+HOSTLDLIBS_xdpsock		+= -pthread
 
 
 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang

+ 3 - 3
samples/seccomp/Makefile

@@ -30,9 +30,9 @@ HOSTCFLAGS_bpf-direct.o += $(MFLAG)
 HOSTCFLAGS_dropper.o += $(MFLAG)
 HOSTCFLAGS_dropper.o += $(MFLAG)
 HOSTCFLAGS_bpf-helper.o += $(MFLAG)
 HOSTCFLAGS_bpf-helper.o += $(MFLAG)
 HOSTCFLAGS_bpf-fancy.o += $(MFLAG)
 HOSTCFLAGS_bpf-fancy.o += $(MFLAG)
-HOSTLOADLIBES_bpf-direct += $(MFLAG)
-HOSTLOADLIBES_bpf-fancy += $(MFLAG)
-HOSTLOADLIBES_dropper += $(MFLAG)
+HOSTLDLIBS_bpf-direct += $(MFLAG)
+HOSTLDLIBS_bpf-fancy += $(MFLAG)
+HOSTLDLIBS_dropper += $(MFLAG)
 endif
 endif
 always := $(hostprogs-m)
 always := $(hostprogs-m)
 endif
 endif

+ 1 - 0
scripts/.gitignore

@@ -1,6 +1,7 @@
 #
 #
 # Generated files
 # Generated files
 #
 #
+bin2c
 conmakehash
 conmakehash
 kallsyms
 kallsyms
 pnmtologo
 pnmtologo

+ 2 - 2
scripts/Kbuild.include

@@ -56,7 +56,7 @@ kecho := $($(quiet)kecho)
 define filechk
 define filechk
 	$(Q)set -e;				\
 	$(Q)set -e;				\
 	mkdir -p $(dir $@);			\
 	mkdir -p $(dir $@);			\
-	$(filechk_$(1)) < $< > $@.tmp;		\
+	$(filechk_$(1)) > $@.tmp;		\
 	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
 	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
 		rm -f $@.tmp;			\
 		rm -f $@.tmp;			\
 	else					\
 	else					\
@@ -126,7 +126,7 @@ cc-option = $(call __cc-option, $(CC),\
 # hostcc-option
 # hostcc-option
 # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
 # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
 hostcc-option = $(call __cc-option, $(HOSTCC),\
 hostcc-option = $(call __cc-option, $(HOSTCC),\
-	$(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
+	$(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
 
 
 # cc-option-yn
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)

+ 3 - 2
scripts/Makefile

@@ -10,6 +10,7 @@
 
 
 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
 
 
+hostprogs-$(CONFIG_BUILD_BIN2C)  += bin2c
 hostprogs-$(CONFIG_KALLSYMS)     += kallsyms
 hostprogs-$(CONFIG_KALLSYMS)     += kallsyms
 hostprogs-$(CONFIG_LOGO)         += pnmtologo
 hostprogs-$(CONFIG_LOGO)         += pnmtologo
 hostprogs-$(CONFIG_VT)           += conmakehash
 hostprogs-$(CONFIG_VT)           += conmakehash
@@ -22,8 +23,8 @@ hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
 
 
 HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
 HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
 HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
 HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
-HOSTLOADLIBES_sign-file = -lcrypto
-HOSTLOADLIBES_extract-cert = -lcrypto
+HOSTLDLIBS_sign-file = -lcrypto
+HOSTLDLIBS_extract-cert = -lcrypto
 
 
 always		:= $(hostprogs-y) $(hostprogs-m)
 always		:= $(hostprogs-y) $(hostprogs-m)
 
 

+ 0 - 7
scripts/Makefile.build

@@ -53,13 +53,6 @@ endif
 
 
 include scripts/Makefile.lib
 include scripts/Makefile.lib
 
 
-ifdef host-progs
-ifneq ($(hostprogs-y),$(host-progs))
-$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
-hostprogs-y += $(host-progs)
-endif
-endif
-
 # Do not include host rules unless needed
 # Do not include host rules unless needed
 ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
 ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
 include scripts/Makefile.host
 include scripts/Makefile.host

+ 0 - 1
scripts/Makefile.clean

@@ -38,7 +38,6 @@ subdir-ymn	:= $(addprefix $(obj)/,$(subdir-ymn))
 
 
 __clean-files	:= $(extra-y) $(extra-m) $(extra-)       \
 __clean-files	:= $(extra-y) $(extra-m) $(extra-)       \
 		   $(always) $(targets) $(clean-files)   \
 		   $(always) $(targets) $(clean-files)   \
-		   $(host-progs)                         \
 		   $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
 		   $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
 		   $(hostlibs-y) $(hostlibs-m) $(hostlibs-) \
 		   $(hostlibs-y) $(hostlibs-m) $(hostlibs-) \
 		   $(hostcxxlibs-y) $(hostcxxlibs-m)
 		   $(hostcxxlibs-y) $(hostcxxlibs-m)

+ 12 - 12
scripts/Makefile.host

@@ -62,9 +62,9 @@ host-cxxshobjs	:= $(addprefix $(obj)/,$(host-cxxshobjs))
 #####
 #####
 # Handle options to gcc. Support building with separate output directory
 # Handle options to gcc. Support building with separate output directory
 
 
-_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
+_hostc_flags   = $(KBUILD_HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
                  $(HOSTCFLAGS_$(basetarget).o)
                  $(HOSTCFLAGS_$(basetarget).o)
-_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
+_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
                  $(HOSTCXXFLAGS_$(basetarget).o)
                  $(HOSTCXXFLAGS_$(basetarget).o)
 
 
 ifeq ($(KBUILD_SRC),)
 ifeq ($(KBUILD_SRC),)
@@ -84,17 +84,17 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
 # Create executable from a single .c file
 # Create executable from a single .c file
 # host-csingle -> Executable
 # host-csingle -> Executable
 quiet_cmd_host-csingle 	= HOSTCC  $@
 quiet_cmd_host-csingle 	= HOSTCC  $@
-      cmd_host-csingle	= $(HOSTCC) $(hostc_flags) $(HOSTLDFLAGS) -o $@ $< \
-	  	$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+      cmd_host-csingle	= $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \
+		$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-csingle): $(obj)/%: $(src)/%.c FORCE
 $(host-csingle): $(obj)/%: $(src)/%.c FORCE
 	$(call if_changed_dep,host-csingle)
 	$(call if_changed_dep,host-csingle)
 
 
 # Link an executable based on list of .o files, all plain c
 # Link an executable based on list of .o files, all plain c
 # host-cmulti -> executable
 # host-cmulti -> executable
 quiet_cmd_host-cmulti	= HOSTLD  $@
 quiet_cmd_host-cmulti	= HOSTLD  $@
-      cmd_host-cmulti	= $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
+      cmd_host-cmulti	= $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \
 			  $(addprefix $(obj)/,$($(@F)-objs)) \
 			  $(addprefix $(obj)/,$($(@F)-objs)) \
-			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+			  $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-cmulti): FORCE
 $(host-cmulti): FORCE
 	$(call if_changed,host-cmulti)
 	$(call if_changed,host-cmulti)
 $(call multi_depend, $(host-cmulti), , -objs)
 $(call multi_depend, $(host-cmulti), , -objs)
@@ -109,10 +109,10 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
 # Link an executable based on list of .o files, a mixture of .c and .cc
 # Link an executable based on list of .o files, a mixture of .c and .cc
 # host-cxxmulti -> executable
 # host-cxxmulti -> executable
 quiet_cmd_host-cxxmulti	= HOSTLD  $@
 quiet_cmd_host-cxxmulti	= HOSTLD  $@
-      cmd_host-cxxmulti	= $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
+      cmd_host-cxxmulti	= $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \
 			  $(foreach o,objs cxxobjs,\
 			  $(foreach o,objs cxxobjs,\
 			  $(addprefix $(obj)/,$($(@F)-$(o)))) \
 			  $(addprefix $(obj)/,$($(@F)-$(o)))) \
-			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+			  $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-cxxmulti): FORCE
 $(host-cxxmulti): FORCE
 	$(call if_changed,host-cxxmulti)
 	$(call if_changed,host-cxxmulti)
 $(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
 $(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
@@ -143,9 +143,9 @@ $(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
 # Link a shared library, based on position independent .o files
 # Link a shared library, based on position independent .o files
 # *.o -> .so shared library (host-cshlib)
 # *.o -> .so shared library (host-cshlib)
 quiet_cmd_host-cshlib	= HOSTLLD -shared $@
 quiet_cmd_host-cshlib	= HOSTLLD -shared $@
-      cmd_host-cshlib	= $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
+      cmd_host-cshlib	= $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
 			  $(addprefix $(obj)/,$($(@F:.so=-objs))) \
 			  $(addprefix $(obj)/,$($(@F:.so=-objs))) \
-			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+			  $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-cshlib): FORCE
 $(host-cshlib): FORCE
 	$(call if_changed,host-cshlib)
 	$(call if_changed,host-cshlib)
 $(call multi_depend, $(host-cshlib), .so, -objs)
 $(call multi_depend, $(host-cshlib), .so, -objs)
@@ -153,9 +153,9 @@ $(call multi_depend, $(host-cshlib), .so, -objs)
 # Link a shared library, based on position independent .o files
 # Link a shared library, based on position independent .o files
 # *.o -> .so shared library (host-cxxshlib)
 # *.o -> .so shared library (host-cxxshlib)
 quiet_cmd_host-cxxshlib	= HOSTLLD -shared $@
 quiet_cmd_host-cxxshlib	= HOSTLLD -shared $@
-      cmd_host-cxxshlib	= $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
+      cmd_host-cxxshlib	= $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
 			  $(addprefix $(obj)/,$($(@F:.so=-objs))) \
 			  $(addprefix $(obj)/,$($(@F:.so=-objs))) \
-			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+			  $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-cxxshlib): FORCE
 $(host-cxxshlib): FORCE
 	$(call if_changed,host-cxxshlib)
 	$(call if_changed,host-cxxshlib)
 $(call multi_depend, $(host-cxxshlib), .so, -objs)
 $(call multi_depend, $(host-cxxshlib), .so, -objs)

+ 3 - 4
scripts/Makefile.lib

@@ -162,7 +162,7 @@ a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 		 $(__cpp_flags)
 		 $(__cpp_flags)
 
 
-ld_flags       = $(LDFLAGS) $(ldflags-y)
+ld_flags       = $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
 
 
 DTC_INCLUDE    := $(srctree)/scripts/dtc/include-prefixes
 DTC_INCLUDE    := $(srctree)/scripts/dtc/include-prefixes
 
 
@@ -225,8 +225,7 @@ $(obj)/%: $(src)/%_shipped
 # ---------------------------------------------------------------------------
 # ---------------------------------------------------------------------------
 
 
 quiet_cmd_ld = LD      $@
 quiet_cmd_ld = LD      $@
-cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
-	       $(filter-out FORCE,$^) -o $@
+cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@
 
 
 # Objcopy
 # Objcopy
 # ---------------------------------------------------------------------------
 # ---------------------------------------------------------------------------
@@ -416,7 +415,7 @@ define filechk_offsets
 	 echo " * This file was generated by Kbuild"; \
 	 echo " * This file was generated by Kbuild"; \
 	 echo " */"; \
 	 echo " */"; \
 	 echo ""; \
 	 echo ""; \
-	 sed -ne $(sed-offsets); \
+	 sed -ne $(sed-offsets) < $<; \
 	 echo ""; \
 	 echo ""; \
 	 echo "#endif" )
 	 echo "#endif" )
 endef
 endef

+ 0 - 1
scripts/basic/.gitignore

@@ -1,2 +1 @@
 fixdep
 fixdep
-bin2c

+ 0 - 1
scripts/basic/Makefile

@@ -9,7 +9,6 @@
 # fixdep: 	 Used to generate dependency information during build process
 # fixdep: 	 Used to generate dependency information during build process
 
 
 hostprogs-y	:= fixdep
 hostprogs-y	:= fixdep
-hostprogs-$(CONFIG_BUILD_BIN2C)     += bin2c
 always		:= $(hostprogs-y)
 always		:= $(hostprogs-y)
 
 
 # fixdep is needed to compile other host programs
 # fixdep is needed to compile other host programs

+ 0 - 0
scripts/basic/bin2c.c → scripts/bin2c.c


+ 3 - 2
scripts/coccicheck

@@ -128,9 +128,10 @@ run_cmd_parmap() {
 	fi
 	fi
 	echo $@ >>$DEBUG_FILE
 	echo $@ >>$DEBUG_FILE
 	$@ 2>>$DEBUG_FILE
 	$@ 2>>$DEBUG_FILE
-	if [[ $? -ne 0 ]]; then
+	err=$?
+	if [[ $err -ne 0 ]]; then
 		echo "coccicheck failed"
 		echo "coccicheck failed"
-		exit $?
+		exit $err
 	fi
 	fi
 }
 }
 
 

+ 129 - 0
scripts/coccinelle/api/atomic_as_refcounter.cocci

@@ -0,0 +1,129 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+(
+ fname@p2(a, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+y=a
+...
+fname@p2(y, ...);
+
+
+@script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)

+ 26 - 8
scripts/coccinelle/tests/doubletest.cocci

@@ -1,6 +1,7 @@
 /// Find &&/|| operations that include the same argument more than once
 /// Find &&/|| operations that include the same argument more than once
-//# A common source of false positives is when the argument performs a side
-//# effect.
+//# A common source of false positives is when the expression, or
+//# another expresssion in the same && or || operation, performs a
+//# side effect.
 ///
 ///
 // Confidence: Moderate
 // Confidence: Moderate
 // Copyright: (C) 2010 Nicolas Palix, DIKU.  GPLv2.
 // Copyright: (C) 2010 Nicolas Palix, DIKU.  GPLv2.
@@ -20,20 +21,37 @@ position p;
 @@
 @@
 
 
 (
 (
-* E@p
-  || ... || E
+ E@p || ... || E
 |
 |
-* E@p
-  && ... && E
+ E@p && ... && E
 )
 )
 
 
-@script:python depends on org@
+@bad@
+expression r.E,e1,e2,fn;
+position r.p;
+assignment operator op;
+@@
+
+(
+E@p
+&
+ <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+>
+)
+
+@depends on context && !bad@
+expression r.E;
+position r.p;
+@@
+
+*E@p
+
+@script:python depends on org && !bad@
 p << r.p;
 p << r.p;
 @@
 @@
 
 
 cocci.print_main("duplicated argument to && or ||",p)
 cocci.print_main("duplicated argument to && or ||",p)
 
 
-@script:python depends on report@
+@script:python depends on report && !bad@
 p << r.p;
 p << r.p;
 @@
 @@
 
 

+ 7 - 1
scripts/depmod.sh

@@ -10,10 +10,16 @@ fi
 DEPMOD=$1
 DEPMOD=$1
 KERNELRELEASE=$2
 KERNELRELEASE=$2
 
 
-if ! test -r System.map -a -x "$DEPMOD"; then
+if ! test -r System.map ; then
 	exit 0
 	exit 0
 fi
 fi
 
 
+if [ -z $(command -v $DEPMOD) ]; then
+	echo "'make modules_install' requires $DEPMOD. Please install it." >&2
+	echo "This is probably in the kmod package." >&2
+	exit 1
+fi
+
 # older versions of depmod require the version string to start with three
 # older versions of depmod require the version string to start with three
 # numbers, so we cheat with a symlink here
 # numbers, so we cheat with a symlink here
 depmod_hack_needed=true
 depmod_hack_needed=true

+ 4 - 4
scripts/kconfig/Makefile

@@ -169,7 +169,7 @@ HOSTCFLAGS_zconf.tab.o	:= -I$(src)
 hostprogs-y	+= nconf
 hostprogs-y	+= nconf
 nconf-objs	:= nconf.o zconf.tab.o nconf.gui.o
 nconf-objs	:= nconf.o zconf.tab.o nconf.gui.o
 
 
-HOSTLOADLIBES_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
+HOSTLDLIBS_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
 HOSTCFLAGS_nconf.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
 HOSTCFLAGS_nconf.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
 HOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
 HOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
 
 
@@ -180,7 +180,7 @@ hostprogs-y	+= mconf
 lxdialog	:= checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
 lxdialog	:= checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
 mconf-objs	:= mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
 mconf-objs	:= mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
 
 
-HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
+HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
 $(foreach f, mconf.o $(lxdialog), \
 $(foreach f, mconf.o $(lxdialog), \
   $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
   $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
 
 
@@ -191,7 +191,7 @@ hostprogs-y	+= qconf
 qconf-cxxobjs	:= qconf.o
 qconf-cxxobjs	:= qconf.o
 qconf-objs	:= zconf.tab.o
 qconf-objs	:= zconf.tab.o
 
 
-HOSTLOADLIBES_qconf	= $(shell . $(obj)/.qconf-cfg && echo $$libs)
+HOSTLDLIBS_qconf	= $(shell . $(obj)/.qconf-cfg && echo $$libs)
 HOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/.qconf-cfg && echo $$cflags)
 HOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/.qconf-cfg && echo $$cflags)
 
 
 $(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
 $(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
@@ -206,7 +206,7 @@ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
 hostprogs-y	+= gconf
 hostprogs-y	+= gconf
 gconf-objs	:= gconf.o zconf.tab.o
 gconf-objs	:= gconf.o zconf.tab.o
 
 
-HOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
+HOSTLDLIBS_gconf    = $(shell . $(obj)/.gconf-cfg && echo $$libs)
 HOSTCFLAGS_gconf.o  = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
 HOSTCFLAGS_gconf.o  = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
 
 
 $(obj)/gconf.o: $(obj)/.gconf-cfg
 $(obj)/gconf.o: $(obj)/.gconf-cfg

+ 3 - 0
scripts/mod/modpost.c

@@ -2125,10 +2125,13 @@ static int check_modname_len(struct module *mod)
  **/
  **/
 static void add_header(struct buffer *b, struct module *mod)
 static void add_header(struct buffer *b, struct module *mod)
 {
 {
+	buf_printf(b, "#include <linux/build-salt.h>\n");
 	buf_printf(b, "#include <linux/module.h>\n");
 	buf_printf(b, "#include <linux/module.h>\n");
 	buf_printf(b, "#include <linux/vermagic.h>\n");
 	buf_printf(b, "#include <linux/vermagic.h>\n");
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "\n");
 	buf_printf(b, "\n");
+	buf_printf(b, "BUILD_SALT;\n");
+	buf_printf(b, "\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 	buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
 	buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
 	buf_printf(b, "\n");
 	buf_printf(b, "\n");

+ 8 - 4
scripts/package/buildtar

@@ -84,10 +84,6 @@ case "${ARCH}" in
 		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
 		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
 		[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
 		[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
 		;;
 		;;
-	vax)
-		[ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
-		[ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
-		;;
 	mips)
 	mips)
 		if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
 		if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
 			cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
 			cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
@@ -109,6 +105,14 @@ case "${ARCH}" in
 			cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
 			cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
 		fi
 		fi
 		;;
 		;;
+	arm64)
+		for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do
+			if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
+				cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
+				break
+			fi
+		done
+		;;
 	*)
 	*)
 		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
 		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
 		echo "" >&2
 		echo "" >&2

+ 50 - 18
scripts/package/mkdebian

@@ -6,49 +6,81 @@
 
 
 set -e
 set -e
 
 
+is_enabled() {
+	grep -q "^CONFIG_$1=y" $KCONFIG_CONFIG
+}
+
+if_enabled_echo() {
+	if is_enabled "$1"; then
+		echo -n "$2"
+	elif [ $# -ge 3 ]; then
+		echo -n "$3"
+	fi
+}
+
 set_debarch() {
 set_debarch() {
+	if [ -n "$KBUILD_DEBARCH" ] ; then
+		debarch="$KBUILD_DEBARCH"
+		return
+	fi
+
 	# Attempt to find the correct Debian architecture
 	# Attempt to find the correct Debian architecture
 	case "$UTS_MACHINE" in
 	case "$UTS_MACHINE" in
-	i386|ia64|alpha)
+	i386|ia64|alpha|m68k|riscv*)
 		debarch="$UTS_MACHINE" ;;
 		debarch="$UTS_MACHINE" ;;
 	x86_64)
 	x86_64)
 		debarch=amd64 ;;
 		debarch=amd64 ;;
 	sparc*)
 	sparc*)
-		debarch=sparc ;;
+		debarch=sparc$(if_enabled_echo 64BIT 64) ;;
 	s390*)
 	s390*)
-		debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;;
+		debarch=s390x ;;
 	ppc*)
 	ppc*)
-		debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;;
+		if is_enabled 64BIT; then
+			debarch=ppc64$(if_enabled_echo CPU_LITTLE_ENDIAN el)
+		else
+			debarch=powerpc$(if_enabled_echo SPE spe)
+		fi
+		;;
 	parisc*)
 	parisc*)
 		debarch=hppa ;;
 		debarch=hppa ;;
 	mips*)
 	mips*)
-		debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;;
+		if is_enabled CPU_LITTLE_ENDIAN; then
+			debarch=mips$(if_enabled_echo 64BIT 64)$(if_enabled_echo CPU_MIPSR6 r6)el
+		elif is_enabled CPU_MIPSR6; then
+			debarch=mips$(if_enabled_echo 64BIT 64)r6
+		else
+			debarch=mips
+		fi
+		;;
 	aarch64|arm64)
 	aarch64|arm64)
 		debarch=arm64 ;;
 		debarch=arm64 ;;
 	arm*)
 	arm*)
-		if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
-		    if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then
-			debarch=armhf
-		    else
-			debarch=armel
-		    fi
+		if is_enabled AEABI; then
+			debarch=arm$(if_enabled_echo VFP hf el)
 		else
 		else
-		    debarch=arm
+			debarch=arm
+		fi
+		;;
+	openrisc)
+		debarch=or1k ;;
+	sh)
+		if is_enabled CPU_SH3; then
+			debarch=sh3$(if_enabled_echo CPU_BIG_ENDIAN eb)
+		elif is_enabled CPU_SH4; then
+			debarch=sh4$(if_enabled_echo CPU_BIG_ENDIAN eb)
 		fi
 		fi
 		;;
 		;;
-	*)
-		debarch=$(dpkg --print-architecture)
+	esac
+	if [ -z "$debarch" ]; then
+		debarch=$(dpkg-architecture -qDEB_HOST_ARCH)
 		echo "" >&2
 		echo "" >&2
 		echo "** ** **  WARNING  ** ** **" >&2
 		echo "** ** **  WARNING  ** ** **" >&2
 		echo "" >&2
 		echo "" >&2
 		echo "Your architecture doesn't have its equivalent" >&2
 		echo "Your architecture doesn't have its equivalent" >&2
 		echo "Debian userspace architecture defined!" >&2
 		echo "Debian userspace architecture defined!" >&2
-		echo "Falling back to using your current userspace instead!" >&2
+		echo "Falling back to the current host architecture ($debarch)." >&2
 		echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
 		echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
 		echo "" >&2
 		echo "" >&2
-	esac
-	if [ -n "$KBUILD_DEBARCH" ] ; then
-		debarch="$KBUILD_DEBARCH"
 	fi
 	fi
 }
 }
 
 

+ 1 - 1
scripts/tracing/draw_functrace.py

@@ -123,7 +123,7 @@ def main():
 		tree = tree.getParent(caller)
 		tree = tree.getParent(caller)
 		tree = tree.calls(callee, calltime)
 		tree = tree.calls(callee, calltime)
 
 
-	print CallTree.ROOT
+	print(CallTree.ROOT)
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
 	main()
 	main()

+ 1 - 1
security/tomoyo/Makefile

@@ -4,7 +4,7 @@ obj-y = audit.o common.o condition.o domain.o environ.o file.o gc.o group.o load
 targets += builtin-policy.h
 targets += builtin-policy.h
 define do_policy
 define do_policy
 echo "static char tomoyo_builtin_$(1)[] __initdata ="; \
 echo "static char tomoyo_builtin_$(1)[] __initdata ="; \
-$(objtree)/scripts/basic/bin2c <$(firstword $(wildcard $(obj)/policy/$(1).conf $(srctree)/$(src)/policy/$(1).conf.default) /dev/null); \
+$(objtree)/scripts/bin2c <$(firstword $(wildcard $(obj)/policy/$(1).conf $(srctree)/$(src)/policy/$(1).conf.default) /dev/null); \
 echo ";"
 echo ";"
 endef
 endef
 quiet_cmd_policy  = POLICY  $@
 quiet_cmd_policy  = POLICY  $@

+ 1 - 1
tools/build/Build.include

@@ -98,4 +98,4 @@ cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXX
 ###
 ###
 ## HOSTCC C flags
 ## HOSTCC C flags
 
 
-host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))
+host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(KBUILD_HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))

+ 1 - 1
tools/build/Makefile

@@ -43,7 +43,7 @@ $(OUTPUT)fixdep-in.o: FORCE
 	$(Q)$(MAKE) $(build)=fixdep
 	$(Q)$(MAKE) $(build)=fixdep
 
 
 $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
 $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
-	$(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $<
+	$(QUIET_LINK)$(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ $<
 
 
 FORCE:
 FORCE:
 
 

+ 2 - 2
tools/objtool/Makefile

@@ -31,8 +31,8 @@ INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
 	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
 	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
-CFLAGS   += -Werror $(WARNINGS) $(HOSTCFLAGS) -g $(INCLUDES)
-LDFLAGS  += -lelf $(LIBSUBCMD) $(HOSTLDFLAGS)
+CFLAGS   += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES)
+LDFLAGS  += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
 
 
 # Allow old libelf to be used:
 # Allow old libelf to be used:
 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)