Commit cff11abe authored by Linus Torvalds's avatar Linus Torvalds

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

Pull Kbuild updates from Masahiro Yamada:

 - fix warnings in 'make clean' for ARCH=um, hexagon, h8300, unicore32

 - ensure to rebuild all objects when the compiler is upgraded

 - exclude system headers from dependency tracking and fixdep processing

 - fix potential bit-size mismatch between the kernel and BPF user-mode
   helper

 - add the new syntax 'userprogs' to build user-space programs for the
   target architecture (the same arch as the kernel)

 - compile user-space sample code under samples/ for the target arch
   instead of the host arch

 - make headers_install fail if a CONFIG option is leaked to user-space

 - sanitize the output format of scripts/checkstack.pl

 - handle ARM 'push' instruction in scripts/checkstack.pl

 - error out before modpost if a module name conflict is found

 - error out when multiple directories are passed to M= because this
   feature is broken for a long time

 - add CONFIG_DEBUG_INFO_COMPRESSED to support compressed debug info

 - a lot of cleanups of modpost

 - dump vmlinux symbols out into vmlinux.symvers, and reuse it in the
   second pass of modpost

 - do not run the second pass of modpost if nothing in modules is
   updated

 - install modules.builtin(.modinfo) by 'make install' as well as by
   'make modules_install' because it is useful even when
   CONFIG_MODULES=n

 - add new command line variables, GZIP, BZIP2, LZOP, LZMA, LZ4, and XZ
   to allow users to use alternatives such as pigz, pbzip2, etc.

* tag 'kbuild-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (96 commits)
  kbuild: add variables for compression tools
  Makefile: install modules.builtin even if CONFIG_MODULES=n
  mksysmap: Fix the mismatch of '.L' symbols in System.map
  kbuild: doc: rename LDFLAGS to KBUILD_LDFLAGS
  modpost: change elf_info->size to size_t
  modpost: remove is_vmlinux() helper
  modpost: strip .o from modname before calling new_module()
  modpost: set have_vmlinux in new_module()
  modpost: remove mod->skip struct member
  modpost: add mod->is_vmlinux struct member
  modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}()
  modpost: remove mod->is_dot_o struct member
  modpost: move -d option in scripts/Makefile.modpost
  modpost: remove -s option
  modpost: remove get_next_text() and make {grab,release_}file static
  modpost: use read_text_file() and get_line() for reading text files
  modpost: avoid false-positive file open error
  modpost: fix potential mmap'ed file overrun in get_src_version()
  modpost: add read_text_file() and get_line() helpers
  modpost: do not call get_modinfo() for vmlinux(.o)
  ...
parents 6f2dc3d3 8dfb61dc
...@@ -56,6 +56,7 @@ modules.order ...@@ -56,6 +56,7 @@ modules.order
/linux /linux
/vmlinux /vmlinux
/vmlinux.32 /vmlinux.32
/vmlinux.symvers
/vmlinux-gdb.py /vmlinux-gdb.py
/vmlinuz /vmlinuz
/System.map /System.map
......
...@@ -251,6 +251,7 @@ vmlinux-* ...@@ -251,6 +251,7 @@ vmlinux-*
vmlinux.aout vmlinux.aout
vmlinux.bin.all vmlinux.bin.all
vmlinux.lds vmlinux.lds
vmlinux.symvers
vmlinuz vmlinuz
voffset.h voffset.h
vsyscall.lds vsyscall.lds
......
This diff is collapsed.
...@@ -528,18 +528,6 @@ build. ...@@ -528,18 +528,6 @@ build.
will then do the expected and compile both modules with will then do the expected and compile both modules with
full knowledge of symbols from either module. full knowledge of symbols from either module.
Use an extra Module.symvers file
When an external module is built, a Module.symvers file
is generated containing all exported symbols which are
not defined in the kernel. To get access to symbols
from bar.ko, copy the Module.symvers file from the
compilation of bar.ko to the directory where foo.ko is
built. During the module build, kbuild will read the
Module.symvers file in the directory of the external
module, and when the build is finished, a new
Module.symvers file is created containing the sum of
all symbols defined and not part of the kernel.
Use "make" variable KBUILD_EXTRA_SYMBOLS Use "make" variable KBUILD_EXTRA_SYMBOLS
If it is impractical to add a top-level kbuild file, If it is impractical to add a top-level kbuild file,
you can assign a space separated list you can assign a space separated list
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
# #
mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration" mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
comment "Compiler: $(CC_VERSION_TEXT)"
source "scripts/Kconfig.include" source "scripts/Kconfig.include"
source "init/Kconfig" source "init/Kconfig"
......
This diff is collapsed.
...@@ -45,12 +45,10 @@ endif ...@@ -45,12 +45,10 @@ endif
ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
KBUILD_CPPFLAGS += -mbig-endian KBUILD_CPPFLAGS += -mbig-endian
CHECKFLAGS += -D__ARMEB__ CHECKFLAGS += -D__ARMEB__
AS += -EB
KBUILD_LDFLAGS += -EB KBUILD_LDFLAGS += -EB
else else
KBUILD_CPPFLAGS += -mlittle-endian KBUILD_CPPFLAGS += -mlittle-endian
CHECKFLAGS += -D__ARMEL__ CHECKFLAGS += -D__ARMEL__
AS += -EL
KBUILD_LDFLAGS += -EL KBUILD_LDFLAGS += -EL
endif endif
......
...@@ -56,7 +56,7 @@ trap 'rm -f "$XIPIMAGE.tmp"; exit 1' 1 2 3 ...@@ -56,7 +56,7 @@ trap 'rm -f "$XIPIMAGE.tmp"; exit 1' 1 2 3
# substitute the data section by a compressed version # substitute the data section by a compressed version
$DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp" $DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp"
$DD if="$XIPIMAGE" skip=$data_start iflag=skip_bytes | $DD if="$XIPIMAGE" skip=$data_start iflag=skip_bytes |
gzip -9 >> "$XIPIMAGE.tmp" $_GZIP -9 >> "$XIPIMAGE.tmp"
# replace kernel binary # replace kernel binary
mv -f "$XIPIMAGE.tmp" "$XIPIMAGE" mv -f "$XIPIMAGE.tmp" "$XIPIMAGE"
...@@ -94,7 +94,6 @@ endif ...@@ -94,7 +94,6 @@ endif
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
KBUILD_CPPFLAGS += -mbig-endian KBUILD_CPPFLAGS += -mbig-endian
CHECKFLAGS += -D__AARCH64EB__ CHECKFLAGS += -D__AARCH64EB__
AS += -EB
# Prefer the baremetal ELF build target, but not all toolchains include # Prefer the baremetal ELF build target, but not all toolchains include
# it so fall back to the standard linux version if needed. # it so fall back to the standard linux version if needed.
KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb) KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
...@@ -102,7 +101,6 @@ UTS_MACHINE := aarch64_be ...@@ -102,7 +101,6 @@ UTS_MACHINE := aarch64_be
else else
KBUILD_CPPFLAGS += -mlittle-endian KBUILD_CPPFLAGS += -mlittle-endian
CHECKFLAGS += -D__AARCH64EL__ CHECKFLAGS += -D__AARCH64EL__
AS += -EL
# Same as above, prefer ELF but fall back to linux target if needed. # Same as above, prefer ELF but fall back to linux target if needed.
KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux) KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux)
UTS_MACHINE := aarch64 UTS_MACHINE := aarch64
......
...@@ -18,7 +18,7 @@ CONFIG_MEMORY_START ?= 0x00400000 ...@@ -18,7 +18,7 @@ CONFIG_MEMORY_START ?= 0x00400000
CONFIG_BOOT_LINK_OFFSET ?= 0x00280000 CONFIG_BOOT_LINK_OFFSET ?= 0x00280000
IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)))) IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET))))
LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null)
LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup -T $(obj)/vmlinux.lds \ LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup -T $(obj)/vmlinux.lds \
--defsym output=$(CONFIG_MEMORY_START) --defsym output=$(CONFIG_MEMORY_START)
......
...@@ -30,7 +30,7 @@ TIR_NAME := r19 ...@@ -30,7 +30,7 @@ TIR_NAME := r19
KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__ KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME) KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null)
libs-y += $(LIBGCC) libs-y += $(LIBGCC)
head-y := arch/hexagon/kernel/head.o head-y := arch/hexagon/kernel/head.o
......
...@@ -40,7 +40,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from ...@@ -40,7 +40,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
endif endif
quiet_cmd_gzip = GZIP $@ quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ cmd_gzip = cat $(real-prereqs) | $(_GZIP) -n -f -9 > $@
quiet_cmd_objcopy = OBJCOPY $@ quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
......
...@@ -135,10 +135,10 @@ vmlinux.gz: vmlinux ...@@ -135,10 +135,10 @@ vmlinux.gz: vmlinux
ifndef CONFIG_KGDB ifndef CONFIG_KGDB
cp vmlinux vmlinux.tmp cp vmlinux vmlinux.tmp
$(STRIP) vmlinux.tmp $(STRIP) vmlinux.tmp
gzip -9c vmlinux.tmp >vmlinux.gz $(_GZIP) -9c vmlinux.tmp >vmlinux.gz
rm vmlinux.tmp rm vmlinux.tmp
else else
gzip -9c vmlinux >vmlinux.gz $(_GZIP) -9c vmlinux >vmlinux.gz
endif endif
bzImage: vmlinux.bz2 bzImage: vmlinux.bz2
...@@ -148,10 +148,10 @@ vmlinux.bz2: vmlinux ...@@ -148,10 +148,10 @@ vmlinux.bz2: vmlinux
ifndef CONFIG_KGDB ifndef CONFIG_KGDB
cp vmlinux vmlinux.tmp cp vmlinux vmlinux.tmp
$(STRIP) vmlinux.tmp $(STRIP) vmlinux.tmp
bzip2 -1c vmlinux.tmp >vmlinux.bz2 $(_BZIP2) -1c vmlinux.tmp >vmlinux.bz2
rm vmlinux.tmp rm vmlinux.tmp
else else
bzip2 -1c vmlinux >vmlinux.bz2 $(_BZIP2) -1c vmlinux >vmlinux.bz2
endif endif
archclean: archclean:
......
...@@ -162,7 +162,7 @@ vmlinuz: bzImage ...@@ -162,7 +162,7 @@ vmlinuz: bzImage
$(OBJCOPY) $(boot)/bzImage $@ $(OBJCOPY) $(boot)/bzImage $@
else else
vmlinuz: vmlinux vmlinuz: vmlinux
@gzip -cf -9 $< > $@ @$(_GZIP) -cf -9 $< > $@
endif endif
install: install:
......
...@@ -140,7 +140,7 @@ export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) ...@@ -140,7 +140,7 @@ export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
# When cleaning we don't include .config, so we don't include # When cleaning we don't include .config, so we don't include
# TT or skas makefiles and don't clean skas_ptregs.h. # TT or skas makefiles and don't clean skas_ptregs.h.
CLEAN_FILES += linux x.i gmon.out CLEAN_FILES += linux x.i gmon.out
MRPROPER_DIRS += arch/$(SUBARCH)/include/generated MRPROPER_FILES += arch/$(SUBARCH)/include/generated
archclean: archclean:
@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
......
...@@ -18,9 +18,9 @@ ubd-objs := ubd_kern.o ubd_user.o ...@@ -18,9 +18,9 @@ ubd-objs := ubd_kern.o ubd_user.o
port-objs := port_kern.o port_user.o port-objs := port_kern.o port_user.o
harddog-objs := harddog_kern.o harddog_user.o harddog-objs := harddog_kern.o harddog_user.o
LDFLAGS_pcap.o := -r $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a) LDFLAGS_pcap.o = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
LDFLAGS_vde.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a) LDFLAGS_vde.o = $(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
......
...@@ -10,12 +10,12 @@ lib-y += strncpy_from_user.o strnlen_user.o ...@@ -10,12 +10,12 @@ lib-y += strncpy_from_user.o strnlen_user.o
lib-y += clear_user.o copy_page.o lib-y += clear_user.o copy_page.o
lib-y += copy_from_user.o copy_to_user.o lib-y += copy_from_user.o copy_to_user.o
GNU_LIBC_A := $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libc.a) GNU_LIBC_A = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libc.a)
GNU_LIBC_A_OBJS := memchr.o memcpy.o memmove.o memset.o GNU_LIBC_A_OBJS := memchr.o memcpy.o memmove.o memset.o
GNU_LIBC_A_OBJS += strchr.o strrchr.o GNU_LIBC_A_OBJS += strchr.o strrchr.o
GNU_LIBC_A_OBJS += rawmemchr.o # needed by strrchr.o GNU_LIBC_A_OBJS += rawmemchr.o # needed by strrchr.o
GNU_LIBGCC_A := $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libgcc.a) GNU_LIBGCC_A = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libgcc.a)
GNU_LIBGCC_A_OBJS := _ashldi3.o _ashrdi3.o _lshrdi3.o GNU_LIBGCC_A_OBJS := _ashldi3.o _ashrdi3.o _lshrdi3.o
GNU_LIBGCC_A_OBJS += _divsi3.o _modsi3.o _ucmpdi2.o _umodsi3.o _udivsi3.o GNU_LIBGCC_A_OBJS += _divsi3.o _modsi3.o _ucmpdi2.o _umodsi3.o _udivsi3.o
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef __LINUX_KCONFIG_H #ifndef __LINUX_KCONFIG_H
#define __LINUX_KCONFIG_H #define __LINUX_KCONFIG_H
/* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */
#include <generated/autoconf.h> #include <generated/autoconf.h>
#ifdef CONFIG_CPU_BIG_ENDIAN #ifdef CONFIG_CPU_BIG_ENDIAN
......
...@@ -8,8 +8,25 @@ config DEFCONFIG_LIST ...@@ -8,8 +8,25 @@ config DEFCONFIG_LIST
default "/boot/config-$(shell,uname -r)" default "/boot/config-$(shell,uname -r)"
default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)" default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
config CC_VERSION_TEXT
string
default "$(CC_VERSION_TEXT)"
help
This is used in unclear ways:
- Re-run Kconfig when the compiler is updated
The 'default' property references the environment variable,
CC_VERSION_TEXT so it is recorded in include/config/auto.conf.cmd.
When the compiler is updated, Kconfig will be invoked.
- Ensure full rebuild when the compier is updated
include/linux/kconfig.h contains this option in the comment line so
fixdep adds include/config/cc/version/text.h into the auto-generated
dependency. When the compiler is updated, syncconfig will touch it
and then every file will be rebuilt.
config CC_IS_GCC config CC_IS_GCC
def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc) def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q gcc)
config GCC_VERSION config GCC_VERSION
int int
...@@ -21,7 +38,7 @@ config LD_VERSION ...@@ -21,7 +38,7 @@ config LD_VERSION
default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh) default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
config CC_IS_CLANG config CC_IS_CLANG
def_bool $(success,$(CC) --version | head -n 1 | grep -q clang) def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q clang)
config LD_IS_LLD config LD_IS_LLD
def_bool $(success,$(LD) -v | head -n 1 | grep -q LLD) def_bool $(success,$(LD) -v | head -n 1 | grep -q LLD)
...@@ -31,7 +48,14 @@ config CLANG_VERSION ...@@ -31,7 +48,14 @@ config CLANG_VERSION
default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
config CC_CAN_LINK config CC_CAN_LINK
def_bool $(success,$(srctree)/scripts/cc-can-link.sh $(CC)) bool
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m64-flag)) if 64BIT
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m32-flag))
config CC_CAN_LINK_STATIC
bool
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m64-flag)) if 64BIT
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m32-flag))
config CC_HAS_ASM_GOTO config CC_HAS_ASM_GOTO
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
......
...@@ -35,4 +35,4 @@ include/generated/compile.h: FORCE ...@@ -35,4 +35,4 @@ include/generated/compile.h: FORCE
@$($(quiet)chk_compile.h) @$($(quiet)chk_compile.h)
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \
"$(CONFIG_PREEMPT_RT)" "$(CC)" "$(LD)" "$(CONFIG_PREEMPT_RT)" $(CONFIG_CC_VERSION_TEXT) "$(LD)"
...@@ -88,7 +88,7 @@ find $cpio_dir -type f -print0 | ...@@ -88,7 +88,7 @@ find $cpio_dir -type f -print0 |
find $cpio_dir -printf "./%P\n" | LC_ALL=C sort | \ find $cpio_dir -printf "./%P\n" | LC_ALL=C sort | \
tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \
--owner=0 --group=0 --numeric-owner --no-recursion \ --owner=0 --group=0 --numeric-owner --no-recursion \
-Jcf $tarfile -C $cpio_dir/ -T - > /dev/null -I $XZ -cf $tarfile -C $cpio_dir/ -T - > /dev/null
echo $headers_md5 > kernel/kheaders.md5 echo $headers_md5 > kernel/kheaders.md5
echo "$this_file_md5" >> kernel/kheaders.md5 echo "$this_file_md5" >> kernel/kheaders.md5
......
...@@ -213,6 +213,23 @@ config DEBUG_INFO_REDUCED ...@@ -213,6 +213,23 @@ config DEBUG_INFO_REDUCED
DEBUG_INFO build and compile times are reduced too. DEBUG_INFO build and compile times are reduced too.
Only works with newer gcc versions. Only works with newer gcc versions.
config DEBUG_INFO_COMPRESSED
bool "Compressed debugging information"
depends on DEBUG_INFO
depends on $(cc-option,-gz=zlib)
depends on $(as-option,-Wa$(comma)--compress-debug-sections=zlib)
depends on $(ld-option,--compress-debug-sections=zlib)
help
Compress the debug information using zlib. Requires GCC 5.0+ or Clang
5.0+, binutils 2.26+, and zlib.
Users of dpkg-deb via scripts/package/builddeb may find an increase in
size of their debug .deb packages with this config set, due to the
debug info being compressed with zlib, then the object files being
recompressed with a different compression scheme. But this is still
preferable to setting $KDEB_COMPRESS to "none" which would be even
larger.
config DEBUG_INFO_SPLIT config DEBUG_INFO_SPLIT
bool "Produce split debuginfo in .dwo files" bool "Produce split debuginfo in .dwo files"
depends on DEBUG_INFO depends on DEBUG_INFO
......
...@@ -9,8 +9,12 @@ menuconfig BPFILTER ...@@ -9,8 +9,12 @@ menuconfig BPFILTER
if BPFILTER if BPFILTER
config BPFILTER_UMH config BPFILTER_UMH
tristate "bpfilter kernel module with user mode helper" tristate "bpfilter kernel module with user mode helper"
depends on CC_CAN_LINK depends on CC_CAN_LINK_STATIC
default m default m
help help
This builds bpfilter kernel module with embedded user mode helper This builds bpfilter kernel module with embedded user mode helper
Note: your toolchain must support building static binaries, since
rootfs isn't mounted at the time when __init functions are called
and do_execv won't be able to find the elf interpreter.
endif endif
...@@ -3,17 +3,14 @@ ...@@ -3,17 +3,14 @@
# Makefile for the Linux BPFILTER layer. # Makefile for the Linux BPFILTER layer.
# #
hostprogs := bpfilter_umh userprogs := bpfilter_umh
bpfilter_umh-objs := main.o bpfilter_umh-objs := main.o
KBUILD_HOSTCFLAGS += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi
HOSTCC := $(CC)
ifeq ($(CONFIG_BPFILTER_UMH), y) # builtin bpfilter_umh should be linked 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
KBUILD_HOSTLDFLAGS += -static userldflags += -static
endif
$(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
......
...@@ -6,6 +6,10 @@ menuconfig SAMPLES ...@@ -6,6 +6,10 @@ menuconfig SAMPLES
if SAMPLES if SAMPLES
config SAMPLE_AUXDISPLAY
bool "auxdisplay sample"
depends on CC_CAN_LINK
config SAMPLE_TRACE_EVENTS config SAMPLE_TRACE_EVENTS
tristate "Build trace_events examples -- loadable modules only" tristate "Build trace_events examples -- loadable modules only"
depends on EVENT_TRACING && m depends on EVENT_TRACING && m
...@@ -118,19 +122,29 @@ config SAMPLE_CONNECTOR ...@@ -118,19 +122,29 @@ config SAMPLE_CONNECTOR
config SAMPLE_HIDRAW config SAMPLE_HIDRAW
bool "hidraw sample" bool "hidraw sample"
depends on HEADERS_INSTALL depends on CC_CAN_LINK && HEADERS_INSTALL
config SAMPLE_PIDFD config SAMPLE_PIDFD
bool "pidfd sample" bool "pidfd sample"
depends on HEADERS_INSTALL depends on CC_CAN_LINK && HEADERS_INSTALL
config SAMPLE_SECCOMP config SAMPLE_SECCOMP
bool "Build seccomp sample code" bool "Build seccomp sample code"
depends on SECCOMP_FILTER && HEADERS_INSTALL depends on SECCOMP_FILTER && CC_CAN_LINK && HEADERS_INSTALL
help help
Build samples of seccomp filters using various methods of Build samples of seccomp filters using various methods of
BPF filter construction. BPF filter construction.
config SAMPLE_TIMER
bool "Timer sample"
depends on CC_CAN_LINK && HEADERS_INSTALL
config SAMPLE_UHID
bool "UHID sample"
depends on CC_CAN_LINK && HEADERS_INSTALL
help
Build UHID sample program.
config SAMPLE_VFIO_MDEV_MTTY config SAMPLE_VFIO_MDEV_MTTY
tristate "Build VFIO mtty example mediated device sample code -- loadable modules only" tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
depends on VFIO_MDEV_DEVICE && m depends on VFIO_MDEV_DEVICE && m
...@@ -178,7 +192,7 @@ config SAMPLE_ANDROID_BINDERFS ...@@ -178,7 +192,7 @@ config SAMPLE_ANDROID_BINDERFS
config SAMPLE_VFS config SAMPLE_VFS
bool "Build example programs that use new VFS system calls" bool "Build example programs that use new VFS system calls"
depends on HEADERS_INSTALL depends on CC_CAN_LINK && HEADERS_INSTALL
help help
Build example userspace programs that use new VFS system calls such Build example userspace programs that use new VFS system calls such
as mount API and statx(). Note that this is restricted to the x86 as mount API and statx(). Note that this is restricted to the x86
...@@ -187,8 +201,12 @@ config SAMPLE_VFS ...@@ -187,8 +201,12 @@ config SAMPLE_VFS
config SAMPLE_INTEL_MEI config SAMPLE_INTEL_MEI
bool "Build example program working with intel mei driver" bool "Build example program working with intel mei driver"
depends on INTEL_MEI depends on INTEL_MEI
depends on CC_CAN_LINK && HEADERS_INSTALL
help help
Build a sample program to work with mei device. Build a sample program to work with mei device.
config SAMPLE_WATCHDOG
bool "watchdog sample"
depends on CC_CAN_LINK
endif # SAMPLES endif # SAMPLES
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Makefile for Linux samples code # Makefile for Linux samples code
OBJECT_FILES_NON_STANDARD := y
subdir-$(CONFIG_SAMPLE_AUXDISPLAY) += auxdisplay
obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/ obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/
obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/ obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/
obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/ obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/
...@@ -16,11 +16,14 @@ subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd ...@@ -16,11 +16,14 @@ subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd
obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/ obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/
obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/ obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/
subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp
subdir-$(CONFIG_SAMPLE_TIMER) += timers
obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/ obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/
obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/ obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/
obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace/ obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace/
obj-$(CONFIG_SAMPLE_TRACE_ARRAY) += ftrace/ obj-$(CONFIG_SAMPLE_TRACE_ARRAY) += ftrace/
subdir-$(CONFIG_SAMPLE_UHID) += uhid
obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/ obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/
obj-y += vfio-mdev/ obj-y += vfio-mdev/
subdir-$(CONFIG_SAMPLE_VFS) += vfs subdir-$(CONFIG_SAMPLE_VFS) += vfs
obj-$(CONFIG_SAMPLE_INTEL_MEI) += mei/ obj-$(CONFIG_SAMPLE_INTEL_MEI) += mei/
subdir-$(CONFIG_SAMPLE_WATCHDOG) += watchdog
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
CC := $(CROSS_COMPILE)gcc userprogs := cfag12864b-example
CFLAGS := -I../../usr/include always-y := $(userprogs)
PROGS := cfag12864b-example
all: $(PROGS)
clean:
rm -fr $(PROGS)
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o
# List of programs to build userprogs := ucon
hostprogs := ucon always-$(CONFIG_CC_CAN_LINK) := $(userprogs)
always-y := $(hostprogs)
HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include userccflags += -I usr/include
all: modules
modules clean:
$(MAKE) -C ../.. M=$(CURDIR) $@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# List of programs to build userprogs := hid-example
hostprogs := hid-example always-y := $(userprogs)
always-y := $(hostprogs)
HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include userccflags += -I usr/include
all: hid-example
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2012-2019, Intel Corporation. All rights reserved. # Copyright (c) 2012-2019, Intel Corporation. All rights reserved.
hostprogs := mei-amt-version userprogs := mei-amt-version
always-y := $(userprogs)
HOSTCFLAGS_mei-amt-version.o += -I$(objtree)/usr/include userccflags += -I usr/include
always-y := $(hostprogs)
all: mei-amt-version
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
hostprogs := pidfd-metadata usertprogs := pidfd-metadata
always-y := $(hostprogs) always-y := $(userprogs)
HOSTCFLAGS_pidfd-metadata.o += -I$(objtree)/usr/include
all: pidfd-metadata userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
ifndef CROSS_COMPILE userprogs := bpf-fancy dropper bpf-direct user-trap
hostprogs := bpf-fancy dropper bpf-direct user-trap
HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include
HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include
HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include
bpf-fancy-objs := bpf-fancy.o bpf-helper.o bpf-fancy-objs := bpf-fancy.o bpf-helper.o
HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include userccflags += -I usr/include
HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include
dropper-objs := dropper.o
HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include always-y := $(userprogs)
HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include
bpf-direct-objs := bpf-direct.o
HOSTCFLAGS_user-trap.o += -I$(objtree)/usr/include
HOSTCFLAGS_user-trap.o += -idirafter $(objtree)/include
user-trap-objs := user-trap.o
# Try to match the kernel target.
ifndef CONFIG_64BIT
# s390 has -m31 flag to build 31 bit binaries
ifndef CONFIG_S390
MFLAG = -m32
else
MFLAG = -m31
endif
HOSTCFLAGS_bpf-direct.o += $(MFLAG)
HOSTCFLAGS_dropper.o += $(MFLAG)
HOSTCFLAGS_bpf-helper.o += $(MFLAG)
HOSTCFLAGS_bpf-fancy.o += $(MFLAG)
HOSTCFLAGS_user-trap.o += $(MFLAG)
HOSTLDLIBS_bpf-direct += $(MFLAG)
HOSTLDLIBS_bpf-fancy += $(MFLAG)
HOSTLDLIBS_dropper += $(MFLAG)
HOSTLDLIBS_user-trap += $(MFLAG)
endif
always-y := $(hostprogs)
endif
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
ifndef CROSS_COMPILE userprogs := hpet_example
uname_M := $(shell uname -m 2>/dev/null || echo not) always-y := $(userprogs)
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
ifeq ($(ARCH),x86) userccflags += -I usr/include
CC := $(CROSS_COMPILE)gcc
PROGS := hpet_example
all: $(PROGS)
clean:
rm -fr $(PROGS)
endif
endif
# SPDX-License-Identifier: GPL-2.0-only
/uhid-example
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
# List of programs to build userprogs := uhid-example
hostprogs := uhid-example always-y := $(userprogs)
# Tell kbuild to always build the programs userccflags += -I usr/include
always-y := $(hostprogs)
HOSTCFLAGS_uhid-example.o += -I$(objtree)/usr/include
...@@ -165,7 +165,7 @@ static int uhid_write(int fd, const struct uhid_event *ev) ...@@ -165,7 +165,7 @@ static int uhid_write(int fd, const struct uhid_event *ev)
fprintf(stderr, "Cannot write to uhid: %m\n"); fprintf(stderr, "Cannot write to uhid: %m\n");
return -errno; return -errno;
} else if (ret != sizeof(*ev)) { } else if (ret != sizeof(*ev)) {
fprintf(stderr, "Wrong size written to uhid: %ld != %lu\n", fprintf(stderr, "Wrong size written to uhid: %zd != %zu\n",
ret, sizeof(ev)); ret, sizeof(ev));
return -EFAULT; return -EFAULT;
} else { } else {
...@@ -236,7 +236,7 @@ static int event(int fd) ...@@ -236,7 +236,7 @@ static int event(int fd)
fprintf(stderr, "Cannot read uhid-cdev: %m\n"); fprintf(stderr, "Cannot read uhid-cdev: %m\n");
return -errno; return -errno;
} else if (ret != sizeof(ev)) { } else if (ret != sizeof(ev)) {
fprintf(stderr, "Invalid size read from uhid-dev: %ld != %lu\n", fprintf(stderr, "Invalid size read from uhid-dev: %zd != %zu\n",
ret, sizeof(ev)); ret, sizeof(ev));
return -EFAULT; return -EFAULT;
} }
......
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
# List of programs to build userprogs := test-fsmount test-statx
hostprogs := \ always-y := $(userprogs)
test-fsmount \
test-statx
always-y := $(hostprogs) userccflags += -I usr/include
HOSTCFLAGS_test-fsmount.o += -I$(objtree)/usr/include
HOSTCFLAGS_test-statx.o += -I$(objtree)/usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
CC := $(CROSS_COMPILE)gcc userprogs := watchdog-simple
PROGS := watchdog-simple always-y := $(userprogs)
all: $(PROGS)
clean:
rm -fr $(PROGS)
...@@ -16,7 +16,7 @@ pound := \# ...@@ -16,7 +16,7 @@ pound := \#
dot-target = $(dir $@).$(notdir $@) dot-target = $(dir $@).$(notdir $@)
### ###
# The temporary file to save gcc -MD generated dependencies must not # The temporary file to save gcc -MMD generated dependencies must not
# contain a comma # contain a comma
depfile = $(subst $(comma),_,$(dot-target).d) depfile = $(subst $(comma),_,$(dot-target).d)
......
...@@ -50,6 +50,12 @@ ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),) ...@@ -50,6 +50,12 @@ ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),)
include scripts/Makefile.host include scripts/Makefile.host
endif endif
# Do not include userprogs rules unless needed.
userprogs := $(sort $(userprogs))
ifneq ($(userprogs),)
include scripts/Makefile.userprogs
endif
ifndef obj ifndef obj
$(warning kbuild: Makefile.build is included improperly) $(warning kbuild: Makefile.build is included improperly)
endif endif
...@@ -63,19 +69,27 @@ endif ...@@ -63,19 +69,27 @@ endif
# =========================================================================== # ===========================================================================
# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
targets-for-builtin := $(extra-y)
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a targets-for-builtin += $(obj)/lib.a
endif endif
ifdef need-builtin ifdef need-builtin
builtin-target := $(obj)/built-in.a targets-for-builtin += $(obj)/built-in.a
endif endif
ifeq ($(CONFIG_MODULES)$(need-modorder),y1) targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
modorder-target := $(obj)/modules.order
ifdef need-modorder
targets-for-modules += $(obj)/modules.order
endif endif
mod-targets := $(patsubst %.o, %.mod, $(obj-m)) targets += $(targets-for-builtin) $(targets-for-modules)
# Linus' kernel sanity checking tool # Linus' kernel sanity checking tool
ifeq ($(KBUILD_CHECKSRC),1) ifeq ($(KBUILD_CHECKSRC),1)
...@@ -274,8 +288,6 @@ cmd_mod = { \ ...@@ -274,8 +288,6 @@ cmd_mod = { \
$(obj)/%.mod: $(obj)/%.o FORCE $(obj)/%.mod: $(obj)/%.o FORCE
$(call if_changed,mod) $(call if_changed,mod)
targets += $(mod-targets)
quiet_cmd_cc_lst_c = MKLST $@ quiet_cmd_cc_lst_c = MKLST $@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
...@@ -348,8 +360,9 @@ endif ...@@ -348,8 +360,9 @@ endif
$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(call if_changed_rule,as_o_S) $(call if_changed_rule,as_o_S)
targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) targets += $(filter-out $(subdir-builtin), $(real-obj-y))
targets += $(extra-y) $(always-y) $(MAKECMDGOALS) targets += $(filter-out $(subdir-modorder), $(real-obj-m))
targets += $(lib-y) $(always-y) $(MAKECMDGOALS)
# Linker scripts preprocessor (.lds.S -> .lds) # Linker scripts preprocessor (.lds.S -> .lds)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -373,44 +386,40 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler ...@@ -373,44 +386,40 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# To build objects in subdirs, we need to descend into the directories # To build objects in subdirs, we need to descend into the directories
$(obj)/%/built-in.a: $(obj)/% ; $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
# #
# Rule to compile a set of .o files into one .a file (without symbol table) # Rule to compile a set of .o files into one .a file (without symbol table)
# #
ifdef builtin-target
quiet_cmd_ar_builtin = AR $@ quiet_cmd_ar_builtin = AR $@
cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs) cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
$(builtin-target): $(real-obj-y) FORCE $(obj)/built-in.a: $(real-obj-y) FORCE
$(call if_changed,ar_builtin) $(call if_changed,ar_builtin)
targets += $(builtin-target)
endif # builtin-target
# #
# Rule to create modules.order file # Rule to create modules.order file
# #
# Create commands to either record .ko file or cat modules.order from # Create commands to either record .ko file or cat modules.order from
# a subdirectory # a subdirectory
$(modorder-target): $(subdir-ym) FORCE # Add $(obj-m) as the prerequisite to avoid updating the timestamp of
$(Q){ $(foreach m, $(modorder), \ # modules.order unless contained modules are updated.
$(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
cmd_modules_order = { $(foreach m, $(real-prereqs), \
$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
| $(AWK) '!x[$$0]++' - > $@ | $(AWK) '!x[$$0]++' - > $@
$(obj)/modules.order: $(obj-m) FORCE
$(call if_changed,modules_order)
# #
# Rule to compile a set of .o files into one .a file (with symbol table) # Rule to compile a set of .o files into one .a file (with symbol table)
# #
ifdef lib-target $(obj)/lib.a: $(lib-y) FORCE
$(lib-target): $(lib-y) FORCE
$(call if_changed,ar) $(call if_changed,ar)
targets += $(lib-target)
endif
# NOTE: # NOTE:
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object # Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
# module is turned into a multi object module, $^ will contain header file # module is turned into a multi object module, $^ will contain header file
...@@ -473,8 +482,8 @@ endif ...@@ -473,8 +482,8 @@ endif
else else
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ __build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
$(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \ $(if $(KBUILD_MODULES), $(targets-for-modules)) \
$(subdir-ym) $(always-y) $(subdir-ym) $(always-y)
@: @:
...@@ -487,8 +496,8 @@ PHONY += $(subdir-ym) ...@@ -487,8 +496,8 @@ PHONY += $(subdir-ym)
$(subdir-ym): $(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \ $(Q)$(MAKE) $(build)=$@ \
$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \ $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \ need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1)) need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1)
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
...@@ -29,7 +29,7 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) ...@@ -29,7 +29,7 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
__clean-files := $(extra-y) $(extra-m) $(extra-) \ __clean-files := $(extra-y) $(extra-m) $(extra-) \
$(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \ $(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \
$(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \ $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) $(userprogs) \
$(hostcxxlibs-y) $(hostcxxlibs-m) $(hostcxxlibs-y) $(hostcxxlibs-m)
__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
......
...@@ -88,8 +88,8 @@ _hostcxx_flags += -I $(objtree)/$(obj) ...@@ -88,8 +88,8 @@ _hostcxx_flags += -I $(objtree)/$(obj)
endif endif
endif endif
hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) hostc_flags = -Wp,-MMD,$(depfile) $(_hostc_flags)
hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) hostcxx_flags = -Wp,-MMD,$(depfile) $(_hostcxx_flags)
##### #####
# Compile programs on the host # Compile programs on the host
......
...@@ -4,8 +4,18 @@ asflags-y += $(EXTRA_AFLAGS) ...@@ -4,8 +4,18 @@ asflags-y += $(EXTRA_AFLAGS)
ccflags-y += $(EXTRA_CFLAGS) ccflags-y += $(EXTRA_CFLAGS)
cppflags-y += $(EXTRA_CPPFLAGS) cppflags-y += $(EXTRA_CPPFLAGS)
ldflags-y += $(EXTRA_LDFLAGS) ldflags-y += $(EXTRA_LDFLAGS)
ifneq ($(always),)
$(warning 'always' is deprecated. Please use 'always-y' instead)
always-y += $(always) always-y += $(always)
hostprogs += $(hostprogs-y) $(hostprogs-m) endif
ifneq ($(hostprogs-y),)
$(warning 'hostprogs-y' is deprecated. Please use 'hostprogs' instead)
hostprogs += $(hostprogs-y)
endif
ifneq ($(hostprogs-m),)
$(warning 'hostprogs-m' is deprecated. Please use 'hostprogs' instead)
hostprogs += $(hostprogs-m)
endif
# flags that take effect in current and sub directories # flags that take effect in current and sub directories
KBUILD_AFLAGS += $(subdir-asflags-y) KBUILD_AFLAGS += $(subdir-asflags-y)
...@@ -22,40 +32,35 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) ...@@ -22,40 +32,35 @@ obj-m := $(filter-out $(obj-y),$(obj-m))
# Filter out objects already built-in # Filter out objects already built-in
lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
# Determine modorder. # Subdirectories we need to descend into
# Unfortunately, we don't have information about ordering between -y subdir-ym := $(sort $(subdir-y) $(subdir-m) \
# and -m subdirs. Just put -y's first. $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m))))
modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
# Handle objects in subdirs:
# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
# foo/modules.order
# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
#
# Generate modules.order to determine modorder. Unfortunately, we don't have
# information about ordering between -y and -m subdirs. Just put -y's first.
ifdef need-modorder
obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
else
obj-m := $(filter-out %/, $(obj-m))
endif
# Handle objects in subdirs
# ---------------------------------------------------------------------------
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
# and add the directory to the list of dirs to descend into: $(subdir-y)
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
# and add the directory to the list of dirs to descend into: $(subdir-m)
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y += $(__subdir-y)
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
subdir-m += $(__subdir-m)
ifdef need-builtin ifdef need-builtin
obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
else else
obj-y := $(filter-out %/, $(obj-y)) obj-y := $(filter-out %/, $(obj-y))
endif endif
obj-m := $(filter-out %/, $(obj-m))
# Subdirectories we need to descend into
subdir-ym := $(sort $(subdir-y) $(subdir-m))
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m))))
multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m))))
multi-used := $(multi-used-y) $(multi-used-m) multi-used := $(multi-used-y) $(multi-used-m)
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
# tell kbuild to descend
subdir-obj-y := $(filter %/built-in.a, $(obj-y))
# Replace multi-part objects by their individual parts, # Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories # including built-in.a from subdirectories
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
...@@ -78,10 +83,8 @@ endif ...@@ -78,10 +83,8 @@ endif
extra-y := $(addprefix $(obj)/,$(extra-y)) extra-y := $(addprefix $(obj)/,$(extra-y))
always-y := $(addprefix $(obj)/,$(always-y)) always-y := $(addprefix $(obj)/,$(always-y))
targets := $(addprefix $(obj)/,$(targets)) targets := $(addprefix $(obj)/,$(targets))
modorder := $(addprefix $(obj)/,$(modorder))
obj-m := $(addprefix $(obj)/,$(obj-m)) obj-m := $(addprefix $(obj)/,$(obj-m))
lib-y := $(addprefix $(obj)/,$(lib-y)) lib-y := $(addprefix $(obj)/,$(lib-y))
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
...@@ -171,22 +174,22 @@ modkern_aflags = $(if $(part-of-module), \ ...@@ -171,22 +174,22 @@ modkern_aflags = $(if $(part-of-module), \
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
-include $(srctree)/include/linux/compiler_types.h \ -include $(srctree)/include/linux/compiler_types.h \
$(_c_flags) $(modkern_cflags) \ $(_c_flags) $(modkern_cflags) \
$(basename_flags) $(modname_flags) $(basename_flags) $(modname_flags)
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
$(_a_flags) $(modkern_aflags) $(_a_flags) $(modkern_aflags)
cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
$(_cpp_flags) $(_cpp_flags)
ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes
dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \
$(addprefix -I,$(DTC_INCLUDE)) \ $(addprefix -I,$(DTC_INCLUDE)) \
-undef -D__DTS__ -undef -D__DTS__
...@@ -241,7 +244,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ ...@@ -241,7 +244,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_gzip = GZIP $@ quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ cmd_gzip = cat $(real-prereqs) | $(_GZIP) -n -f -9 > $@
# DTC # DTC
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -287,13 +290,13 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE ...@@ -287,13 +290,13 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
quiet_cmd_dtc = DTC $@ quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(DTC) -O $(2) -o $@ -b 0 \ $(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
$(call if_changed_dep,dtc,dtb) $(call if_changed_dep,dtc)
DT_CHECKER ?= dt-validate DT_CHECKER ?= dt-validate
DT_BINDING_DIR := Documentation/devicetree/bindings DT_BINDING_DIR := Documentation/devicetree/bindings
...@@ -304,7 +307,7 @@ quiet_cmd_dtb_check = CHECK $@ ...@@ -304,7 +307,7 @@ quiet_cmd_dtb_check = CHECK $@
cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@
define rule_dtc define rule_dtc
$(call cmd_and_fixdep,dtc,yaml) $(call cmd_and_fixdep,dtc)
$(call cmd,dtb_check) $(call cmd,dtb_check)
endef endef
...@@ -334,19 +337,19 @@ printf "%08x\n" $$dec_size | \ ...@@ -334,19 +337,19 @@ printf "%08x\n" $$dec_size | \
) )
quiet_cmd_bzip2 = BZIP2 $@ quiet_cmd_bzip2 = BZIP2 $@
cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9; $(size_append); } > $@ cmd_bzip2 = { cat $(real-prereqs) | $(_BZIP2) -9; $(size_append); } > $@
# Lzma # Lzma
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_lzma = LZMA $@ quiet_cmd_lzma = LZMA $@
cmd_lzma = { cat $(real-prereqs) | lzma -9; $(size_append); } > $@ cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
quiet_cmd_lzo = LZO $@ quiet_cmd_lzo = LZO $@
cmd_lzo = { cat $(real-prereqs) | lzop -9; $(size_append); } > $@ cmd_lzo = { cat $(real-prereqs) | $(_LZOP) -9; $(size_append); } > $@
quiet_cmd_lz4 = LZ4 $@ quiet_cmd_lz4 = LZ4 $@
cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout; \ cmd_lz4 = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \
$(size_append); } > $@ $(size_append); } > $@
# U-Boot mkimage # U-Boot mkimage
...@@ -393,7 +396,7 @@ quiet_cmd_xzkern = XZKERN $@ ...@@ -393,7 +396,7 @@ quiet_cmd_xzkern = XZKERN $@
$(size_append); } > $@ $(size_append); } > $@
quiet_cmd_xzmisc = XZMISC $@ quiet_cmd_xzmisc = XZMISC $@
cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@
# ASM offsets # ASM offsets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
...@@ -43,34 +43,30 @@ __modpost: ...@@ -43,34 +43,30 @@ __modpost:
include include/config/auto.conf include include/config/auto.conf
include scripts/Kbuild.include include scripts/Kbuild.include
kernelsymfile := $(objtree)/Module.symvers
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
MODPOST = scripts/mod/modpost \ MODPOST = scripts/mod/modpost \
$(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODVERSIONS),-m) \
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
$(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(KBUILD_MODPOST_WARN),-w) \
$(if $(KBUILD_MODPOST_WARN),-w) -o $@
ifdef MODPOST_VMLINUX ifdef MODPOST_VMLINUX
quiet_cmd_modpost = MODPOST vmlinux.o quiet_cmd_modpost = MODPOST $@
cmd_modpost = $(MODPOST) vmlinux.o cmd_modpost = $(MODPOST) $<
__modpost: vmlinux.symvers: vmlinux.o
$(call cmd,modpost) $(call cmd,modpost)
else __modpost: vmlinux.symvers
MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ else
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
MODPOST += $(wildcard vmlinux)
input-symdump := vmlinux.symvers
output-symdump := Module.symvers
else else
# set src + obj - they may be used in the modules's Makefile # set src + obj - they may be used in the modules's Makefile
...@@ -80,22 +76,57 @@ src := $(obj) ...@@ -80,22 +76,57 @@ src := $(obj)
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
$(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
# modpost option for external modules
MODPOST += -e
input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
endif
# modpost options for modules (both in-kernel and external)
MODPOST += \
$(addprefix -i ,$(wildcard $(input-symdump))) \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)
# 'make -i -k' ignores compile errors, and builds as many modules as possible.
ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
MODPOST += -n
endif endif
# find all modules listed in modules.order # Clear VPATH to not search for *.symvers in $(srctree). Check only $(objtree).
modules := $(sort $(shell cat $(MODORDER))) VPATH :=
$(input-symdump):
@echo >&2 'WARNING: Symbol version dump "$@" is missing.'
@echo >&2 ' Modules may not have dependencies or modversions.'
# Read out modules.order instead of expanding $(modules) to pass in modpost. # Read out modules.order to pass in modpost.
# Otherwise, allmodconfig would fail with "Argument list too long". # Otherwise, allmodconfig would fail with "Argument list too long".
quiet_cmd_modpost = MODPOST $(words $(modules)) modules quiet_cmd_modpost = MODPOST $@
cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T -
__modpost: $(output-symdump): $(MODORDER) $(input-symdump) FORCE
$(call cmd,modpost) $(call if_changed,modpost)
targets += $(output-symdump)
__modpost: $(output-symdump)
ifneq ($(KBUILD_MODPOST_NOFINAL),1) ifneq ($(KBUILD_MODPOST_NOFINAL),1)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
endif endif
PHONY += FORCE
FORCE:
existing-targets := $(wildcard $(sort $(targets)))
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
PHONY += FORCE
FORCE:
endif endif
.PHONY: $(PHONY) .PHONY: $(PHONY)
...@@ -45,7 +45,7 @@ if test "$(objtree)" != "$(srctree)"; then \ ...@@ -45,7 +45,7 @@ if test "$(objtree)" != "$(srctree)"; then \
false; \ false; \
fi ; \ fi ; \
$(srctree)/scripts/setlocalversion --save-scmversion; \ $(srctree)/scripts/setlocalversion --save-scmversion; \
tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \ tar -I $(_GZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
rm -f $(objtree)/.scmversion rm -f $(objtree)/.scmversion
...@@ -127,9 +127,9 @@ util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ ...@@ -127,9 +127,9 @@ util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
rm -r $(perf-tar); \ rm -r $(perf-tar); \
$(if $(findstring tar-src,$@),, \ $(if $(findstring tar-src,$@),, \
$(if $(findstring bz2,$@),bzip2, \ $(if $(findstring bz2,$@),$(_BZIP2), \
$(if $(findstring gz,$@),gzip, \ $(if $(findstring gz,$@),$(_GZIP), \
$(if $(findstring xz,$@),xz, \ $(if $(findstring xz,$@),$(XZ), \
$(error unknown target $@)))) \ $(error unknown target $@)))) \
-f -9 $(perf-tar).tar) -f -9 $(perf-tar).tar)
......
# SPDX-License-Identifier: GPL-2.0-only
#
# Build userspace programs for the target system
#
# Executables compiled from a single .c file
user-csingle := $(foreach m, $(userprogs), $(if $($(m)-objs),,$(m)))
# Executables linked based on several .o files
user-cmulti := $(foreach m, $(userprogs), $(if $($(m)-objs),$(m)))
# Objects compiled from .c files
user-cobjs := $(sort $(foreach m, $(userprogs), $($(m)-objs)))
user-csingle := $(addprefix $(obj)/, $(user-csingle))
user-cmulti := $(addprefix $(obj)/, $(user-cmulti))
user-cobjs := $(addprefix $(obj)/, $(user-cobjs))
user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
$($(target-stem)-userccflags)
user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
# Create an executable from a single .c file
quiet_cmd_user_cc_c = CC [U] $@
cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
$($(target-stem)-userldlibs)
$(user-csingle): $(obj)/%: $(src)/%.c FORCE
$(call if_changed_dep,user_cc_c)
# Link an executable based on list of .o files
quiet_cmd_user_ld = LD [U] $@
cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
$(addprefix $(obj)/, $($(target-stem)-objs)) \
$($(target-stem)-userldlibs)
$(user-cmulti): FORCE
$(call if_changed,user_ld)
$(call multi_depend, $(user-cmulti), , -objs)
# Create .o file from a .c file
quiet_cmd_user_cc_o_c = CC [U] $@
cmd_user_cc_o_c = $(CC) $(user_ccflags) -c -o $@ $<
$(user-cobjs): $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_dep,user_cc_o_c)
targets += $(user-csingle) $(user-cmulti) $(user-cobjs)
...@@ -160,7 +160,7 @@ struct item { ...@@ -160,7 +160,7 @@ struct item {
struct item *next; struct item *next;
unsigned int len; unsigned int len;
unsigned int hash; unsigned int hash;
char name[0]; char name[];
}; };
#define HASHSZ 256 #define HASHSZ 256
......
...@@ -34,8 +34,10 @@ use strict; ...@@ -34,8 +34,10 @@ use strict;
# $& (whole re) matches the complete objdump line with the stack growth # $& (whole re) matches the complete objdump line with the stack growth
# $1 (first bracket) matches the dynamic amount of the stack growth # $1 (first bracket) matches the dynamic amount of the stack growth
# #
# $sub: subroutine for special handling to check stack usage.
#
# use anything else and feel the pain ;) # use anything else and feel the pain ;)
my (@stack, $re, $dre, $x, $xs, $funcre); my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
{ {
my $arch = shift; my $arch = shift;
if ($arch eq "") { if ($arch eq "") {
...@@ -43,6 +45,11 @@ my (@stack, $re, $dre, $x, $xs, $funcre); ...@@ -43,6 +45,11 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
chomp($arch); chomp($arch);
} }
$min_stack = shift;
if ($min_stack eq "" || $min_stack !~ /^\d+$/) {
$min_stack = 100;
}
$x = "[0-9a-f]"; # hex character $x = "[0-9a-f]"; # hex character
$xs = "[0-9a-f ]"; # hex character or space $xs = "[0-9a-f ]"; # hex character or space
$funcre = qr/^$x* <(.*)>:$/; $funcre = qr/^$x* <(.*)>:$/;
...@@ -53,7 +60,8 @@ my (@stack, $re, $dre, $x, $xs, $funcre); ...@@ -53,7 +60,8 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
$dre = qr/^.*sub.*sp, sp, #(0x$x{1,8})/o; $dre = qr/^.*sub.*sp, sp, #(0x$x{1,8})/o;
} elsif ($arch eq 'arm') { } elsif ($arch eq 'arm') {
#c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o; $re = qr/.*sub.*sp, sp, #([0-9]{1,4})/o;
$sub = \&arm_push_handling;
} elsif ($arch =~ /^x86(_64)?$/ || $arch =~ /^i[3456]86$/) { } elsif ($arch =~ /^x86(_64)?$/ || $arch =~ /^i[3456]86$/) {
#c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
# or # or
...@@ -106,14 +114,51 @@ my (@stack, $re, $dre, $x, $xs, $funcre); ...@@ -106,14 +114,51 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
} }
} }
#
# To count stack usage of push {*, fp, ip, lr, pc} instruction in ARM,
# if FRAME POINTER is enabled.
# e.g. c01f0d48: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
#
sub arm_push_handling {
my $regex = qr/.*push.*fp, ip, lr, pc}/o;
my $size = 0;
my $line_arg = shift;
if ($line_arg =~ m/$regex/) {
$size = $line_arg =~ tr/,//;
$size = ($size + 1) * 4;
}
return $size;
}
# #
# main() # main()
# #
my ($func, $file, $lastslash); my ($func, $file, $lastslash, $total_size, $addr, $intro);
$total_size = 0;
while (my $line = <STDIN>) { while (my $line = <STDIN>) {
if ($line =~ m/$funcre/) { if ($line =~ m/$funcre/) {
$func = $1; $func = $1;
next if $line !~ m/^($xs*)/;
if ($total_size > $min_stack) {
push @stack, "$intro$total_size\n";
}
$addr = $1;
$addr =~ s/ /0/g;
$addr = "0x$addr";
$intro = "$addr $func [$file]:";
my $padlen = 56 - length($intro);
while ($padlen > 0) {
$intro .= ' ';
$padlen -= 8;
}
$total_size = 0;
} }
elsif ($line =~ m/(.*):\s*file format/) { elsif ($line =~ m/(.*):\s*file format/) {
$file = $1; $file = $1;
...@@ -134,37 +179,23 @@ while (my $line = <STDIN>) { ...@@ -134,37 +179,23 @@ while (my $line = <STDIN>) {
} }
next if ($size > 0x10000000); next if ($size > 0x10000000);
next if $line !~ m/^($xs*)/; $total_size += $size;
my $addr = $1;
$addr =~ s/ /0/g;
$addr = "0x$addr";
my $intro = "$addr $func [$file]:";
my $padlen = 56 - length($intro);
while ($padlen > 0) {
$intro .= ' ';
$padlen -= 8;
}
next if ($size < 100);
push @stack, "$intro$size\n";
} }
elsif (defined $dre && $line =~ m/$dre/) { elsif (defined $dre && $line =~ m/$dre/) {
my $size = "Dynamic ($1)"; my $size = $1;
next if $line !~ m/^($xs*)/;
my $addr = $1;
$addr =~ s/ /0/g;
$addr = "0x$addr";
my $intro = "$addr $func [$file]:"; $size = hex($size) if ($size =~ /^0x/);
my $padlen = 56 - length($intro); $total_size += $size;
while ($padlen > 0) {
$intro .= ' ';
$padlen -= 8;
} }
push @stack, "$intro$size\n"; elsif (defined $sub) {
my $size = &$sub($line);
$total_size += $size;
} }
} }
if ($total_size > $min_stack) {
push @stack, "$intro$total_size\n";
}
# Sort output by size (last field) # Sort output by size (last field)
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack; print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
...@@ -14,7 +14,7 @@ $(objtree)/$(obj)/randomize_layout_seed.h: FORCE ...@@ -14,7 +14,7 @@ $(objtree)/$(obj)/randomize_layout_seed.h: FORCE
$(call if_changed,create_randomize_layout_seed) $(call if_changed,create_randomize_layout_seed)
targets = randomize_layout_seed.h randomize_layout_hash.h targets = randomize_layout_seed.h randomize_layout_hash.h
hostcxxlibs-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p))) hostcxxlibs-y := $(GCC_PLUGIN)
always-y := $(hostcxxlibs-y) always-y := $(hostcxxlibs-y)
$(foreach p,$(hostcxxlibs-y:%.so=%),$(eval $(p)-objs := $(p).o)) $(foreach p,$(hostcxxlibs-y:%.so=%),$(eval $(p)-objs := $(p).o))
......
...@@ -64,7 +64,7 @@ configs=$(sed -e ' ...@@ -64,7 +64,7 @@ configs=$(sed -e '
d d
' $OUTFILE) ' $OUTFILE)
# The entries in the following list are not warned. # The entries in the following list do not result in an error.
# Please do not add a new entry. This list is only for existing ones. # Please do not add a new entry. This list is only for existing ones.
# The list will be reduced gradually, and deleted eventually. (hopefully) # The list will be reduced gradually, and deleted eventually. (hopefully)
# #
...@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS ...@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
for c in $configs for c in $configs
do do
warn=1 leak_error=1
for ignore in $config_leak_ignores for ignore in $config_leak_ignores
do do
if echo "$INFILE:$c" | grep -q "$ignore$"; then if echo "$INFILE:$c" | grep -q "$ignore$"; then
warn= leak_error=
break break
fi fi
done done
if [ "$warn" = 1 ]; then if [ "$leak_error" = 1 ]; then
echo "warning: $INFILE: leak $c to user-space" >&2 echo "error: $INFILE: leak $c to user-space" >&2
exit 1
fi fi
done done
......
...@@ -241,8 +241,6 @@ on_signals() ...@@ -241,8 +241,6 @@ on_signals()
} }
trap on_signals HUP INT QUIT TERM trap on_signals HUP INT QUIT TERM
#
#
# Use "make V=1" to debug this script # Use "make V=1" to debug this script
case "${KBUILD_VERBOSE}" in case "${KBUILD_VERBOSE}" in
*1*) *1*)
......
...@@ -6,7 +6,7 @@ ARCH=$2 ...@@ -6,7 +6,7 @@ ARCH=$2
SMP=$3 SMP=$3
PREEMPT=$4 PREEMPT=$4
PREEMPT_RT=$5 PREEMPT_RT=$5
CC=$6 CC_VERSION="$6"
LD=$7 LD=$7
vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; } vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
...@@ -62,7 +62,6 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)" ...@@ -62,7 +62,6 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY" printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
| sed 's/[[:space:]]*$//') | sed 's/[[:space:]]*$//')
printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION" printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
......
...@@ -41,4 +41,4 @@ ...@@ -41,4 +41,4 @@
# so we just ignore them to let readprofile continue to work. # so we just ignore them to let readprofile continue to work.
# (At least sparc64 has __crc_ in the middle). # (At least sparc64 has __crc_ in the middle).
$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2 $NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)' > $2
This diff is collapsed.
...@@ -111,29 +111,29 @@ buf_write(struct buffer *buf, const char *s, int len); ...@@ -111,29 +111,29 @@ buf_write(struct buffer *buf, const char *s, int len);
struct namespace_list { struct namespace_list {
struct namespace_list *next; struct namespace_list *next;
char namespace[0]; char namespace[];
}; };
struct module { struct module {
struct module *next; struct module *next;
const char *name;
int gpl_compatible; int gpl_compatible;
struct symbol *unres; struct symbol *unres;
int from_dump; /* 1 if module was loaded from *.symvers */
int is_vmlinux;
int seen; int seen;
int skip;
int has_init; int has_init;
int has_cleanup; int has_cleanup;
struct buffer dev_table_buf; struct buffer dev_table_buf;
char srcversion[25]; char srcversion[25];
int is_dot_o;
// Missing namespace dependencies // Missing namespace dependencies
struct namespace_list *missing_namespaces; struct namespace_list *missing_namespaces;
// Actual imported namespaces // Actual imported namespaces
struct namespace_list *imported_namespaces; struct namespace_list *imported_namespaces;
char name[];
}; };
struct elf_info { struct elf_info {
unsigned long size; size_t size;
Elf_Ehdr *hdr; Elf_Ehdr *hdr;
Elf_Shdr *sechdrs; Elf_Shdr *sechdrs;
Elf_Sym *symtab_start; Elf_Sym *symtab_start;
...@@ -187,16 +187,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, ...@@ -187,16 +187,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
void add_moddevtable(struct buffer *buf, struct module *mod); void add_moddevtable(struct buffer *buf, struct module *mod);
/* sumversion.c */ /* sumversion.c */
void maybe_frob_rcs_version(const char *modfilename,
char *version,
void *modinfo,
unsigned long modinfo_offset);
void get_src_version(const char *modname, char sum[], unsigned sumlen); void get_src_version(const char *modname, char sum[], unsigned sumlen);
/* from modpost.c */ /* from modpost.c */
void *grab_file(const char *filename, unsigned long *size); char *read_text_file(const char *filename);
char* get_next_line(unsigned long *pos, void *file, unsigned long size); char *get_line(char **stringp);
void release_file(void *file, unsigned long size);
enum loglevel { enum loglevel {
LOG_WARN, LOG_WARN,
......
...@@ -258,9 +258,8 @@ static int parse_file(const char *fname, struct md4_ctx *md) ...@@ -258,9 +258,8 @@ static int parse_file(const char *fname, struct md4_ctx *md)
char *file; char *file;
unsigned long i, len; unsigned long i, len;
file = grab_file(fname, &len); file = read_text_file(fname);
if (!file) len = strlen(file);
return 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
/* Collapse and ignore \ and CR. */ /* Collapse and ignore \ and CR. */
...@@ -287,7 +286,7 @@ static int parse_file(const char *fname, struct md4_ctx *md) ...@@ -287,7 +286,7 @@ static int parse_file(const char *fname, struct md4_ctx *md)
add_char(file[i], md); add_char(file[i], md);
} }
release_file(file, len); free(file);
return 1; return 1;
} }
/* Check whether the file is a static library or not */ /* Check whether the file is a static library or not */
...@@ -304,9 +303,8 @@ static int is_static_library(const char *objfile) ...@@ -304,9 +303,8 @@ static int is_static_library(const char *objfile)
* to figure out source files. */ * to figure out source files. */
static int parse_source_files(const char *objfile, struct md4_ctx *md) static int parse_source_files(const char *objfile, struct md4_ctx *md)
{ {
char *cmd, *file, *line, *dir; char *cmd, *file, *line, *dir, *pos;
const char *base; const char *base;
unsigned long flen, pos = 0;
int dirlen, ret = 0, check_files = 0; int dirlen, ret = 0, check_files = 0;
cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd"))); cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd")));
...@@ -324,14 +322,12 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) ...@@ -324,14 +322,12 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
strncpy(dir, objfile, dirlen); strncpy(dir, objfile, dirlen);
dir[dirlen] = '\0'; dir[dirlen] = '\0';
file = grab_file(cmd, &flen); file = read_text_file(cmd);
if (!file) {
warn("could not find %s for %s\n", cmd, objfile); pos = file;
goto out;
}
/* Sum all files in the same dir or subdirs. */ /* Sum all files in the same dir or subdirs. */
while ((line = get_next_line(&pos, file, flen)) != NULL) { while ((line = get_line(&pos))) {
char* p = line; char* p = line;
if (strncmp(line, "source_", sizeof("source_")-1) == 0) { if (strncmp(line, "source_", sizeof("source_")-1) == 0) {
...@@ -382,8 +378,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) ...@@ -382,8 +378,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
/* Everyone parsed OK */ /* Everyone parsed OK */
ret = 1; ret = 1;
out_file: out_file:
release_file(file, flen); free(file);
out:
free(dir); free(dir);
free(cmd); free(cmd);
return ret; return ret;
...@@ -392,106 +387,34 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) ...@@ -392,106 +387,34 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
/* Calc and record src checksum. */ /* Calc and record src checksum. */
void get_src_version(const char *modname, char sum[], unsigned sumlen) void get_src_version(const char *modname, char sum[], unsigned sumlen)
{ {
void *file; char *buf, *pos, *firstline;
unsigned long len;
struct md4_ctx md; struct md4_ctx md;
char *sources, *end, *fname; char *fname;
char filelist[PATH_MAX + 1]; char filelist[PATH_MAX + 1];
/* objects for a module are listed in the first line of *.mod file. */ /* objects for a module are listed in the first line of *.mod file. */
snprintf(filelist, sizeof(filelist), "%.*smod", snprintf(filelist, sizeof(filelist), "%.*smod",
(int)strlen(modname) - 1, modname); (int)strlen(modname) - 1, modname);
file = grab_file(filelist, &len); buf = read_text_file(filelist);
if (!file)
/* not a module or .mod file missing - ignore */
return;
sources = file; pos = buf;
firstline = get_line(&pos);
end = strchr(sources, '\n'); if (!firstline) {
if (!end) {
warn("bad ending versions file for %s\n", modname); warn("bad ending versions file for %s\n", modname);
goto release; goto free;
} }
*end = '\0';
md4_init(&md); md4_init(&md);
while ((fname = strsep(&sources, " ")) != NULL) { while ((fname = strsep(&firstline, " "))) {
if (!*fname) if (!*fname)
continue; continue;
if (!(is_static_library(fname)) && if (!(is_static_library(fname)) &&
!parse_source_files(fname, &md)) !parse_source_files(fname, &md))
goto release; goto free;
} }
md4_final_ascii(&md, sum, sumlen); md4_final_ascii(&md, sum, sumlen);
release: free:
release_file(file, len); free(buf);
}
static void write_version(const char *filename, const char *sum,
unsigned long offset)
{
int fd;
fd = open(filename, O_RDWR);
if (fd < 0) {
warn("changing sum in %s failed: %s\n",
filename, strerror(errno));
return;
}
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
warn("changing sum in %s:%lu failed: %s\n",
filename, offset, strerror(errno));
goto out;
}
if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
warn("writing sum in %s failed: %s\n",
filename, strerror(errno));
goto out;
}
out:
close(fd);
}
static int strip_rcs_crap(char *version)
{
unsigned int len, full_len;
if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
return 0;
/* Space for version string follows. */
full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
/* Move string to start with version number: prefix will be
* $Revision$ or $Revision: */
len = strlen("$Revision");
if (version[len] == ':' || version[len] == '$')
len++;
while (isspace(version[len]))
len++;
memmove(version, version+len, full_len-len);
full_len -= len;
/* Preserve up to next whitespace. */
len = 0;
while (version[len] && !isspace(version[len]))
len++;
memmove(version + len, version + strlen(version),
full_len - strlen(version));
return 1;
}
/* Clean up RCS-style version numbers. */
void maybe_frob_rcs_version(const char *modfilename,
char *version,
void *modinfo,
unsigned long version_offset)
{
if (strip_rcs_crap(version))
write_version(modfilename, version, version_offset);
} }
...@@ -3,14 +3,24 @@ ...@@ -3,14 +3,24 @@
set -e set -e
if [ $# != 1 ]; then
echo "Usage: $0 <modules.order>" >& 2
exit 1
fi
exit_code=0
# Check uniqueness of module names # Check uniqueness of module names
check_same_name_modules() check_same_name_modules()
{ {
for m in $(sed 's:.*/::' modules.order | sort | uniq -d) for m in $(sed 's:.*/::' $1 | sort | uniq -d)
do do
echo "warning: same module names found:" >&2 echo "error: the following would cause module name conflict:" >&2
sed -n "/\/$m/s:^: :p" modules.order >&2 sed -n "/\/$m/s:^: :p" modules.order >&2
exit_code=1
done done
} }
check_same_name_modules check_same_name_modules "$1"
exit $exit_code
...@@ -28,15 +28,15 @@ case "${1}" in ...@@ -28,15 +28,15 @@ case "${1}" in
opts= opts=
;; ;;
targz-pkg) targz-pkg)
opts=--gzip opts="-I ${_GZIP}"
tarball=${tarball}.gz tarball=${tarball}.gz
;; ;;
tarbz2-pkg) tarbz2-pkg)
opts=--bzip2 opts="-I ${_BZIP2}"
tarball=${tarball}.bz2 tarball=${tarball}.bz2
;; ;;
tarxz-pkg) tarxz-pkg)
opts=--xz opts="-I ${XZ}"
tarball=${tarball}.xz tarball=${tarball}.xz
;; ;;
*) *)
......
...@@ -20,4 +20,4 @@ case $SRCARCH in ...@@ -20,4 +20,4 @@ case $SRCARCH in
sparc) BCJ=--sparc ;; sparc) BCJ=--sparc ;;
esac esac
exec xz --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
# We cannot go as far as adding -Wpedantic since it emits too many warnings. # We cannot go as far as adding -Wpedantic since it emits too many warnings.
UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration
override c_flags = $(UAPI_CFLAGS) -Wp,-MD,$(depfile) -I$(objtree)/usr/include # In theory, we do not care -m32 or -m64 for header compile tests.
# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
UAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
# The following are excluded for now because they fail to build. # The following are excluded for now because they fail to build.
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment