History

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

Linus Torvalds committed 7 years ago

Commit 2d00aee2 parents 126195c 86cdd2f15 files · +41 −86Browse files

Unified · Split

15 files
  1. Documentation/kbuild/makefiles.rst +0 −5
  2. Documentation/kbuild/modules.rst +4 −3
  3. Documentation/kbuild/reproducible-builds.rst +9 −4
  4. Makefile +2 −22
  5. arch/powerpc/boot/Makefile +1 −1
  6. drivers/video/logo/Makefile +2 −19
  7. kernel/gen_kheaders.sh +4 −1
  8. scripts/Kbuild.include +0 −5
  9. scripts/Makefile.build +1 −1
  10. scripts/Makefile.lib +1 −1
  11. scripts/mod/modpost.c +9 −4
  12. scripts/namespace.pl +7 −6
  13. scripts/setlocalversion +1 −1
  14. security/integrity/Makefile +0 −3
  15. usr/include/Makefile +0 −10
Documentation/kbuild/makefiles.rst+0−5
@@ -954,11 +954,6 @@ When kbuild executes, the following steps are followed (roughly): · 953 unmodified lines
954954
955955 From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
956956
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−
962957 KBUILD_LDS
963958
964959 The linker script with full path. Assigned by the top-level Makefile.
Documentation/kbuild/modules.rst+4−3
@@ -498,10 +498,11 @@ build. · 497 unmodified lines
498498 will be written containing all exported symbols that were not
499499 defined in the kernel.
500500
501−--- 6.3 Symbols From Another External Module
501+6.3 Symbols From Another External Module
502+----------------------------------------
502503
503504 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
505506 all symbols to avoid spitting out warnings about undefined
506507 symbols. Three solutions exist for this situation.
507508
@@ -521,7 +522,7 @@ build. · 13 unmodified lines
521522 The top-level kbuild file would then look like::
522523
523524 #./Kbuild (or ./Makefile):
524− obj-y := foo/ bar/
525+ obj-m := foo/ bar/
525526
526527 And executing::
527528
Documentation/kbuild/reproducible-builds.rst+9−4
@@ -16,16 +16,21 @@ the kernel may be unreproducible, and how to avoid them. · 15 unmodified lines
1616 Timestamps
1717 ----------
1818
19−The kernel embeds a timestamp in two places:
19+The kernel embeds timestamps in three places:
2020
2121 * The version string exposed by ``uname()`` and included in
2222 ``/proc/version``
2323
2424 * File timestamps in the embedded initramfs
2525
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.
2934
3035 The kernel does *not* use the ``__DATE__`` and ``__TIME__`` macros,
3136 and enables warnings if they are used. If you incorporate external
Makefile+2−22
@@ -206,24 +206,8 @@ ifndef KBUILD_CHECKSRC · 205 unmodified lines
206206 KBUILD_CHECKSRC = 0
207207 endif
208208
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.
227211 ifeq ("$(origin M)", "command line")
228212 KBUILD_EXTMOD := $(M)
229213 endif
@@ -498,7 +482,6 @@ export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN · 268 unmodified lines
498482 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
499483 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
500484 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
501−export KBUILD_ARFLAGS
502485
503486 # Files to ignore in find ... statements
504487
@@ -914,9 +897,6 @@ ifdef CONFIG_RETPOLINE · 409 unmodified lines
914897 KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
915898 endif
916899
917−# use the deterministic mode of AR if available
918−KBUILD_ARFLAGS := $(call ar-option,D)
919−
920900 include scripts/Makefile.kasan
921901 include scripts/Makefile.extrawarn
922902 include scripts/Makefile.ubsan
arch/powerpc/boot/Makefile+1−1
@@ -50,7 +50,7 @@ endif · 49 unmodified lines
5050
5151 BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
5252
53−BOOTARFLAGS := -cr$(KBUILD_ARFLAGS)
53+BOOTARFLAGS := -crD
5454
5555 ifdef CONFIG_CC_IS_CLANG
5656 BOOTCFLAGS += $(CLANG_FLAGS)
drivers/video/logo/Makefile+2−19
@@ -18,23 +18,6 @@ obj-$(CONFIG_SPU_BASE) += logo_spe_clut224.o · 17 unmodified lines
1818
1919 # How to generate logo's
2020
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−
3821 pnmtologo := scripts/pnmtologo
3922
4023 # 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
5538 $(obj)/%_gray256.c: $(src)/%_gray256.pgm $(pnmtologo) FORCE
5639 $(call if_changed,logo)
5740
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
kernel/gen_kheaders.sh+4−1
@@ -71,7 +71,10 @@ done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1 · 70 unmodified lines
7171 find $cpio_dir -type f -print0 |
7272 xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'
7373
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
7578
7679 echo "$src_files_md5" > kernel/kheaders.md5
7780 echo "$obj_files_md5" >> kernel/kheaders.md5
scripts/Kbuild.include+0−5
@@ -143,11 +143,6 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e · 142 unmodified lines
143143 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
144144 ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
145145
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−
151146 # ld-version
152147 # Note this is mainly for HJ Lu's 3 number binutil versions
153148 ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
scripts/Makefile.build+1−1
@@ -389,7 +389,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; · 388 unmodified lines
389389 ifdef builtin-target
390390
391391 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)
393393
394394 $(builtin-target): $(real-obj-y) FORCE
395395 $(call if_changed,ar_builtin)
scripts/Makefile.lib+1−1
@@ -232,7 +232,7 @@ quiet_cmd_ld = LD $@ · 231 unmodified lines
232232 # ---------------------------------------------------------------------------
233233
234234 quiet_cmd_ar = AR $@
235− cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
235+ cmd_ar = rm -f $@; $(AR) cDPrsT $@ $(real-prereqs)
236236
237237 # Objcopy
238238 # ---------------------------------------------------------------------------
scripts/mod/modpost.c+9−4
@@ -2652,15 +2652,20 @@ int main(int argc, char **argv) · 2651 unmodified lines
26522652 fatal("modpost: Section mismatches detected.\n"
26532653 "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n");
26542654 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;
26562664
2657− while (s) {
26582665 if (s->is_static)
26592666 warn("\"%s\" [%s] is a static %s\n",
26602667 s->name, s->module->name,
26612668 export_str(s->export));
2662−
2663− s = s->next;
26642669 }
26652670 }
26662671
scripts/namespace.pl+7−6
@@ -65,13 +65,14 @@ · 64 unmodified lines
6565 use warnings;
6666 use strict;
6767 use File::Find;
68+use File::Spec;
6869
6970 my $nm = ($ENV{'NM'} || "nm") . " -p";
7071 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'}));
7576
7677 if ($#ARGV != -1) {
7778 print STDERR "usage: $0 takes no parameters\n";
@@ -231,9 +232,9 @@ sub do_nm · 153 unmodified lines
231232 }
232233 ($source = $basename) =~ s/\.o$//;
233234 if (-e "$source.c" || -e "$source.S") {
234− $source = "$objtree$File::Find::dir/$source";
235+ $source = File::Spec->catfile($objtree, $File::Find::dir, $source)
235236 } else {
236− $source = "$srctree$File::Find::dir/$source";
237+ $source = File::Spec->catfile($srctree, $File::Find::dir, $source)
237238 }
238239 if (! -e "$source.c" && ! -e "$source.S") {
239240 # No obvious source, exclude the object if it is conglomerate
scripts/setlocalversion+1−1
@@ -126,7 +126,7 @@ scm_version() · 125 unmodified lines
126126
127127 collect_files()
128128 {
129− local file res
129+ local file res=
130130
131131 for file; do
132132 case "$file" in
security/integrity/Makefile+0−3
@@ -13,9 +13,6 @@ integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyrin · 12 unmodified lines
1313 integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \
1414 platform_certs/load_uefi.o
1515 integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o
16−$(obj)/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar
1716
18−subdir-$(CONFIG_IMA) += ima
1917 obj-$(CONFIG_IMA) += ima/
20−subdir-$(CONFIG_EVM) += evm
2118 obj-$(CONFIG_EVM) += evm/
usr/include/Makefile+0−10
@@ -29,13 +29,11 @@ header-test- += linux/android/binderfs.h · 28 unmodified lines
2929 header-test-$(CONFIG_CPU_BIG_ENDIAN) += linux/byteorder/big_endian.h
3030 header-test-$(CONFIG_CPU_LITTLE_ENDIAN) += linux/byteorder/little_endian.h
3131 header-test- += linux/coda.h
32−header-test- += linux/coda_psdev.h
3332 header-test- += linux/elfcore.h
3433 header-test- += linux/errqueue.h
3534 header-test- += linux/fsmap.h
3635 header-test- += linux/hdlc/ioctl.h
3736 header-test- += linux/ivtv.h
38−header-test- += linux/jffs2.h
3937 header-test- += linux/kexec.h
4038 header-test- += linux/matroxfb.h
4139 header-test- += linux/netfilter_ipv4/ipt_LOG.h
@@ -55,20 +53,12 @@ header-test- += linux/v4l2-mediabus.h · 13 unmodified lines
5553 header-test- += linux/v4l2-subdev.h
5654 header-test- += linux/videodev2.h
5755 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
6156 header-test- += sound/asequencer.h
6257 header-test- += sound/asoc.h
6358 header-test- += sound/asound.h
6459 header-test- += sound/compress_offload.h
6560 header-test- += sound/emu10k1.h
6661 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
7262 header-test- += xen/evtchn.h
7363 header-test- += xen/gntdev.h
7464 header-test- += xen/privcmd.h

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t