Skip to content

Commit cff11ab

Browse files
committed
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) ...
2 parents 6f2dc3d + 8dfb61d commit cff11ab

60 files changed

Lines changed: 883 additions & 757 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ modules.order
5656
/linux
5757
/vmlinux
5858
/vmlinux.32
59+
/vmlinux.symvers
5960
/vmlinux-gdb.py
6061
/vmlinuz
6162
/System.map

‎Documentation/dontdiff‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ vmlinux-*
251251
vmlinux.aout
252252
vmlinux.bin.all
253253
vmlinux.lds
254+
vmlinux.symvers
254255
vmlinuz
255256
voffset.h
256257
vsyscall.lds

‎Documentation/kbuild/makefiles.rst‎

Lines changed: 137 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,37 @@ This document describes the Linux kernel Makefiles.
2929
--- 4.4 Controlling compiler options for host programs
3030
--- 4.5 When host programs are actually built
3131
32-
=== 5 Kbuild clean infrastructure
33-
34-
=== 6 Architecture Makefiles
35-
--- 6.1 Set variables to tweak the build to the architecture
36-
--- 6.2 Add prerequisites to archheaders:
37-
--- 6.3 Add prerequisites to archprepare:
38-
--- 6.4 List directories to visit when descending
39-
--- 6.5 Architecture-specific boot images
40-
--- 6.6 Building non-kbuild targets
41-
--- 6.7 Commands useful for building a boot image
42-
--- 6.8 Custom kbuild commands
43-
--- 6.9 Preprocessing linker scripts
44-
--- 6.10 Generic header files
45-
--- 6.11 Post-link pass
46-
47-
=== 7 Kbuild syntax for exported headers
48-
--- 7.1 no-export-headers
49-
--- 7.2 generic-y
50-
--- 7.3 generated-y
51-
--- 7.4 mandatory-y
52-
53-
=== 8 Kbuild Variables
54-
=== 9 Makefile language
55-
=== 10 Credits
56-
=== 11 TODO
32+
=== 5 Userspace Program support
33+
--- 5.1 Simple Userspace Program
34+
--- 5.2 Composite Userspace Programs
35+
--- 5.3 Controlling compiler options for userspace programs
36+
--- 5.4 When userspace programs are actually built
37+
38+
=== 6 Kbuild clean infrastructure
39+
40+
=== 7 Architecture Makefiles
41+
--- 7.1 Set variables to tweak the build to the architecture
42+
--- 7.2 Add prerequisites to archheaders:
43+
--- 7.3 Add prerequisites to archprepare:
44+
--- 7.4 List directories to visit when descending
45+
--- 7.5 Architecture-specific boot images
46+
--- 7.6 Building non-kbuild targets
47+
--- 7.7 Commands useful for building a boot image
48+
--- 7.8 Custom kbuild commands
49+
--- 7.9 Preprocessing linker scripts
50+
--- 7.10 Generic header files
51+
--- 7.11 Post-link pass
52+
53+
=== 8 Kbuild syntax for exported headers
54+
--- 8.1 no-export-headers
55+
--- 8.2 generic-y
56+
--- 8.3 generated-y
57+
--- 8.4 mandatory-y
58+
59+
=== 9 Kbuild Variables
60+
=== 10 Makefile language
61+
=== 11 Credits
62+
=== 12 TODO
5763
5864
1 Overview
5965
==========
@@ -732,7 +738,88 @@ Both possibilities are described in the following.
732738
This will tell kbuild to build lxdialog even if not referenced in
733739
any rule.
734740

735-
5 Kbuild clean infrastructure
741+
5 Userspace Program support
742+
===========================
743+
744+
Just like host programs, Kbuild also supports building userspace executables
745+
for the target architecture (i.e. the same architecture as you are building
746+
the kernel for).
747+
748+
The syntax is quite similar. The difference is to use "userprogs" instead of
749+
"hostprogs".
750+
751+
5.1 Simple Userspace Program
752+
----------------------------
753+
754+
The following line tells kbuild that the program bpf-direct shall be
755+
built for the target architecture.
756+
757+
Example::
758+
759+
userprogs := bpf-direct
760+
761+
Kbuild assumes in the above example that bpf-direct is made from a
762+
single C source file named bpf-direct.c located in the same directory
763+
as the Makefile.
764+
765+
5.2 Composite Userspace Programs
766+
--------------------------------
767+
768+
Userspace programs can be made up based on composite objects.
769+
The syntax used to define composite objects for userspace programs is
770+
similar to the syntax used for kernel objects.
771+
$(<executable>-objs) lists all objects used to link the final
772+
executable.
773+
774+
Example::
775+
776+
#samples/seccomp/Makefile
777+
userprogs := bpf-fancy
778+
bpf-fancy-objs := bpf-fancy.o bpf-helper.o
779+
780+
Objects with extension .o are compiled from the corresponding .c
781+
files. In the above example, bpf-fancy.c is compiled to bpf-fancy.o
782+
and bpf-helper.c is compiled to bpf-helper.o.
783+
784+
Finally, the two .o files are linked to the executable, bpf-fancy.
785+
Note: The syntax <executable>-y is not permitted for userspace programs.
786+
787+
5.3 Controlling compiler options for userspace programs
788+
-------------------------------------------------------
789+
790+
When compiling userspace programs, it is possible to set specific flags.
791+
The programs will always be compiled utilising $(CC) passed
792+
the options specified in $(KBUILD_USERCFLAGS).
793+
To set flags that will take effect for all userspace programs created
794+
in that Makefile, use the variable userccflags.
795+
796+
Example::
797+
798+
# samples/seccomp/Makefile
799+
userccflags += -I usr/include
800+
801+
To set specific flags for a single file the following construction
802+
is used:
803+
804+
Example::
805+
806+
bpf-helper-userccflags += -I user/include
807+
808+
It is also possible to specify additional options to the linker.
809+
810+
Example::
811+
812+
# net/bpfilter/Makefile
813+
bpfilter_umh-userldflags += -static
814+
815+
When linking bpfilter_umh, it will be passed the extra option -static.
816+
817+
5.4 When userspace programs are actually built
818+
----------------------------------------------
819+
820+
Same as "When host programs are actually built".
821+
822+
6 Kbuild clean infrastructure
736823
=============================
737824

738825
"make clean" deletes most generated files in the obj tree where the kernel
@@ -790,7 +877,7 @@ is not operational at that point.
790877
Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will
791878
be visited during "make clean".
792879

793-
6 Architecture Makefiles
880+
7 Architecture Makefiles
794881
========================
795882

796883
The top level Makefile sets up the environment and does the preparation,
@@ -820,10 +907,10 @@ When kbuild executes, the following steps are followed (roughly):
820907
- Preparing initrd images and the like
821908

822909

823-
6.1 Set variables to tweak the build to the architecture
910+
7.1 Set variables to tweak the build to the architecture
824911
--------------------------------------------------------
825912

826-
LDFLAGS
913+
KBUILD_LDFLAGS
827914
Generic $(LD) options
828915

829916
Flags used for all invocations of the linker.
@@ -832,7 +919,7 @@ When kbuild executes, the following steps are followed (roughly):
832919
Example::
833920

834921
#arch/s390/Makefile
835-
LDFLAGS := -m elf_s390
922+
KBUILD_LDFLAGS := -m elf_s390
836923

837924
Note: ldflags-y can be used to further customise
838925
the flags used. See chapter 3.7.
@@ -967,7 +1054,7 @@ When kbuild executes, the following steps are followed (roughly):
9671054
KBUILD_VMLINUX_LIBS together specify all the object files used to
9681055
link vmlinux.
9691056

970-
6.2 Add prerequisites to archheaders
1057+
7.2 Add prerequisites to archheaders
9711058
------------------------------------
9721059

9731060
The archheaders: rule is used to generate header files that
@@ -977,7 +1064,7 @@ When kbuild executes, the following steps are followed (roughly):
9771064
architecture itself.
9781065

9791066

980-
6.3 Add prerequisites to archprepare
1067+
7.3 Add prerequisites to archprepare
9811068
------------------------------------
9821069

9831070
The archprepare: rule is used to list prerequisites that need to be
@@ -995,7 +1082,7 @@ When kbuild executes, the following steps are followed (roughly):
9951082
generating offset header files.
9961083

9971084

998-
6.4 List directories to visit when descending
1085+
7.4 List directories to visit when descending
9991086
---------------------------------------------
10001087

10011088
An arch Makefile cooperates with the top Makefile to define variables
@@ -1030,7 +1117,7 @@ When kbuild executes, the following steps are followed (roughly):
10301117
drivers-$(CONFIG_OPROFILE) += arch/sparc64/oprofile/
10311118

10321119

1033-
6.5 Architecture-specific boot images
1120+
7.5 Architecture-specific boot images
10341121
-------------------------------------
10351122

10361123
An arch Makefile specifies goals that take the vmlinux file, compress
@@ -1085,7 +1172,7 @@ When kbuild executes, the following steps are followed (roughly):
10851172

10861173
When "make" is executed without arguments, bzImage will be built.
10871174

1088-
6.6 Building non-kbuild targets
1175+
7.6 Building non-kbuild targets
10891176
-------------------------------
10901177

10911178
extra-y
@@ -1108,7 +1195,7 @@ When kbuild executes, the following steps are followed (roughly):
11081195
In this example, extra-y is used to list object files that
11091196
shall be built, but shall not be linked as part of built-in.a.
11101197

1111-
6.7 Commands useful for building a boot image
1198+
7.7 Commands useful for building a boot image
11121199
---------------------------------------------
11131200

11141201
Kbuild provides a few macros that are useful when building a
@@ -1211,7 +1298,7 @@ When kbuild executes, the following steps are followed (roughly):
12111298
targets += $(dtb-y)
12121299
DTC_FLAGS ?= -p 1024
12131300

1214-
6.8 Custom kbuild commands
1301+
7.8 Custom kbuild commands
12151302
--------------------------
12161303

12171304
When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand
@@ -1241,7 +1328,7 @@ When kbuild executes, the following steps are followed (roughly):
12411328
will be displayed with "make KBUILD_VERBOSE=0".
12421329

12431330

1244-
6.9 Preprocessing linker scripts
1331+
7.9 Preprocessing linker scripts
12451332
--------------------------------
12461333

12471334
When the vmlinux image is built, the linker script
@@ -1274,7 +1361,7 @@ When kbuild executes, the following steps are followed (roughly):
12741361
The kbuild infrastructure for `*lds` files is used in several
12751362
architecture-specific files.
12761363

1277-
6.10 Generic header files
1364+
7.10 Generic header files
12781365
-------------------------
12791366

12801367
The directory include/asm-generic contains the header files
@@ -1283,7 +1370,7 @@ When kbuild executes, the following steps are followed (roughly):
12831370
to list the file in the Kbuild file.
12841371
See "7.2 generic-y" for further info on syntax etc.
12851372

1286-
6.11 Post-link pass
1373+
7.11 Post-link pass
12871374
-------------------
12881375

12891376
If the file arch/xxx/Makefile.postlink exists, this makefile
@@ -1299,7 +1386,7 @@ When kbuild executes, the following steps are followed (roughly):
12991386
For example, powerpc uses this to check relocation sanity of
13001387
the linked vmlinux file.
13011388

1302-
7 Kbuild syntax for exported headers
1389+
8 Kbuild syntax for exported headers
13031390
------------------------------------
13041391

13051392
The kernel includes a set of headers that is exported to userspace.
@@ -1319,14 +1406,14 @@ A Kbuild file may be defined under arch/<arch>/include/uapi/asm/ and
13191406
arch/<arch>/include/asm/ to list asm files coming from asm-generic.
13201407
See subsequent chapter for the syntax of the Kbuild file.
13211408

1322-
7.1 no-export-headers
1409+
8.1 no-export-headers
13231410
---------------------
13241411

13251412
no-export-headers is essentially used by include/uapi/linux/Kbuild to
13261413
avoid exporting specific headers (e.g. kvm.h) on architectures that do
13271414
not support it. It should be avoided as much as possible.
13281415

1329-
7.2 generic-y
1416+
8.2 generic-y
13301417
-------------
13311418

13321419
If an architecture uses a verbatim copy of a header from
@@ -1356,7 +1443,7 @@ See subsequent chapter for the syntax of the Kbuild file.
13561443

13571444
#include <asm-generic/termios.h>
13581445

1359-
7.3 generated-y
1446+
8.3 generated-y
13601447
---------------
13611448

13621449
If an architecture generates other header files alongside generic-y
@@ -1370,7 +1457,7 @@ See subsequent chapter for the syntax of the Kbuild file.
13701457
#arch/x86/include/asm/Kbuild
13711458
generated-y += syscalls_32.h
13721459

1373-
7.4 mandatory-y
1460+
8.4 mandatory-y
13741461
---------------
13751462

13761463
mandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild
@@ -1380,7 +1467,7 @@ See subsequent chapter for the syntax of the Kbuild file.
13801467
in arch/$(ARCH)/include/(uapi/)/asm, Kbuild will automatically generate
13811468
a wrapper of the asm-generic one.
13821469

1383-
8 Kbuild Variables
1470+
9 Kbuild Variables
13841471
==================
13851472

13861473
The top Makefile exports the following variables:
@@ -1438,8 +1525,8 @@ The top Makefile exports the following variables:
14381525
command.
14391526

14401527

1441-
9 Makefile language
1442-
===================
1528+
10 Makefile language
1529+
====================
14431530

14441531
The kernel Makefiles are designed to be run with GNU Make. The Makefiles
14451532
use only the documented features of GNU Make, but they do use many
@@ -1458,15 +1545,15 @@ time the left-hand side is used.
14581545
There are some cases where "=" is appropriate. Usually, though, ":="
14591546
is the right choice.
14601547

1461-
10 Credits
1548+
11 Credits
14621549
==========
14631550

14641551
- Original version made by Michael Elizabeth Chastain, <mailto:mec@shout.net>
14651552
- Updates by Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
14661553
- Updates by Sam Ravnborg <sam@ravnborg.org>
14671554
- Language QA by Jan Engelhardt <jengelh@gmx.de>
14681555

1469-
11 TODO
1556+
12 TODO
14701557
=======
14711558

14721559
- Describe how kbuild supports shipped files with _shipped.

‎Documentation/kbuild/modules.rst‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -528,18 +528,6 @@ build.
528528
will then do the expected and compile both modules with
529529
full knowledge of symbols from either module.
530530

531-
Use an extra Module.symvers file
532-
When an external module is built, a Module.symvers file
533-
is generated containing all exported symbols which are
534-
not defined in the kernel. To get access to symbols
535-
from bar.ko, copy the Module.symvers file from the
536-
compilation of bar.ko to the directory where foo.ko is
537-
built. During the module build, kbuild will read the
538-
Module.symvers file in the directory of the external
539-
module, and when the build is finished, a new
540-
Module.symvers file is created containing the sum of
541-
all symbols defined and not part of the kernel.
542-
543531
Use "make" variable KBUILD_EXTRA_SYMBOLS
544532
If it is impractical to add a top-level kbuild file,
545533
you can assign a space separated list

‎Kconfig‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#
66
mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
77

8-
comment "Compiler: $(CC_VERSION_TEXT)"
9-
108
source "scripts/Kconfig.include"
119

1210
source "init/Kconfig"

0 commit comments

Comments
 (0)