Kbuild fixes for v5.4

- remove unneeded ar-option and KBUILD_ARFLAGS
 
  - remove long-deprecated SUBDIRS
 
  - fix modpost to suppress false-positive warnings for UML builds
 
  - fix namespace.pl to handle relative paths to ${objtree}, ${srctree}
 
  - make setlocalversion work for /bin/sh
 
  - make header archive reproducible
 
  - fix some Makefiles and documents
 -----BEGIN PGP SIGNATURE-----
 
 iQJSBAABCgA8FiEEbmPs18K1szRHjPqEPYsBB53g2wYFAl2YPUEeHHlhbWFkYS5t
 YXNhaGlyb0Bzb2Npb25leHQuY29tAAoJED2LAQed4NsGVu4P/3Qv7Ov3/R4BlgYb
 +LaKupCY/ADE5bRAv/N5AAy37+TJmTLQswN2/JwHflYvTeWd4kZjquFpJkFNwMsk
 Qlb79NQvyM9+NlFfSFjap8HBNb0J8A+92aKmrHmh1sQqJJs6JPZ0MOGoAXmgsJaN
 SPLvhqophKpmYu7Oa0x2aC2kq+1DnCQyMLTOuVCdrtF0tF8w0hiowDz5GOmOi1U6
 VK2ECfzjenFkfbqZOUVBPVfPR9hMpmVBdKdFLwD/iTKVkShZcWmdbxk/ADbemyet
 2njehRF2HGp7opbwM4AxIeIubCqYSkThUpLJarKWk/8W87gksH6pCR8yIq1nOwkO
 l+/GY2YdvkBdDCkSKpLiQxtJaqnZb8Yv1ZPvCfGF09Ba8tFtwX+HSecSkLFHGyJv
 K9FD0XSOFBkQesZWdpIr/xeLwwiuSH80QACrub1Z5Q4OCURaBkKwrO/eDG1/2Xle
 YKGZO2va2VVkeo5bisOZ2vfISwZrtiaGakQ8vTdq/5RO59/JvQjsGB8KbccaKXAu
 Ozk8vVqkwTmLP6gzIEd2Wr/ICNGuAVc0EELT7lj07hcd6rzsCxPWVXqTFsCkGBJe
 587i1jeH1z9oyrHUcP6dhR3joIuOUuUJk1uR7YZq4L4POSvrJnvzMFkSv6tBKL2p
 Uq9qD7mpt/9zl3PART7HK9KYfTGJ
 =fSXc
 -----END PGP SIGNATURE-----

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

Pull Kbuild fixes from Masahiro Yamada:

 - remove unneeded ar-option and KBUILD_ARFLAGS

 - remove long-deprecated SUBDIRS

 - fix modpost to suppress false-positive warnings for UML builds

 - fix namespace.pl to handle relative paths to ${objtree}, ${srctree}

 - make setlocalversion work for /bin/sh

 - make header archive reproducible

 - fix some Makefiles and documents

* tag 'kbuild-fixes-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kheaders: make headers archive reproducible
  kbuild: update compile-test header list for v5.4-rc2
  kbuild: two minor updates for Documentation/kbuild/modules.rst
  scripts/setlocalversion: clear local variable to make it work for sh
  namespace: fix namespace.pl script to support relative paths
  video/logo: do not generate unneeded logo C files
  video/logo: remove unneeded *.o pattern from clean-files
  integrity: remove pointless subdir-$(CONFIG_...)
  integrity: remove unneeded, broken attempt to add -fshort-wchar
  modpost: fix static EXPORT_SYMBOL warnings for UML build
  kbuild: correct formatting of header in kbuild module docs
  kbuild: remove SUBDIRS support
  kbuild: remove ar-option and KBUILD_ARFLAGS
This commit is contained in:
Linus Torvalds 2019-10-05 12:56:59 -07:00
commit 2d00aee21a
15 changed files with 41 additions and 86 deletions

View File

@ -954,11 +954,6 @@ When kbuild executes, the following steps are followed (roughly):
From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
KBUILD_ARFLAGS Options for $(AR) when creating archives
$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
mode) if this option is supported by $(AR).
KBUILD_LDS KBUILD_LDS
The linker script with full path. Assigned by the top-level Makefile. The linker script with full path. Assigned by the top-level Makefile.

View File

@ -498,10 +498,11 @@ build.
will be written containing all exported symbols that were not will be written containing all exported symbols that were not
defined in the kernel. defined in the kernel.
--- 6.3 Symbols From Another External Module 6.3 Symbols From Another External Module
----------------------------------------
Sometimes, an external module uses exported symbols from Sometimes, an external module uses exported symbols from
another external module. kbuild needs to have full knowledge of another external module. Kbuild needs to have full knowledge of
all symbols to avoid spitting out warnings about undefined all symbols to avoid spitting out warnings about undefined
symbols. Three solutions exist for this situation. symbols. Three solutions exist for this situation.
@ -521,7 +522,7 @@ build.
The top-level kbuild file would then look like:: The top-level kbuild file would then look like::
#./Kbuild (or ./Makefile): #./Kbuild (or ./Makefile):
obj-y := foo/ bar/ obj-m := foo/ bar/
And executing:: And executing::

View File

@ -16,16 +16,21 @@ the kernel may be unreproducible, and how to avoid them.
Timestamps Timestamps
---------- ----------
The kernel embeds a timestamp in two places: The kernel embeds timestamps in three places:
* The version string exposed by ``uname()`` and included in * The version string exposed by ``uname()`` and included in
``/proc/version`` ``/proc/version``
* File timestamps in the embedded initramfs * File timestamps in the embedded initramfs
By default the timestamp is the current time. This must be overridden * If enabled via ``CONFIG_IKHEADERS``, file timestamps of kernel
using the `KBUILD_BUILD_TIMESTAMP`_ variable. If you are building headers embedded in the kernel or respective module,
from a git commit, you could use its commit date. exposed via ``/sys/kernel/kheaders.tar.xz``
By default the timestamp is the current time and in the case of
``kheaders`` the various files' modification times. This must
be overridden using the `KBUILD_BUILD_TIMESTAMP`_ variable.
If you are building from a git commit, you could use its commit date.
The kernel does *not* use the ``__DATE__`` and ``__TIME__`` macros, The kernel does *not* use the ``__DATE__`` and ``__TIME__`` macros,
and enables warnings if they are used. If you incorporate external and enables warnings if they are used. If you incorporate external

View File

@ -206,24 +206,8 @@ ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0 KBUILD_CHECKSRC = 0
endif endif
# Use make M=dir to specify directory of external module to build # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
# Old syntax make ... SUBDIRS=$PWD is still supported # directory of external module to build. Setting M= takes precedence.
# Setting the environment variable KBUILD_EXTMOD take precedence
ifdef SUBDIRS
$(warning ================= WARNING ================)
$(warning 'SUBDIRS' will be removed after Linux 5.3)
$(warning )
$(warning If you are building an individual subdirectory)
$(warning in the kernel tree, you can do like this:)
$(warning $$ make path/to/dir/you/want/to/build/)
$(warning (Do not forget the trailing slash))
$(warning )
$(warning If you are building an external module,)
$(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
$(warning ==========================================)
KBUILD_EXTMOD ?= $(SUBDIRS)
endif
ifeq ("$(origin M)", "command line") ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M) KBUILD_EXTMOD := $(M)
endif endif
@ -498,7 +482,6 @@ export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
export KBUILD_ARFLAGS
# Files to ignore in find ... statements # Files to ignore in find ... statements
@ -914,9 +897,6 @@ ifdef CONFIG_RETPOLINE
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
endif endif
# use the deterministic mode of AR if available
KBUILD_ARFLAGS := $(call ar-option,D)
include scripts/Makefile.kasan include scripts/Makefile.kasan
include scripts/Makefile.extrawarn include scripts/Makefile.extrawarn
include scripts/Makefile.ubsan include scripts/Makefile.ubsan

View File

@ -50,7 +50,7 @@ endif
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) BOOTARFLAGS := -crD
ifdef CONFIG_CC_IS_CLANG ifdef CONFIG_CC_IS_CLANG
BOOTCFLAGS += $(CLANG_FLAGS) BOOTCFLAGS += $(CLANG_FLAGS)

View File

@ -18,23 +18,6 @@ obj-$(CONFIG_SPU_BASE) += logo_spe_clut224.o
# How to generate logo's # How to generate logo's
# Use logo-cfiles to retrieve list of .c files to be built
logo-cfiles = $(notdir $(patsubst %.$(2), %.c, \
$(wildcard $(srctree)/$(src)/*$(1).$(2))))
# Mono logos
extra-y += $(call logo-cfiles,_mono,pbm)
# VGA16 logos
extra-y += $(call logo-cfiles,_vga16,ppm)
# 224 Logos
extra-y += $(call logo-cfiles,_clut224,ppm)
# Gray 256
extra-y += $(call logo-cfiles,_gray256,pgm)
pnmtologo := scripts/pnmtologo pnmtologo := scripts/pnmtologo
# Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..." # Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..."
@ -55,5 +38,5 @@ $(obj)/%_clut224.c: $(src)/%_clut224.ppm $(pnmtologo) FORCE
$(obj)/%_gray256.c: $(src)/%_gray256.pgm $(pnmtologo) FORCE $(obj)/%_gray256.c: $(src)/%_gray256.pgm $(pnmtologo) FORCE
$(call if_changed,logo) $(call if_changed,logo)
# Files generated that shall be removed upon make clean # generated C files
clean-files := *.o *_mono.c *_vga16.c *_clut224.c *_gray256.c targets += *_mono.c *_vga16.c *_clut224.c *_gray256.c

View File

@ -71,7 +71,10 @@ done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1
find $cpio_dir -type f -print0 | find $cpio_dir -type f -print0 |
xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;' xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'
tar -Jcf $tarfile -C $cpio_dir/ . > /dev/null # Create archive and try to normalize metadata for reproducibility
tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \
--owner=0 --group=0 --sort=name --numeric-owner \
-Jcf $tarfile -C $cpio_dir/ . > /dev/null
echo "$src_files_md5" > kernel/kheaders.md5 echo "$src_files_md5" > kernel/kheaders.md5
echo "$obj_files_md5" >> kernel/kheaders.md5 echo "$obj_files_md5" >> kernel/kheaders.md5

View File

@ -143,11 +143,6 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
# ar-option
# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
# Important: no spaces around options
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
# ld-version # ld-version
# Note this is mainly for HJ Lu's 3 number binutil versions # Note this is mainly for HJ Lu's 3 number binutil versions
ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)

View File

@ -389,7 +389,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
ifdef builtin-target ifdef builtin-target
quiet_cmd_ar_builtin = AR $@ quiet_cmd_ar_builtin = AR $@
cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
$(builtin-target): $(real-obj-y) FORCE $(builtin-target): $(real-obj-y) FORCE
$(call if_changed,ar_builtin) $(call if_changed,ar_builtin)

View File

@ -232,7 +232,7 @@ quiet_cmd_ld = LD $@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_ar = AR $@ quiet_cmd_ar = AR $@
cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs)
# Objcopy # Objcopy
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -2652,15 +2652,20 @@ int main(int argc, char **argv)
fatal("modpost: Section mismatches detected.\n" fatal("modpost: Section mismatches detected.\n"
"Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n");
for (n = 0; n < SYMBOL_HASH_SIZE; n++) { for (n = 0; n < SYMBOL_HASH_SIZE; n++) {
struct symbol *s = symbolhash[n]; struct symbol *s;
for (s = symbolhash[n]; s; s = s->next) {
/*
* Do not check "vmlinux". This avoids the same warnings
* shown twice, and false-positives for ARCH=um.
*/
if (is_vmlinux(s->module->name) && !s->module->is_dot_o)
continue;
while (s) {
if (s->is_static) if (s->is_static)
warn("\"%s\" [%s] is a static %s\n", warn("\"%s\" [%s] is a static %s\n",
s->name, s->module->name, s->name, s->module->name,
export_str(s->export)); export_str(s->export));
s = s->next;
} }
} }

View File

@ -65,13 +65,14 @@
use warnings; use warnings;
use strict; use strict;
use File::Find; use File::Find;
use File::Spec;
my $nm = ($ENV{'NM'} || "nm") . " -p"; my $nm = ($ENV{'NM'} || "nm") . " -p";
my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment";
my $srctree = ""; my $srctree = File::Spec->curdir();
my $objtree = ""; my $objtree = File::Spec->curdir();
$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); $srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'}));
$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); $objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'}));
if ($#ARGV != -1) { if ($#ARGV != -1) {
print STDERR "usage: $0 takes no parameters\n"; print STDERR "usage: $0 takes no parameters\n";
@ -231,9 +232,9 @@ sub do_nm
} }
($source = $basename) =~ s/\.o$//; ($source = $basename) =~ s/\.o$//;
if (-e "$source.c" || -e "$source.S") { if (-e "$source.c" || -e "$source.S") {
$source = "$objtree$File::Find::dir/$source"; $source = File::Spec->catfile($objtree, $File::Find::dir, $source)
} else { } else {
$source = "$srctree$File::Find::dir/$source"; $source = File::Spec->catfile($srctree, $File::Find::dir, $source)
} }
if (! -e "$source.c" && ! -e "$source.S") { if (! -e "$source.c" && ! -e "$source.S") {
# No obvious source, exclude the object if it is conglomerate # No obvious source, exclude the object if it is conglomerate

View File

@ -126,7 +126,7 @@ scm_version()
collect_files() collect_files()
{ {
local file res local file res=
for file; do for file; do
case "$file" in case "$file" in

View File

@ -13,9 +13,6 @@ integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyrin
integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \
platform_certs/load_uefi.o platform_certs/load_uefi.o
integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o
$(obj)/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar
subdir-$(CONFIG_IMA) += ima
obj-$(CONFIG_IMA) += ima/ obj-$(CONFIG_IMA) += ima/
subdir-$(CONFIG_EVM) += evm
obj-$(CONFIG_EVM) += evm/ obj-$(CONFIG_EVM) += evm/

View File

@ -29,13 +29,11 @@ header-test- += linux/android/binderfs.h
header-test-$(CONFIG_CPU_BIG_ENDIAN) += linux/byteorder/big_endian.h header-test-$(CONFIG_CPU_BIG_ENDIAN) += linux/byteorder/big_endian.h
header-test-$(CONFIG_CPU_LITTLE_ENDIAN) += linux/byteorder/little_endian.h header-test-$(CONFIG_CPU_LITTLE_ENDIAN) += linux/byteorder/little_endian.h
header-test- += linux/coda.h header-test- += linux/coda.h
header-test- += linux/coda_psdev.h
header-test- += linux/elfcore.h header-test- += linux/elfcore.h
header-test- += linux/errqueue.h header-test- += linux/errqueue.h
header-test- += linux/fsmap.h header-test- += linux/fsmap.h
header-test- += linux/hdlc/ioctl.h header-test- += linux/hdlc/ioctl.h
header-test- += linux/ivtv.h header-test- += linux/ivtv.h
header-test- += linux/jffs2.h
header-test- += linux/kexec.h header-test- += linux/kexec.h
header-test- += linux/matroxfb.h header-test- += linux/matroxfb.h
header-test- += linux/netfilter_ipv4/ipt_LOG.h header-test- += linux/netfilter_ipv4/ipt_LOG.h
@ -55,20 +53,12 @@ header-test- += linux/v4l2-mediabus.h
header-test- += linux/v4l2-subdev.h header-test- += linux/v4l2-subdev.h
header-test- += linux/videodev2.h header-test- += linux/videodev2.h
header-test- += linux/vm_sockets.h header-test- += linux/vm_sockets.h
header-test- += scsi/scsi_bsg_fc.h
header-test- += scsi/scsi_netlink.h
header-test- += scsi/scsi_netlink_fc.h
header-test- += sound/asequencer.h header-test- += sound/asequencer.h
header-test- += sound/asoc.h header-test- += sound/asoc.h
header-test- += sound/asound.h header-test- += sound/asound.h
header-test- += sound/compress_offload.h header-test- += sound/compress_offload.h
header-test- += sound/emu10k1.h header-test- += sound/emu10k1.h
header-test- += sound/sfnt_info.h header-test- += sound/sfnt_info.h
header-test- += sound/sof/eq.h
header-test- += sound/sof/fw.h
header-test- += sound/sof/header.h
header-test- += sound/sof/manifest.h
header-test- += sound/sof/trace.h
header-test- += xen/evtchn.h header-test- += xen/evtchn.h
header-test- += xen/gntdev.h header-test- += xen/gntdev.h
header-test- += xen/privcmd.h header-test- += xen/privcmd.h