Skip to content

Commit

Permalink
Merge tag 'kbuild-v4.19' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  ...
  • Loading branch information
torvalds committed Aug 15, 2018
2 parents 7c7b562 + 512ddf7 commit e026bcc
Show file tree
Hide file tree
Showing 51 changed files with 373 additions and 169 deletions.
16 changes: 16 additions & 0 deletions Documentation/kbuild/kbuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ LDFLAGS_MODULE
--------------------------------------------------
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
--------------------------------------------------
Set the top-level Kconfig file to the value of this environment
Expand Down
8 changes: 7 additions & 1 deletion Documentation/kbuild/makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ Both possibilities are described in the following.

When compiling host programs, it is possible to set specific flags.
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
in that Makefile, use the variable HOST_EXTRACFLAGS.

Expand Down Expand Up @@ -1105,6 +1105,12 @@ When kbuild executes, the following steps are followed (roughly):
target: source(s) FORCE
#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
Link target. Often, LDFLAGS_$@ is used to set specific options to ld.

Expand Down
19 changes: 7 additions & 12 deletions Documentation/process/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ binutils 2.20 ld -v
flex 2.5.35 flex --version
bison 2.0 bison --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
jfsutils 1.1.3 fsck.jfs -V
reiserfsprogs 3.6.3 reiserfsck -V
Expand Down Expand Up @@ -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
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
--------

Expand Down Expand Up @@ -371,16 +365,17 @@ 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
--------

- <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
--------

Expand Down
24 changes: 13 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers_% archheaders archscripts \
kernelversion %src-pkg
%asm-generic kernelversion %src-pkg

config-targets := 0
mixed-targets := 0
Expand Down Expand Up @@ -359,11 +359,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)

HOSTCC = gcc
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...)
AS = $(CROSS_COMPILE)as
Expand Down Expand Up @@ -429,10 +430,10 @@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
LDFLAGS :=
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 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS

export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
Expand Down Expand Up @@ -1009,9 +1010,10 @@ ifdef CONFIG_GDB_SCRIPTS
endif
+$(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
vmlinux-dirs += samples
samples: headers_install
endif

# The actual objects are generated when descending,
Expand Down Expand Up @@ -1116,7 +1118,7 @@ define filechk_version.h
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
endef

$(version_h): $(srctree)/Makefile FORCE
$(version_h): FORCE
$(call filechk,version.h)
$(Q)rm -f $(old_version_h)

Expand Down
2 changes: 1 addition & 1 deletion arch/alpha/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets := vmlinux.gz vmlinux \
tools/bootpzh bootloader bootpheader bootpzheader
OBJSTRIP := $(obj)/tools/objstrip

HOSTCFLAGS := -Wall -I$(objtree)/usr/include
KBUILD_HOSTCFLAGS := -Wall -I$(objtree)/usr/include
BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj)

# SRM bootable image. Copy to offset 512 of a partition.
Expand Down
3 changes: 0 additions & 3 deletions arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#
# Copyright (C) 1995-2001 by Russell King

# Ensure linker flags are correct
LDFLAGS :=

LDFLAGS_vmlinux :=-p --no-undefined -X --pic-veneer
ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
LDFLAGS_vmlinux += --be8
Expand Down
25 changes: 0 additions & 25 deletions arch/arm/mach-at91/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@ ifeq ($(CONFIG_PM_DEBUG),y)
CFLAGS_pm.o += -DDEBUG
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
$(call if_changed_dep,cc_s_c)

Expand Down
3 changes: 3 additions & 0 deletions arch/arm64/kernel/vdso/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include <linux/uts.h>
#include <linux/version.h>
#include <linux/elfnote.h>
#include <linux/build-salt.h>

ELFNOTE_START(Linux, 0, "a")
.long LINUX_VERSION_CODE
ELFNOTE_END

BUILD_SALT
1 change: 0 additions & 1 deletion arch/openrisc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

KBUILD_DEFCONFIG := or1ksim_defconfig

LDFLAGS :=
OBJCOPYFLAGS := -O binary -R .note -R .comment -S
LDFLAGS_vmlinux :=
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/kernel/vdso32/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <linux/uts.h>
#include <linux/version.h>
#include <linux/build-salt.h>

#define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type) \
.section name, flags; \
Expand All @@ -23,3 +24,5 @@
ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0)
.long LINUX_VERSION_CODE
ASM_ELF_NOTE_END

BUILD_SALT
3 changes: 1 addition & 2 deletions arch/powerpc/purgatory/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined
$(obj)/purgatory.ro: $(obj)/trampoline.o FORCE
$(call if_changed,ld)

CMD_BIN2C = $(objtree)/scripts/basic/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
$(call if_changed,bin2c)
Expand Down
1 change: 0 additions & 1 deletion arch/riscv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# for more details.
#

LDFLAGS :=
OBJCOPYFLAGS := -O binary
LDFLAGS_vmlinux :=
ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
Expand Down
6 changes: 3 additions & 3 deletions arch/s390/kernel/syscalls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')

define filechk_syshdr
$(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2"
$(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2" < $<
endef

define filechk_sysnr
$(CONFIG_SHELL) '$(systbl)' -N -a $(sysnr_abi_$(basetarget))
$(CONFIG_SHELL) '$(systbl)' -N -a $(sysnr_abi_$(basetarget)) < $<
endef

define filechk_syscalls
$(CONFIG_SHELL) '$(systbl)' -S
$(CONFIG_SHELL) '$(systbl)' -S < $<
endef

syshdr_abi_unistd_32 := common,32
Expand Down
3 changes: 1 addition & 2 deletions arch/s390/purgatory/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
$(call if_changed,ld)

CMD_BIN2C = $(objtree)/scripts/basic/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
$(call if_changed,bin2c)
Expand Down
11 changes: 2 additions & 9 deletions arch/um/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,7 @@ endef
KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig

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

Expand Down Expand Up @@ -169,7 +162,7 @@ define filechk_gen-asm-offsets
echo " *"; \
echo " */"; \
echo ""; \
sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" < $<; \
echo ""; )
endef

Expand Down
4 changes: 2 additions & 2 deletions arch/um/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

$(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
$(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
# object name, so nothing from the library gets linked.
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/Makefile.um
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ KBUILD_CFLAGS += $(call cc-option,-m32)
KBUILD_AFLAGS += $(call cc-option,-m32)
LINK-y += $(call cc-option,-m32)

export LDFLAGS

LDS_EXTRA := -Ui386
export LDS_EXTRA

Expand Down
3 changes: 3 additions & 0 deletions arch/x86/entry/vdso/vdso-note.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* Here we can supply some information useful to userland.
*/

#include <linux/build-salt.h>
#include <linux/uts.h>
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
.long LINUX_VERSION_CODE
ELFNOTE_END

BUILD_SALT
3 changes: 3 additions & 0 deletions arch/x86/entry/vdso/vdso32/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Here we can supply some information useful to userland.
*/

#include <linux/build-salt.h>
#include <linux/version.h>
#include <linux/elfnote.h>

Expand All @@ -14,6 +15,8 @@ ELFNOTE_START(Linux, 0, "a")
.long LINUX_VERSION_CODE
ELFNOTE_END

BUILD_SALT

#ifdef CONFIG_XEN
/*
* Add a special note telling glibc's dynamic linker a fake hardware
Expand Down
3 changes: 1 addition & 2 deletions arch/x86/purgatory/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE

targets += kexec-purgatory.c

CMD_BIN2C = $(objtree)/scripts/basic/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
$(call if_changed,bin2c)
Expand Down
3 changes: 1 addition & 2 deletions arch/xtensa/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Image: boot-elf
zImage: boot-redboot
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)

OBJCOPYFLAGS = --strip-all -R .comment -R .note.gnu.build-id -O binary
Expand Down
Loading

0 comments on commit e026bcc

Please sign in to comment.