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
Unified · Split
| @@ -954,11 +954,6 @@ When kbuild executes, the following steps are followed (roughly): · 953 unmodified lines | ||
| 954 | 954 | |
| 955 | 955 | From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). |
| 956 | 956 | |
| 957 | − KBUILD_ARFLAGS Options for $(AR) when creating archives | |
| 958 | − | |
| 959 | − $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic | |
| 960 | − mode) if this option is supported by $(AR). | |
| 961 | − | |
| 962 | 957 | KBUILD_LDS |
| 963 | 958 | |
| 964 | 959 | The linker script with full path. Assigned by the top-level Makefile. |
| @@ -498,10 +498,11 @@ build. · 497 unmodified lines | ||
| 498 | 498 | will be written containing all exported symbols that were not |
| 499 | 499 | defined in the kernel. |
| 500 | 500 | |
| 501 | −--- 6.3 Symbols From Another External Module | |
| 501 | +6.3 Symbols From Another External Module | |
| 502 | +---------------------------------------- | |
| 502 | 503 | |
| 503 | 504 | Sometimes, an external module uses exported symbols from |
| 504 | − another external module. kbuild needs to have full knowledge of | |
| 505 | + another external module. Kbuild needs to have full knowledge of | |
| 505 | 506 | all symbols to avoid spitting out warnings about undefined |
| 506 | 507 | symbols. Three solutions exist for this situation. |
| 507 | 508 | |
| @@ -521,7 +522,7 @@ build. · 13 unmodified lines | ||
| 521 | 522 | The top-level kbuild file would then look like:: |
| 522 | 523 | |
| 523 | 524 | #./Kbuild (or ./Makefile): |
| 524 | − obj-y := foo/ bar/ | |
| 525 | + obj-m := foo/ bar/ | |
| 525 | 526 | |
| 526 | 527 | And executing:: |
| 527 | 528 | |
| @@ -16,16 +16,21 @@ the kernel may be unreproducible, and how to avoid them. · 15 unmodified lines | ||
| 16 | 16 | Timestamps |
| 17 | 17 | ---------- |
| 18 | 18 | |
| 19 | −The kernel embeds a timestamp in two places: | |
| 19 | +The kernel embeds timestamps in three places: | |
| 20 | 20 | |
| 21 | 21 | * The version string exposed by ``uname()`` and included in |
| 22 | 22 | ``/proc/version`` |
| 23 | 23 | |
| 24 | 24 | * File timestamps in the embedded initramfs |
| 25 | 25 | |
| 26 | −By default the timestamp is the current time. This must be overridden | |
| 27 | −using the `KBUILD_BUILD_TIMESTAMP`_ variable. If you are building | |
| 28 | −from a git commit, you could use its commit date. | |
| 26 | +* If enabled via ``CONFIG_IKHEADERS``, file timestamps of kernel | |
| 27 | + headers embedded in the kernel or respective module, | |
| 28 | + exposed via ``/sys/kernel/kheaders.tar.xz`` | |
| 29 | + | |
| 30 | +By default the timestamp is the current time and in the case of | |
| 31 | +``kheaders`` the various files' modification times. This must | |
| 32 | +be overridden using the `KBUILD_BUILD_TIMESTAMP`_ variable. | |
| 33 | +If you are building from a git commit, you could use its commit date. | |
| 29 | 34 | |
| 30 | 35 | The kernel does *not* use the ``__DATE__`` and ``__TIME__`` macros, |
| 31 | 36 | and enables warnings if they are used. If you incorporate external |
| @@ -206,24 +206,8 @@ ifndef KBUILD_CHECKSRC · 205 unmodified lines | ||
| 206 | 206 | KBUILD_CHECKSRC = 0 |
| 207 | 207 | endif |
| 208 | 208 | |
| 209 | −# Use make M=dir to specify directory of external module to build | |
| 210 | −# Old syntax make ... SUBDIRS=$PWD is still supported | |
| 211 | −# Setting the environment variable KBUILD_EXTMOD take precedence | |
| 212 | −ifdef SUBDIRS | |
| 213 | − $(warning ================= WARNING ================) | |
| 214 | − $(warning 'SUBDIRS' will be removed after Linux 5.3) | |
| 215 | − $(warning ) | |
| 216 | − $(warning If you are building an individual subdirectory) | |
| 217 | − $(warning in the kernel tree, you can do like this:) | |
| 218 | − $(warning $$ make path/to/dir/you/want/to/build/) | |
| 219 | − $(warning (Do not forget the trailing slash)) | |
| 220 | − $(warning ) | |
| 221 | − $(warning If you are building an external module,) | |
| 222 | − $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead) | |
| 223 | − $(warning ==========================================) | |
| 224 | − KBUILD_EXTMOD ?= $(SUBDIRS) | |
| 225 | −endif | |
| 226 | − | |
| 209 | +# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the | |
| 210 | +# directory of external module to build. Setting M= takes precedence. | |
| 227 | 211 | ifeq ("$(origin M)", "command line") |
| 228 | 212 | KBUILD_EXTMOD := $(M) |
| 229 | 213 | endif |
| @@ -498,7 +482,6 @@ export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN · 268 unmodified lines | ||
| 498 | 482 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
| 499 | 483 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE |
| 500 | 484 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL |
| 501 | −export KBUILD_ARFLAGS | |
| 502 | 485 | |
| 503 | 486 | # Files to ignore in find ... statements |
| 504 | 487 | |
| @@ -914,9 +897,6 @@ ifdef CONFIG_RETPOLINE · 409 unmodified lines | ||
| 914 | 897 | KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) |
| 915 | 898 | endif |
| 916 | 899 | |
| 917 | −# use the deterministic mode of AR if available | |
| 918 | −KBUILD_ARFLAGS := $(call ar-option,D) | |
| 919 | − | |
| 920 | 900 | include scripts/Makefile.kasan |
| 921 | 901 | include scripts/Makefile.extrawarn |
| 922 | 902 | include scripts/Makefile.ubsan |
| @@ -50,7 +50,7 @@ endif · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc |
| 52 | 52 | |
| 53 | −BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) | |
| 53 | +BOOTARFLAGS := -crD | |
| 54 | 54 | |
| 55 | 55 | ifdef CONFIG_CC_IS_CLANG |
| 56 | 56 | BOOTCFLAGS += $(CLANG_FLAGS) |
| @@ -18,23 +18,6 @@ obj-$(CONFIG_SPU_BASE) += logo_spe_clut224.o · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | # How to generate logo's |
| 20 | 20 | |
| 21 | −# Use logo-cfiles to retrieve list of .c files to be built | |
| 22 | −logo-cfiles = $(notdir $(patsubst %.$(2), %.c, \ | |
| 23 | − $(wildcard $(srctree)/$(src)/*$(1).$(2)))) | |
| 24 | − | |
| 25 | − | |
| 26 | −# Mono logos | |
| 27 | −extra-y += $(call logo-cfiles,_mono,pbm) | |
| 28 | − | |
| 29 | −# VGA16 logos | |
| 30 | −extra-y += $(call logo-cfiles,_vga16,ppm) | |
| 31 | − | |
| 32 | −# 224 Logos | |
| 33 | −extra-y += $(call logo-cfiles,_clut224,ppm) | |
| 34 | − | |
| 35 | −# Gray 256 | |
| 36 | −extra-y += $(call logo-cfiles,_gray256,pgm) | |
| 37 | − | |
| 38 | 21 | pnmtologo := scripts/pnmtologo |
| 39 | 22 | |
| 40 | 23 | # Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..." |
| @@ -55,5 +38,5 @@ $(obj)/%_clut224.c: $(src)/%_clut224.ppm $(pnmtologo) FORCE · 14 unmodified lines | ||
| 55 | 38 | $(obj)/%_gray256.c: $(src)/%_gray256.pgm $(pnmtologo) FORCE |
| 56 | 39 | $(call if_changed,logo) |
| 57 | 40 | |
| 58 | −# Files generated that shall be removed upon make clean | |
| 59 | −clean-files := *.o *_mono.c *_vga16.c *_clut224.c *_gray256.c | |
| 41 | +# generated C files | |
| 42 | +targets += *_mono.c *_vga16.c *_clut224.c *_gray256.c | |
| @@ -71,7 +71,10 @@ done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1 · 70 unmodified lines | ||
| 71 | 71 | find $cpio_dir -type f -print0 | |
| 72 | 72 | xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;' |
| 73 | 73 | |
| 74 | −tar -Jcf $tarfile -C $cpio_dir/ . > /dev/null | |
| 74 | +# Create archive and try to normalize metadata for reproducibility | |
| 75 | +tar "${KBUILD_BUILD_TIMESTAMP:+--mtime=$KBUILD_BUILD_TIMESTAMP}" \ | |
| 76 | + --owner=0 --group=0 --sort=name --numeric-owner \ | |
| 77 | + -Jcf $tarfile -C $cpio_dir/ . > /dev/null | |
| 75 | 78 | |
| 76 | 79 | echo "$src_files_md5" > kernel/kheaders.md5 |
| 77 | 80 | echo "$obj_files_md5" >> kernel/kheaders.md5 |
| @@ -143,11 +143,6 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e · 142 unmodified lines | ||
| 143 | 143 | # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) |
| 144 | 144 | ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) |
| 145 | 145 | |
| 146 | −# ar-option | |
| 147 | −# Usage: KBUILD_ARFLAGS := $(call ar-option,D) | |
| 148 | −# Important: no spaces around options | |
| 149 | −ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) | |
| 150 | − | |
| 151 | 146 | # ld-version |
| 152 | 147 | # Note this is mainly for HJ Lu's 3 number binutil versions |
| 153 | 148 | ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) |
| @@ -389,7 +389,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; · 388 unmodified lines | ||
| 389 | 389 | ifdef builtin-target |
| 390 | 390 | |
| 391 | 391 | quiet_cmd_ar_builtin = AR $@ |
| 392 | − cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 392 | + cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs) | |
| 393 | 393 | |
| 394 | 394 | $(builtin-target): $(real-obj-y) FORCE |
| 395 | 395 | $(call if_changed,ar_builtin) |
| @@ -232,7 +232,7 @@ quiet_cmd_ld = LD $@ · 231 unmodified lines | ||
| 232 | 232 | # --------------------------------------------------------------------------- |
| 233 | 233 | |
| 234 | 234 | quiet_cmd_ar = AR $@ |
| 235 | − cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 235 | + cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs) | |
| 236 | 236 | |
| 237 | 237 | # Objcopy |
| 238 | 238 | # --------------------------------------------------------------------------- |
| @@ -2652,15 +2652,20 @@ int main(int argc, char **argv) · 2651 unmodified lines | ||
| 2652 | 2652 | fatal("modpost: Section mismatches detected.\n" |
| 2653 | 2653 | "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); |
| 2654 | 2654 | for (n = 0; n < SYMBOL_HASH_SIZE; n++) { |
| 2655 | − struct symbol *s = symbolhash[n]; | |
| 2655 | + struct symbol *s; | |
| 2656 | + | |
| 2657 | + for (s = symbolhash[n]; s; s = s->next) { | |
| 2658 | + /* | |
| 2659 | + * Do not check "vmlinux". This avoids the same warnings | |
| 2660 | + * shown twice, and false-positives for ARCH=um. | |
| 2661 | + */ | |
| 2662 | + if (is_vmlinux(s->module->name) && !s->module->is_dot_o) | |
| 2663 | + continue; | |
| 2656 | 2664 | |
| 2657 | − while (s) { | |
| 2658 | 2665 | if (s->is_static) |
| 2659 | 2666 | warn("\"%s\" [%s] is a static %s\n", |
| 2660 | 2667 | s->name, s->module->name, |
| 2661 | 2668 | export_str(s->export)); |
| 2662 | − | |
| 2663 | − s = s->next; | |
| 2664 | 2669 | } |
| 2665 | 2670 | } |
| 2666 | 2671 | |
| @@ -65,13 +65,14 @@ · 64 unmodified lines | ||
| 65 | 65 | use warnings; |
| 66 | 66 | use strict; |
| 67 | 67 | use File::Find; |
| 68 | +use File::Spec; | |
| 68 | 69 | |
| 69 | 70 | my $nm = ($ENV{'NM'} || "nm") . " -p"; |
| 70 | 71 | my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; |
| 71 | −my $srctree = ""; | |
| 72 | −my $objtree = ""; | |
| 73 | −$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); | |
| 74 | −$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); | |
| 72 | +my $srctree = File::Spec->curdir(); | |
| 73 | +my $objtree = File::Spec->curdir(); | |
| 74 | +$srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); | |
| 75 | +$objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); | |
| 75 | 76 | |
| 76 | 77 | if ($#ARGV != -1) { |
| 77 | 78 | print STDERR "usage: $0 takes no parameters\n"; |
| @@ -231,9 +232,9 @@ sub do_nm · 153 unmodified lines | ||
| 231 | 232 | } |
| 232 | 233 | ($source = $basename) =~ s/\.o$//; |
| 233 | 234 | if (-e "$source.c" || -e "$source.S") { |
| 234 | − $source = "$objtree$File::Find::dir/$source"; | |
| 235 | + $source = File::Spec->catfile($objtree, $File::Find::dir, $source) | |
| 235 | 236 | } else { |
| 236 | − $source = "$srctree$File::Find::dir/$source"; | |
| 237 | + $source = File::Spec->catfile($srctree, $File::Find::dir, $source) | |
| 237 | 238 | } |
| 238 | 239 | if (! -e "$source.c" && ! -e "$source.S") { |
| 239 | 240 | # No obvious source, exclude the object if it is conglomerate |
| @@ -126,7 +126,7 @@ scm_version() · 125 unmodified lines | ||
| 126 | 126 | |
| 127 | 127 | collect_files() |
| 128 | 128 | { |
| 129 | − local file res | |
| 129 | + local file res= | |
| 130 | 130 | |
| 131 | 131 | for file; do |
| 132 | 132 | case "$file" in |
| @@ -13,9 +13,6 @@ integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyrin · 12 unmodified lines | ||
| 13 | 13 | integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ |
| 14 | 14 | platform_certs/load_uefi.o |
| 15 | 15 | integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o |
| 16 | −$(obj)/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar | |
| 17 | 16 | |
| 18 | −subdir-$(CONFIG_IMA) += ima | |
| 19 | 17 | obj-$(CONFIG_IMA) += ima/ |
| 20 | −subdir-$(CONFIG_EVM) += evm | |
| 21 | 18 | obj-$(CONFIG_EVM) += evm/ |
| @@ -29,13 +29,11 @@ header-test- += linux/android/binderfs.h · 28 unmodified lines | ||
| 29 | 29 | header-test-$(CONFIG_CPU_BIG_ENDIAN) += linux/byteorder/big_endian.h |
| 30 | 30 | header-test-$(CONFIG_CPU_LITTLE_ENDIAN) += linux/byteorder/little_endian.h |
| 31 | 31 | header-test- += linux/coda.h |
| 32 | −header-test- += linux/coda_psdev.h | |
| 33 | 32 | header-test- += linux/elfcore.h |
| 34 | 33 | header-test- += linux/errqueue.h |
| 35 | 34 | header-test- += linux/fsmap.h |
| 36 | 35 | header-test- += linux/hdlc/ioctl.h |
| 37 | 36 | header-test- += linux/ivtv.h |
| 38 | −header-test- += linux/jffs2.h | |
| 39 | 37 | header-test- += linux/kexec.h |
| 40 | 38 | header-test- += linux/matroxfb.h |
| 41 | 39 | header-test- += linux/netfilter_ipv4/ipt_LOG.h |
| @@ -55,20 +53,12 @@ header-test- += linux/v4l2-mediabus.h · 13 unmodified lines | ||
| 55 | 53 | header-test- += linux/v4l2-subdev.h |
| 56 | 54 | header-test- += linux/videodev2.h |
| 57 | 55 | header-test- += linux/vm_sockets.h |
| 58 | −header-test- += scsi/scsi_bsg_fc.h | |
| 59 | −header-test- += scsi/scsi_netlink.h | |
| 60 | −header-test- += scsi/scsi_netlink_fc.h | |
| 61 | 56 | header-test- += sound/asequencer.h |
| 62 | 57 | header-test- += sound/asoc.h |
| 63 | 58 | header-test- += sound/asound.h |
| 64 | 59 | header-test- += sound/compress_offload.h |
| 65 | 60 | header-test- += sound/emu10k1.h |
| 66 | 61 | header-test- += sound/sfnt_info.h |
| 67 | −header-test- += sound/sof/eq.h | |
| 68 | −header-test- += sound/sof/fw.h | |
| 69 | −header-test- += sound/sof/header.h | |
| 70 | −header-test- += sound/sof/manifest.h | |
| 71 | −header-test- += sound/sof/trace.h | |
| 72 | 62 | header-test- += xen/evtchn.h |
| 73 | 63 | header-test- += xen/gntdev.h |
| 74 | 64 | header-test- += xen/privcmd.h |