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
......
...@@ -29,31 +29,37 @@ This document describes the Linux kernel Makefiles. ...@@ -29,31 +29,37 @@ This document describes the Linux kernel Makefiles.
--- 4.4 Controlling compiler options for host programs --- 4.4 Controlling compiler options for host programs
--- 4.5 When host programs are actually built --- 4.5 When host programs are actually built
=== 5 Kbuild clean infrastructure === 5 Userspace Program support
--- 5.1 Simple Userspace Program
=== 6 Architecture Makefiles --- 5.2 Composite Userspace Programs
--- 6.1 Set variables to tweak the build to the architecture --- 5.3 Controlling compiler options for userspace programs
--- 6.2 Add prerequisites to archheaders: --- 5.4 When userspace programs are actually built
--- 6.3 Add prerequisites to archprepare:
--- 6.4 List directories to visit when descending === 6 Kbuild clean infrastructure
--- 6.5 Architecture-specific boot images
--- 6.6 Building non-kbuild targets === 7 Architecture Makefiles
--- 6.7 Commands useful for building a boot image --- 7.1 Set variables to tweak the build to the architecture
--- 6.8 Custom kbuild commands --- 7.2 Add prerequisites to archheaders:
--- 6.9 Preprocessing linker scripts --- 7.3 Add prerequisites to archprepare:
--- 6.10 Generic header files --- 7.4 List directories to visit when descending
--- 6.11 Post-link pass --- 7.5 Architecture-specific boot images
--- 7.6 Building non-kbuild targets
=== 7 Kbuild syntax for exported headers --- 7.7 Commands useful for building a boot image
--- 7.1 no-export-headers --- 7.8 Custom kbuild commands
--- 7.2 generic-y --- 7.9 Preprocessing linker scripts
--- 7.3 generated-y --- 7.10 Generic header files
--- 7.4 mandatory-y --- 7.11 Post-link pass
=== 8 Kbuild Variables === 8 Kbuild syntax for exported headers
=== 9 Makefile language --- 8.1 no-export-headers
=== 10 Credits --- 8.2 generic-y
=== 11 TODO --- 8.3 generated-y
--- 8.4 mandatory-y
=== 9 Kbuild Variables
=== 10 Makefile language
=== 11 Credits
=== 12 TODO
1 Overview 1 Overview
========== ==========
...@@ -732,7 +738,88 @@ Both possibilities are described in the following. ...@@ -732,7 +738,88 @@ Both possibilities are described in the following.
This will tell kbuild to build lxdialog even if not referenced in This will tell kbuild to build lxdialog even if not referenced in
any rule. any rule.
5 Kbuild clean infrastructure 5 Userspace Program support
===========================
Just like host programs, Kbuild also supports building userspace executables
for the target architecture (i.e. the same architecture as you are building
the kernel for).
The syntax is quite similar. The difference is to use "userprogs" instead of
"hostprogs".
5.1 Simple Userspace Program
----------------------------
The following line tells kbuild that the program bpf-direct shall be
built for the target architecture.
Example::
userprogs := bpf-direct
Kbuild assumes in the above example that bpf-direct is made from a
single C source file named bpf-direct.c located in the same directory
as the Makefile.
5.2 Composite Userspace Programs
--------------------------------
Userspace programs can be made up based on composite objects.
The syntax used to define composite objects for userspace programs is
similar to the syntax used for kernel objects.
$(<executable>-objs) lists all objects used to link the final
executable.
Example::
#samples/seccomp/Makefile
userprogs := bpf-fancy
bpf-fancy-objs := bpf-fancy.o bpf-helper.o
Objects with extension .o are compiled from the corresponding .c
files. In the above example, bpf-fancy.c is compiled to bpf-fancy.o
and bpf-helper.c is compiled to bpf-helper.o.
Finally, the two .o files are linked to the executable, bpf-fancy.
Note: The syntax <executable>-y is not permitted for userspace programs.
5.3 Controlling compiler options for userspace programs
-------------------------------------------------------
When compiling userspace programs, it is possible to set specific flags.
The programs will always be compiled utilising $(CC) passed
the options specified in $(KBUILD_USERCFLAGS).
To set flags that will take effect for all userspace programs created
in that Makefile, use the variable userccflags.
Example::
# samples/seccomp/Makefile
userccflags += -I usr/include
To set specific flags for a single file the following construction
is used:
Example::
bpf-helper-userccflags += -I user/include
It is also possible to specify additional options to the linker.
Example::
# net/bpfilter/Makefile
bpfilter_umh-userldflags += -static
When linking bpfilter_umh, it will be passed the extra option -static.
5.4 When userspace programs are actually built
----------------------------------------------
Same as "When host programs are actually built".
6 Kbuild clean infrastructure
============================= =============================
"make clean" deletes most generated files in the obj tree where the kernel "make clean" deletes most generated files in the obj tree where the kernel
...@@ -790,7 +877,7 @@ is not operational at that point. ...@@ -790,7 +877,7 @@ is not operational at that point.
Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will
be visited during "make clean". be visited during "make clean".
6 Architecture Makefiles 7 Architecture Makefiles
======================== ========================
The top level Makefile sets up the environment and does the preparation, 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): ...@@ -820,10 +907,10 @@ When kbuild executes, the following steps are followed (roughly):
- Preparing initrd images and the like - Preparing initrd images and the like
6.1 Set variables to tweak the build to the architecture 7.1 Set variables to tweak the build to the architecture
-------------------------------------------------------- --------------------------------------------------------
LDFLAGS KBUILD_LDFLAGS
Generic $(LD) options Generic $(LD) options
Flags used for all invocations of the linker. Flags used for all invocations of the linker.
...@@ -832,7 +919,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -832,7 +919,7 @@ When kbuild executes, the following steps are followed (roughly):
Example:: Example::
#arch/s390/Makefile #arch/s390/Makefile
LDFLAGS := -m elf_s390 KBUILD_LDFLAGS := -m elf_s390
Note: ldflags-y can be used to further customise Note: ldflags-y can be used to further customise
the flags used. See chapter 3.7. the flags used. See chapter 3.7.
...@@ -967,7 +1054,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -967,7 +1054,7 @@ When kbuild executes, the following steps are followed (roughly):
KBUILD_VMLINUX_LIBS together specify all the object files used to KBUILD_VMLINUX_LIBS together specify all the object files used to
link vmlinux. link vmlinux.
6.2 Add prerequisites to archheaders 7.2 Add prerequisites to archheaders
------------------------------------ ------------------------------------
The archheaders: rule is used to generate header files that The archheaders: rule is used to generate header files that
...@@ -977,7 +1064,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -977,7 +1064,7 @@ When kbuild executes, the following steps are followed (roughly):
architecture itself. architecture itself.
6.3 Add prerequisites to archprepare 7.3 Add prerequisites to archprepare
------------------------------------ ------------------------------------
The archprepare: rule is used to list prerequisites that need to be 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): ...@@ -995,7 +1082,7 @@ When kbuild executes, the following steps are followed (roughly):
generating offset header files. generating offset header files.
6.4 List directories to visit when descending 7.4 List directories to visit when descending
--------------------------------------------- ---------------------------------------------
An arch Makefile cooperates with the top Makefile to define variables An arch Makefile cooperates with the top Makefile to define variables
...@@ -1030,7 +1117,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1030,7 +1117,7 @@ When kbuild executes, the following steps are followed (roughly):
drivers-$(CONFIG_OPROFILE) += arch/sparc64/oprofile/ drivers-$(CONFIG_OPROFILE) += arch/sparc64/oprofile/
6.5 Architecture-specific boot images 7.5 Architecture-specific boot images
------------------------------------- -------------------------------------
An arch Makefile specifies goals that take the vmlinux file, compress An arch Makefile specifies goals that take the vmlinux file, compress
...@@ -1085,7 +1172,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1085,7 +1172,7 @@ When kbuild executes, the following steps are followed (roughly):
When "make" is executed without arguments, bzImage will be built. When "make" is executed without arguments, bzImage will be built.
6.6 Building non-kbuild targets 7.6 Building non-kbuild targets
------------------------------- -------------------------------
extra-y extra-y
...@@ -1108,7 +1195,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1108,7 +1195,7 @@ When kbuild executes, the following steps are followed (roughly):
In this example, extra-y is used to list object files that In this example, extra-y is used to list object files that
shall be built, but shall not be linked as part of built-in.a. shall be built, but shall not be linked as part of built-in.a.
6.7 Commands useful for building a boot image 7.7 Commands useful for building a boot image
--------------------------------------------- ---------------------------------------------
Kbuild provides a few macros that are useful when building a Kbuild provides a few macros that are useful when building a
...@@ -1211,7 +1298,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1211,7 +1298,7 @@ When kbuild executes, the following steps are followed (roughly):
targets += $(dtb-y) targets += $(dtb-y)
DTC_FLAGS ?= -p 1024 DTC_FLAGS ?= -p 1024
6.8 Custom kbuild commands 7.8 Custom kbuild commands
-------------------------- --------------------------
When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand 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): ...@@ -1241,7 +1328,7 @@ When kbuild executes, the following steps are followed (roughly):
will be displayed with "make KBUILD_VERBOSE=0". will be displayed with "make KBUILD_VERBOSE=0".
6.9 Preprocessing linker scripts 7.9 Preprocessing linker scripts
-------------------------------- --------------------------------
When the vmlinux image is built, the linker script When the vmlinux image is built, the linker script
...@@ -1274,7 +1361,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1274,7 +1361,7 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for `*lds` files is used in several The kbuild infrastructure for `*lds` files is used in several
architecture-specific files. architecture-specific files.
6.10 Generic header files 7.10 Generic header files
------------------------- -------------------------
The directory include/asm-generic contains the header files The directory include/asm-generic contains the header files
...@@ -1283,7 +1370,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1283,7 +1370,7 @@ When kbuild executes, the following steps are followed (roughly):
to list the file in the Kbuild file. to list the file in the Kbuild file.
See "7.2 generic-y" for further info on syntax etc. See "7.2 generic-y" for further info on syntax etc.
6.11 Post-link pass 7.11 Post-link pass
------------------- -------------------
If the file arch/xxx/Makefile.postlink exists, this makefile If the file arch/xxx/Makefile.postlink exists, this makefile
...@@ -1299,7 +1386,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1299,7 +1386,7 @@ When kbuild executes, the following steps are followed (roughly):
For example, powerpc uses this to check relocation sanity of For example, powerpc uses this to check relocation sanity of
the linked vmlinux file. the linked vmlinux file.
7 Kbuild syntax for exported headers 8 Kbuild syntax for exported headers
------------------------------------ ------------------------------------
The kernel includes a set of headers that is exported to userspace. 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 ...@@ -1319,14 +1406,14 @@ A Kbuild file may be defined under arch/<arch>/include/uapi/asm/ and
arch/<arch>/include/asm/ to list asm files coming from asm-generic. arch/<arch>/include/asm/ to list asm files coming from asm-generic.
See subsequent chapter for the syntax of the Kbuild file. See subsequent chapter for the syntax of the Kbuild file.
7.1 no-export-headers 8.1 no-export-headers
--------------------- ---------------------
no-export-headers is essentially used by include/uapi/linux/Kbuild to no-export-headers is essentially used by include/uapi/linux/Kbuild to
avoid exporting specific headers (e.g. kvm.h) on architectures that do avoid exporting specific headers (e.g. kvm.h) on architectures that do
not support it. It should be avoided as much as possible. not support it. It should be avoided as much as possible.
7.2 generic-y 8.2 generic-y
------------- -------------
If an architecture uses a verbatim copy of a header from 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. ...@@ -1356,7 +1443,7 @@ See subsequent chapter for the syntax of the Kbuild file.
#include <asm-generic/termios.h> #include <asm-generic/termios.h>
7.3 generated-y 8.3 generated-y
--------------- ---------------
If an architecture generates other header files alongside generic-y If an architecture generates other header files alongside generic-y
...@@ -1370,7 +1457,7 @@ See subsequent chapter for the syntax of the Kbuild file. ...@@ -1370,7 +1457,7 @@ See subsequent chapter for the syntax of the Kbuild file.
#arch/x86/include/asm/Kbuild #arch/x86/include/asm/Kbuild
generated-y += syscalls_32.h generated-y += syscalls_32.h
7.4 mandatory-y 8.4 mandatory-y
--------------- ---------------
mandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild 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. ...@@ -1380,7 +1467,7 @@ See subsequent chapter for the syntax of the Kbuild file.
in arch/$(ARCH)/include/(uapi/)/asm, Kbuild will automatically generate in arch/$(ARCH)/include/(uapi/)/asm, Kbuild will automatically generate
a wrapper of the asm-generic one. a wrapper of the asm-generic one.
8 Kbuild Variables 9 Kbuild Variables
================== ==================
The top Makefile exports the following variables: The top Makefile exports the following variables:
...@@ -1438,8 +1525,8 @@ The top Makefile exports the following variables: ...@@ -1438,8 +1525,8 @@ The top Makefile exports the following variables:
command. command.
9 Makefile language 10 Makefile language
=================== ====================
The kernel Makefiles are designed to be run with GNU Make. The Makefiles The kernel Makefiles are designed to be run with GNU Make. The Makefiles
use only the documented features of GNU Make, but they do use many use only the documented features of GNU Make, but they do use many
...@@ -1458,7 +1545,7 @@ time the left-hand side is used. ...@@ -1458,7 +1545,7 @@ time the left-hand side is used.
There are some cases where "=" is appropriate. Usually, though, ":=" There are some cases where "=" is appropriate. Usually, though, ":="
is the right choice. is the right choice.
10 Credits 11 Credits
========== ==========
- Original version made by Michael Elizabeth Chastain, <mailto:mec@shout.net> - Original version made by Michael Elizabeth Chastain, <mailto:mec@shout.net>
...@@ -1466,7 +1553,7 @@ is the right choice. ...@@ -1466,7 +1553,7 @@ is the right choice.
- Updates by Sam Ravnborg <sam@ravnborg.org> - Updates by Sam Ravnborg <sam@ravnborg.org>
- Language QA by Jan Engelhardt <jengelh@gmx.de> - Language QA by Jan Engelhardt <jengelh@gmx.de>
11 TODO 12 TODO
======= =======
- Describe how kbuild supports shipped files with _shipped. - Describe how kbuild supports shipped files with _shipped.
......
...@@ -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"
......
...@@ -11,9 +11,12 @@ NAME = Kleptomaniac Octopus ...@@ -11,9 +11,12 @@ NAME = Kleptomaniac Octopus
# Comments in this file are targeted only to the developer, do not # Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file. # expect to learn how to build the kernel reading this file.
$(if $(filter __%, $(MAKECMDGOALS)), \
$(error targets prefixed with '__' are only for internal use))
# That's our default target when none is given on the command line # That's our default target when none is given on the command line
PHONY := _all PHONY := __all
_all: __all:
# We are using a recursive build, so we need to do a little thinking # We are using a recursive build, so we need to do a little thinking
# to get the ordering right. # to get the ordering right.
...@@ -157,12 +160,14 @@ MAKEFLAGS += --include-dir=$(abs_srctree) ...@@ -157,12 +160,14 @@ MAKEFLAGS += --include-dir=$(abs_srctree)
need-sub-make := 1 need-sub-make := 1
endif endif
this-makefile := $(lastword $(MAKEFILE_LIST))
ifneq ($(filter 3.%,$(MAKE_VERSION)),) ifneq ($(filter 3.%,$(MAKE_VERSION)),)
# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
# We need to invoke sub-make to avoid implicit rules in the top Makefile. # We need to invoke sub-make to avoid implicit rules in the top Makefile.
need-sub-make := 1 need-sub-make := 1
# Cancel implicit rules for this Makefile. # Cancel implicit rules for this Makefile.
$(lastword $(MAKEFILE_LIST)): ; $(this-makefile): ;
endif endif
export abs_srctree abs_objtree export abs_srctree abs_objtree
...@@ -170,13 +175,13 @@ export sub_make_done := 1 ...@@ -170,13 +175,13 @@ export sub_make_done := 1
ifeq ($(need-sub-make),1) ifeq ($(need-sub-make),1)
PHONY += $(MAKECMDGOALS) sub-make PHONY += $(MAKECMDGOALS) __sub-make
$(filter-out _all sub-make $(lastword $(MAKEFILE_LIST)), $(MAKECMDGOALS)) _all: sub-make $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
@: @:
# Invoke a second make in the output directory, passing relevant variables # Invoke a second make in the output directory, passing relevant variables
sub-make: __sub-make:
$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
endif # need-sub-make endif # need-sub-make
...@@ -213,6 +218,9 @@ ifeq ("$(origin M)", "command line") ...@@ -213,6 +218,9 @@ ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M) KBUILD_EXTMOD := $(M)
endif endif
$(if $(word 2, $(KBUILD_EXTMOD)), \
$(error building multiple external modules is not supported))
export KBUILD_CHECKSRC KBUILD_EXTMOD export KBUILD_CHECKSRC KBUILD_EXTMOD
extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
...@@ -321,7 +329,7 @@ ifdef mixed-build ...@@ -321,7 +329,7 @@ ifdef mixed-build
PHONY += $(MAKECMDGOALS) __build_one_by_one PHONY += $(MAKECMDGOALS) __build_one_by_one
$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one $(MAKECMDGOALS): __build_one_by_one
@: @:
__build_one_by_one: __build_one_by_one:
...@@ -406,9 +414,12 @@ else ...@@ -406,9 +414,12 @@ else
HOSTCC = gcc HOSTCC = gcc
HOSTCXX = g++ HOSTCXX = g++
endif endif
KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
$(HOSTCFLAGS) -O2 -fomit-frame-pointer -std=gnu89
export KBUILD_USERLDFLAGS :=
KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
...@@ -447,6 +458,26 @@ PYTHON = python ...@@ -447,6 +458,26 @@ PYTHON = python
PYTHON3 = python3 PYTHON3 = python3
CHECK = sparse CHECK = sparse
BASH = bash BASH = bash
GZIP = gzip
BZIP2 = bzip2
LZOP = lzop
LZMA = lzma
LZ4 = lz4c
XZ = xz
# GZIP, BZIP2, LZOP env vars are used by the tools. Support them as the command
# line interface, but use _GZIP, _BZIP2, _LZOP internally.
_GZIP := $(GZIP)
_BZIP2 := $(BZIP2)
_LZOP := $(LZOP)
# Reset GZIP, BZIP2, LZOP in this Makefile
override GZIP=
override BZIP2=
override LZOP=
# Reset GZIP, BZIP2, LZOP in recursive invocations
MAKEOVERRIDES += GZIP= BZIP2= LZOP=
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
...@@ -495,6 +526,7 @@ CLANG_FLAGS := ...@@ -495,6 +526,7 @@ CLANG_FLAGS :=
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export _GZIP _BZIP2 _LZOP LZMA LZ4 XZ
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
...@@ -593,12 +625,12 @@ else #!config-build ...@@ -593,12 +625,12 @@ else #!config-build
# targets and others. In general all targets except *config targets. # targets and others. In general all targets except *config targets.
# If building an external module we do not care about the all: rule # If building an external module we do not care about the all: rule
# but instead _all depend on modules # but instead __all depend on modules
PHONY += all PHONY += all
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
_all: all __all: all
else else
_all: modules __all: modules
endif endif
# Decide whether to build built-in, modular, or both. # Decide whether to build built-in, modular, or both.
...@@ -608,19 +640,15 @@ KBUILD_MODULES := ...@@ -608,19 +640,15 @@ KBUILD_MODULES :=
KBUILD_BUILTIN := 1 KBUILD_BUILTIN := 1
# If we have only "make modules", don't compile built-in objects. # If we have only "make modules", don't compile built-in objects.
# When we're building modules with modversions, we need to consider
# the built-in objects during the descend as well, in order to
# make sure the checksums are up to date before we record them.
ifeq ($(MAKECMDGOALS),modules) ifeq ($(MAKECMDGOALS),modules)
KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) KBUILD_BUILTIN :=
endif endif
# If we have "make <whatever> modules", compile modules # If we have "make <whatever> modules", compile modules
# in addition to whatever we do anyway. # in addition to whatever we do anyway.
# Just "make" or "make all" shall build modules as well # Just "make" or "make all" shall build modules as well
ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),) ifneq ($(filter all modules nsdeps,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1 KBUILD_MODULES := 1
endif endif
...@@ -636,13 +664,11 @@ endif ...@@ -636,13 +664,11 @@ endif
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
# Objects we will link into vmlinux / subdirs we need to visit # Objects we will link into vmlinux / subdirs we need to visit
init-y := init/ core-y := init/ usr/
drivers-y := drivers/ sound/ drivers-y := drivers/ sound/
drivers-$(CONFIG_SAMPLES) += samples/ drivers-$(CONFIG_SAMPLES) += samples/
net-y := net/ drivers-y += net/ virt/
libs-y := lib/ libs-y := lib/
core-y := usr/
virt-y := virt/
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
# The all: target is the default when no target is given on the # The all: target is the default when no target is given on the
...@@ -695,7 +721,7 @@ $(KCONFIG_CONFIG): ...@@ -695,7 +721,7 @@ $(KCONFIG_CONFIG):
# This exploits the 'multi-target pattern rule' trick. # This exploits the 'multi-target pattern rule' trick.
# The syncconfig should be executed only once to make all the targets. # The syncconfig should be executed only once to make all the targets.
# (Note: use the grouped target '&:' when we bump to GNU Make 4.3) # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG) %/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG)
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
else # !may-sync-config else # !may-sync-config
# External modules and some install targets need include/generated/autoconf.h # External modules and some install targets need include/generated/autoconf.h
...@@ -814,6 +840,12 @@ DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ ...@@ -814,6 +840,12 @@ DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
$(call cc-option,-fno-var-tracking) $(call cc-option,-fno-var-tracking)
endif endif
ifdef CONFIG_DEBUG_INFO_COMPRESSED
DEBUG_CFLAGS += -gz=zlib
KBUILD_AFLAGS += -Wa,--compress-debug-sections=zlib
KBUILD_LDFLAGS += --compress-debug-sections=zlib
endif
KBUILD_CFLAGS += $(DEBUG_CFLAGS) KBUILD_CFLAGS += $(DEBUG_CFLAGS)
export DEBUG_CFLAGS export DEBUG_CFLAGS
...@@ -950,6 +982,10 @@ ifeq ($(CONFIG_RELR),y) ...@@ -950,6 +982,10 @@ ifeq ($(CONFIG_RELR),y)
LDFLAGS_vmlinux += --pack-dyn-relocs=relr LDFLAGS_vmlinux += --pack-dyn-relocs=relr
endif endif
# Align the bit size of userspace programs with the kernel
KBUILD_USERCFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
# make the checker run with the right architecture # make the checker run with the right architecture
CHECKFLAGS += --arch=$(ARCH) CHECKFLAGS += --arch=$(ARCH)
...@@ -1011,10 +1047,10 @@ export mod_strip_cmd ...@@ -1011,10 +1047,10 @@ export mod_strip_cmd
mod_compress_cmd = true mod_compress_cmd = true
ifdef CONFIG_MODULE_COMPRESS ifdef CONFIG_MODULE_COMPRESS
ifdef CONFIG_MODULE_COMPRESS_GZIP ifdef CONFIG_MODULE_COMPRESS_GZIP
mod_compress_cmd = gzip -n -f mod_compress_cmd = $(_GZIP) -n -f
endif # CONFIG_MODULE_COMPRESS_GZIP endif # CONFIG_MODULE_COMPRESS_GZIP
ifdef CONFIG_MODULE_COMPRESS_XZ ifdef CONFIG_MODULE_COMPRESS_XZ
mod_compress_cmd = xz -f mod_compress_cmd = $(XZ) -f
endif # CONFIG_MODULE_COMPRESS_XZ endif # CONFIG_MODULE_COMPRESS_XZ
endif # CONFIG_MODULE_COMPRESS endif # CONFIG_MODULE_COMPRESS
export mod_compress_cmd export mod_compress_cmd
...@@ -1049,34 +1085,33 @@ export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps ...@@ -1049,34 +1085,33 @@ export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) $(libs-y) $(libs-m)))
vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
$(patsubst %/,%,$(filter %/, $(init-) $(core-) \ $(patsubst %/,%,$(filter %/, $(core-) \
$(drivers-) $(net-) $(libs-) $(virt-)))) $(drivers-) $(libs-))))
subdir-modorder := $(addsuffix modules.order,$(filter %/, \
$(core-y) $(core-m) $(libs-y) $(libs-m) \
$(drivers-y) $(drivers-m)))
build-dirs := $(vmlinux-dirs) build-dirs := $(vmlinux-dirs)
clean-dirs := $(vmlinux-alldirs) clean-dirs := $(vmlinux-alldirs)
init-y := $(patsubst %/, %/built-in.a, $(init-y)) # Externally visible symbols (used by link-vmlinux.sh)
core-y := $(patsubst %/, %/built-in.a, $(core-y)) KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
net-y := $(patsubst %/, %/built-in.a, $(net-y))
libs-y2 := $(patsubst %/, %/built-in.a, $(filter %/, $(libs-y)))
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
libs-y1 := $(filter-out %/, $(libs-y)) KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
libs-y2 += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
else else
libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
endif endif
virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
# Externally visible symbols (used by link-vmlinux.sh) export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
$(drivers-y) $(net-y) $(virt-y)
export KBUILD_VMLINUX_LIBS := $(libs-y1)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
export LDFLAGS_vmlinux export LDFLAGS_vmlinux
# used by scripts/Makefile.package # used by scripts/Makefile.package
...@@ -1087,16 +1122,14 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) ...@@ -1087,16 +1122,14 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
# Recurse until adjust_autoksyms.sh is satisfied # Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive PHONY += autoksyms_recursive
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
autoksyms_recursive: descend modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile vmlinux"
endif
# For the kernel to actually contain only the needed exported symbols, # For the kernel to actually contain only the needed exported symbols,
# we have to build modules as well to determine what those symbols are. # we have to build modules as well to determine what those symbols are.
# (this can be evaluated only once include/config/auto.conf has been included) # (this can be evaluated only once include/config/auto.conf has been included)
ifdef CONFIG_TRIM_UNUSED_KSYMS KBUILD_MODULES := 1
KBUILD_MODULES := 1
autoksyms_recursive: descend modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile vmlinux"
endif endif
autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
...@@ -1122,7 +1155,7 @@ targets := vmlinux ...@@ -1122,7 +1155,7 @@ targets := vmlinux
# The actual objects are generated when descending, # The actual objects are generated when descending,
# make sure no implicit rule kicks in # make sure no implicit rule kicks in
$(sort $(vmlinux-deps)): descend ; $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
filechk_kernel.release = \ filechk_kernel.release = \
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
...@@ -1147,7 +1180,8 @@ scripts: scripts_basic scripts_dtc ...@@ -1147,7 +1180,8 @@ scripts: scripts_basic scripts_dtc
PHONY += prepare archprepare PHONY += prepare archprepare
archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
include/generated/autoconf.h
prepare0: archprepare prepare0: archprepare
$(Q)$(MAKE) $(build)=scripts/mod $(Q)$(MAKE) $(build)=scripts/mod
...@@ -1315,12 +1349,29 @@ dt_binding_check: scripts_dtc ...@@ -1315,12 +1349,29 @@ dt_binding_check: scripts_dtc
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Modules # Modules
# install modules.builtin regardless of CONFIG_MODULES
PHONY += _builtin_inst_
_builtin_inst_:
@mkdir -p $(MODLIB)/
@cp -f modules.builtin $(MODLIB)/
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
PHONY += install
install: _builtin_inst_
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
# By default, build modules as well # By default, build modules as well
all: modules all: modules
# When we're building modules with modversions, we need to consider
# the built-in objects during the descend as well, in order to
# make sure the checksums are up to date before we record them.
ifdef CONFIG_MODVERSIONS
KBUILD_BUILTIN := 1
endif
# Build modules # Build modules
# #
# A module can be listed more than once in obj-m resulting in # A module can be listed more than once in obj-m resulting in
...@@ -1328,12 +1379,19 @@ all: modules ...@@ -1328,12 +1379,19 @@ all: modules
# using awk while concatenating to the final file. # using awk while concatenating to the final file.
PHONY += modules PHONY += modules
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
modules.order: descend PHONY += modules_check
$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@ modules_check: modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
modules.order: $(subdir-modorder) FORCE
$(call if_changed,modules_order)
targets += modules.order
# Target to prepare building external modules # Target to prepare building external modules
PHONY += modules_prepare PHONY += modules_prepare
...@@ -1344,7 +1402,7 @@ PHONY += modules_install ...@@ -1344,7 +1402,7 @@ PHONY += modules_install
modules_install: _modinst_ _modinst_post modules_install: _modinst_ _modinst_post
PHONY += _modinst_ PHONY += _modinst_
_modinst_: _modinst_: _builtin_inst_
@rm -rf $(MODLIB)/kernel @rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/source @rm -f $(MODLIB)/source
@mkdir -p $(MODLIB)/kernel @mkdir -p $(MODLIB)/kernel
...@@ -1354,8 +1412,6 @@ _modinst_: ...@@ -1354,8 +1412,6 @@ _modinst_:
ln -s $(CURDIR) $(MODLIB)/build ; \ ln -s $(CURDIR) $(MODLIB)/build ; \
fi fi
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
@cp -f modules.builtin $(MODLIB)/
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
# This depmod is only for convenience to give the initial # This depmod is only for convenience to give the initial
...@@ -1395,14 +1451,14 @@ endif # CONFIG_MODULES ...@@ -1395,14 +1451,14 @@ endif # CONFIG_MODULES
# make distclean Remove editor backup files, patch leftover files and the like # make distclean Remove editor backup files, patch leftover files and the like
# Directories & files removed with 'make clean' # Directories & files removed with 'make clean'
CLEAN_DIRS += include/ksym CLEAN_FILES += include/ksym vmlinux.symvers \
CLEAN_FILES += modules.builtin modules.builtin.modinfo modules.nsdeps modules.builtin modules.builtin.modinfo modules.nsdeps
# Directories & files removed with 'make mrproper' # Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config include/generated \ MRPROPER_FILES += include/config include/generated \
arch/$(SRCARCH)/include/generated .tmp_objdiff \ arch/$(SRCARCH)/include/generated .tmp_objdiff \
debian/ snap/ tar-install/ debian snap tar-install \
MRPROPER_FILES += .config .config.old .version \ .config .config.old .version \
Module.symvers \ Module.symvers \
signing_key.pem signing_key.priv signing_key.x509 \ signing_key.pem signing_key.priv signing_key.x509 \
x509.genkey extra_certificates signing_key.x509.keyid \ x509.genkey extra_certificates signing_key.x509.keyid \
...@@ -1410,12 +1466,10 @@ MRPROPER_FILES += .config .config.old .version \ ...@@ -1410,12 +1466,10 @@ MRPROPER_FILES += .config .config.old .version \
*.spec *.spec
# Directories & files removed with 'make distclean' # Directories & files removed with 'make distclean'
DISTCLEAN_DIRS +=
DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
# clean - Delete most, but leave enough to build external modules # clean - Delete most, but leave enough to build external modules
# #
clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES) clean: rm-files := $(CLEAN_FILES)
PHONY += archclean vmlinuxclean PHONY += archclean vmlinuxclean
...@@ -1428,7 +1482,6 @@ clean: archclean vmlinuxclean ...@@ -1428,7 +1482,6 @@ clean: archclean vmlinuxclean
# mrproper - Delete all generated files, including .config # mrproper - Delete all generated files, including .config
# #
mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
mrproper-dirs := $(addprefix _mrproper_,scripts) mrproper-dirs := $(addprefix _mrproper_,scripts)
...@@ -1437,18 +1490,15 @@ $(mrproper-dirs): ...@@ -1437,18 +1490,15 @@ $(mrproper-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
mrproper: clean $(mrproper-dirs) mrproper: clean $(mrproper-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles) $(call cmd,rmfiles)
# distclean # distclean
# #
distclean: rm-dirs := $(wildcard $(DISTCLEAN_DIRS))
distclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
PHONY += distclean PHONY += distclean
distclean: mrproper distclean: mrproper
$(call cmd,rmdirs)
$(call cmd,rmfiles) $(call cmd,rmfiles)
@find $(srctree) $(RCS_FIND_IGNORE) \ @find $(srctree) $(RCS_FIND_IGNORE) \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
...@@ -1634,17 +1684,9 @@ else # KBUILD_EXTMOD ...@@ -1634,17 +1684,9 @@ else # KBUILD_EXTMOD
# We are always building modules # We are always building modules
KBUILD_MODULES := 1 KBUILD_MODULES := 1
PHONY += $(objtree)/Module.symvers
$(objtree)/Module.symvers:
@test -e $(objtree)/Module.symvers || ( \
echo; \
echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \
echo " is missing; modules will have no dependencies and modversions."; \
echo )
build-dirs := $(KBUILD_EXTMOD) build-dirs := $(KBUILD_EXTMOD)
PHONY += modules PHONY += modules
modules: descend $(objtree)/Module.symvers modules: descend
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
PHONY += modules_install PHONY += modules_install
...@@ -1663,10 +1705,6 @@ _emodinst_post: _emodinst_ ...@@ -1663,10 +1705,6 @@ _emodinst_post: _emodinst_
clean-dirs := $(KBUILD_EXTMOD) clean-dirs := $(KBUILD_EXTMOD)
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps
PHONY += /
/:
@echo >&2 '"$(MAKE) /" is no longer supported. Please use "$(MAKE) ./" instead.'
PHONY += help PHONY += help
help: help:
@echo ' Building external modules.' @echo ' Building external modules.'
...@@ -1724,6 +1762,10 @@ build-dirs := $(foreach d, $(build-dirs), \ ...@@ -1724,6 +1762,10 @@ build-dirs := $(foreach d, $(build-dirs), \
endif endif
ifndef CONFIG_MODULES
KBUILD_MODULES :=
endif
# Handle descending into subdirectories listed in $(build-dirs) # Handle descending into subdirectories listed in $(build-dirs)
# Preset locale variables to speed up the build process. Limit locale # Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running # tweaks to this spot to avoid wrong language settings when running
...@@ -1742,7 +1784,6 @@ $(clean-dirs): ...@@ -1742,7 +1784,6 @@ $(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
clean: $(clean-dirs) clean: $(clean-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles) $(call cmd,rmfiles)
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
...@@ -1837,14 +1878,8 @@ tools/%: FORCE ...@@ -1837,14 +1878,8 @@ tools/%: FORCE
$(Q)mkdir -p $(objtree)/tools $(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
# FIXME Should go into a make.lib or something
# ===========================================================================
quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
cmd_rmdirs = rm -rf $(rm-dirs)
quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
cmd_rmfiles = rm -f $(rm-files) cmd_rmfiles = rm -rf $(rm-files)
# Run depmod only if we have System.map and depmod is executable # Run depmod only if we have System.map and depmod is executable
quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
......
...@@ -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
...@@ -30,8 +30,6 @@ static int have_vmlinux = 0; ...@@ -30,8 +30,6 @@ static int have_vmlinux = 0;
static int all_versions = 0; static int all_versions = 0;
/* If we are modposting external module set to 1 */ /* If we are modposting external module set to 1 */
static int external_module = 0; static int external_module = 0;
/* Warn about section mismatch in vmlinux if set to 1 */
static int vmlinux_section_warnings = 1;
/* Only warn about unresolved symbols */ /* Only warn about unresolved symbols */
static int warn_unresolved = 0; static int warn_unresolved = 0;
/* How a symbol is exported */ /* How a symbol is exported */
...@@ -90,26 +88,61 @@ static inline bool strends(const char *str, const char *postfix) ...@@ -90,26 +88,61 @@ static inline bool strends(const char *str, const char *postfix)
return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
} }
static int is_vmlinux(const char *modname) void *do_nofail(void *ptr, const char *expr)
{ {
const char *myname; if (!ptr)
fatal("Memory allocation failure: %s.\n", expr);
myname = strrchr(modname, '/'); return ptr;
if (myname) }
myname++;
else char *read_text_file(const char *filename)
myname = modname; {
struct stat st;
size_t nbytes;
int fd;
char *buf;
fd = open(filename, O_RDONLY);
if (fd < 0) {
perror(filename);
exit(1);
}
if (fstat(fd, &st) < 0) {
perror(filename);
exit(1);
}
buf = NOFAIL(malloc(st.st_size + 1));
nbytes = st.st_size;
while (nbytes) {
ssize_t bytes_read;
bytes_read = read(fd, buf, nbytes);
if (bytes_read < 0) {
perror(filename);
exit(1);
}
nbytes -= bytes_read;
}
buf[st.st_size] = '\0';
return (strcmp(myname, "vmlinux") == 0) || close(fd);
(strcmp(myname, "vmlinux.o") == 0);
return buf;
} }
void *do_nofail(void *ptr, const char *expr) char *get_line(char **stringp)
{ {
if (!ptr) /* do not return the unwanted extra line at EOF */
fatal("Memory allocation failure: %s.\n", expr); if (*stringp && **stringp == '\0')
return NULL;
return ptr; return strsep(stringp, "\n");
} }
/* A list of all modules we processed */ /* A list of all modules we processed */
...@@ -128,24 +161,20 @@ static struct module *find_module(const char *modname) ...@@ -128,24 +161,20 @@ static struct module *find_module(const char *modname)
static struct module *new_module(const char *modname) static struct module *new_module(const char *modname)
{ {
struct module *mod; struct module *mod;
char *p;
mod = NOFAIL(malloc(sizeof(*mod))); mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1));
memset(mod, 0, sizeof(*mod)); memset(mod, 0, sizeof(*mod));
p = NOFAIL(strdup(modname));
/* strip trailing .o */
if (strends(p, ".o")) {
p[strlen(p) - 2] = '\0';
mod->is_dot_o = 1;
}
/* add to list */ /* add to list */
mod->name = p; strcpy(mod->name, modname);
mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
mod->gpl_compatible = -1; mod->gpl_compatible = -1;
mod->next = modules; mod->next = modules;
modules = mod; modules = mod;
if (mod->is_vmlinux)
have_vmlinux = 1;
return mod; return mod;
} }
...@@ -161,12 +190,9 @@ struct symbol { ...@@ -161,12 +190,9 @@ struct symbol {
int crc_valid; int crc_valid;
char *namespace; char *namespace;
unsigned int weak:1; unsigned int weak:1;
unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
unsigned int kernel:1; /* 1 if symbol is from kernel
* (only for external modules) **/
unsigned int is_static:1; /* 1 if symbol is not global */ unsigned int is_static:1; /* 1 if symbol is not global */
enum export export; /* Type of export */ enum export export; /* Type of export */
char name[0]; char name[];
}; };
static struct symbol *symbolhash[SYMBOL_HASH_SIZE]; static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
...@@ -288,29 +314,32 @@ static enum export export_no(const char *s) ...@@ -288,29 +314,32 @@ static enum export export_no(const char *s)
return export_unknown; return export_unknown;
} }
static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) static void *sym_get_data_by_offset(const struct elf_info *info,
unsigned int secindex, unsigned long offset)
{ {
return (void *)elf->hdr + Elf_Shdr *sechdr = &info->sechdrs[secindex];
elf->sechdrs[elf->secindex_strings].sh_offset +
sechdr->sh_name;
}
static const char *sec_name(struct elf_info *elf, int secindex) if (info->hdr->e_type != ET_REL)
{ offset -= sechdr->sh_addr;
return sech_name(elf, &elf->sechdrs[secindex]);
return (void *)info->hdr + sechdr->sh_offset + offset;
} }
static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
{ {
unsigned int secindex = get_secindex(info, sym); return sym_get_data_by_offset(info, get_secindex(info, sym),
Elf_Shdr *sechdr = &info->sechdrs[secindex]; sym->st_value);
unsigned long offset; }
offset = sym->st_value; static const char *sech_name(const struct elf_info *info, Elf_Shdr *sechdr)
if (info->hdr->e_type != ET_REL) {
offset -= sechdr->sh_addr; return sym_get_data_by_offset(info, info->secindex_strings,
sechdr->sh_name);
}
return (void *)info->hdr + sechdr->sh_offset + offset; static const char *sec_name(const struct elf_info *info, int secindex)
{
return sech_name(info, &info->sechdrs[secindex]);
} }
#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
...@@ -386,17 +415,15 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, ...@@ -386,17 +415,15 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
if (!s) { if (!s) {
s = new_symbol(name, mod, export); s = new_symbol(name, mod, export);
} else if (!external_module || is_vmlinux(s->module->name) || } else if (!external_module || s->module->is_vmlinux ||
s->module == mod) { s->module == mod) {
warn("%s: '%s' exported twice. Previous export was in %s%s\n", warn("%s: '%s' exported twice. Previous export was in %s%s\n",
mod->name, name, s->module->name, mod->name, name, s->module->name,
is_vmlinux(s->module->name) ? "" : ".ko"); s->module->is_vmlinux ? "" : ".ko");
return s; return s;
} }
s->module = mod; s->module = mod;
s->vmlinux = is_vmlinux(mod->name);
s->kernel = 0;
s->export = export; s->export = export;
return s; return s;
} }
...@@ -416,7 +443,7 @@ static void sym_set_crc(const char *name, unsigned int crc) ...@@ -416,7 +443,7 @@ static void sym_set_crc(const char *name, unsigned int crc)
s->crc_valid = 1; s->crc_valid = 1;
} }
void *grab_file(const char *filename, unsigned long *size) static void *grab_file(const char *filename, size_t *size)
{ {
struct stat st; struct stat st;
void *map = MAP_FAILED; void *map = MAP_FAILED;
...@@ -438,41 +465,7 @@ void *grab_file(const char *filename, unsigned long *size) ...@@ -438,41 +465,7 @@ void *grab_file(const char *filename, unsigned long *size)
return map; return map;
} }
/** static void release_file(void *file, size_t size)
* Return a copy of the next line in a mmap'ed file.
* spaces in the beginning of the line is trimmed away.
* Return a pointer to a static buffer.
**/
char *get_next_line(unsigned long *pos, void *file, unsigned long size)
{
static char line[4096];
int skip = 1;
size_t len = 0;
signed char *p = (signed char *)file + *pos;
char *s = line;
for (; *pos < size ; (*pos)++) {
if (skip && isspace(*p)) {
p++;
continue;
}
skip = 0;
if (*p != '\n' && (*pos < size)) {
len++;
*s++ = *p++;
if (len > 4095)
break; /* Too long, stop */
} else {
/* End of string */
*s = '\0';
return line;
}
}
/* End of buffer */
return NULL;
}
void release_file(void *file, unsigned long size)
{ {
munmap(file, size); munmap(file, size);
} }
...@@ -528,9 +521,8 @@ static int parse_elf(struct elf_info *info, const char *filename) ...@@ -528,9 +521,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
/* Check if file offset is correct */ /* Check if file offset is correct */
if (hdr->e_shoff > info->size) { if (hdr->e_shoff > info->size) {
fatal("section header offset=%lu in file '%s' is bigger than " fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n",
"filesize=%lu\n", (unsigned long)hdr->e_shoff, (unsigned long)hdr->e_shoff, filename, info->size);
filename, info->size);
return 0; return 0;
} }
...@@ -683,7 +675,7 @@ static void handle_modversion(const struct module *mod, ...@@ -683,7 +675,7 @@ static void handle_modversion(const struct module *mod,
if (sym->st_shndx == SHN_UNDEF) { if (sym->st_shndx == SHN_UNDEF) {
warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n",
symname, mod->name, is_vmlinux(mod->name) ? "":".ko"); symname, mod->name, mod->is_vmlinux ? "" : ".ko");
return; return;
} }
...@@ -705,8 +697,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info, ...@@ -705,8 +697,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info,
enum export export; enum export export;
const char *name; const char *name;
if ((!is_vmlinux(mod->name) || mod->is_dot_o) && if (strstarts(symname, "__ksymtab"))
strstarts(symname, "__ksymtab"))
export = export_from_secname(info, get_secindex(info, sym)); export = export_from_secname(info, get_secindex(info, sym));
else else
export = export_from_sec(info, get_secindex(info, sym)); export = export_from_sec(info, get_secindex(info, sym));
...@@ -1752,11 +1743,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf, ...@@ -1752,11 +1743,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
static unsigned int *reloc_location(struct elf_info *elf, static unsigned int *reloc_location(struct elf_info *elf,
Elf_Shdr *sechdr, Elf_Rela *r) Elf_Shdr *sechdr, Elf_Rela *r)
{ {
Elf_Shdr *sechdrs = elf->sechdrs; return sym_get_data_by_offset(elf, sechdr->sh_info, r->r_offset);
int section = sechdr->sh_info;
return (void *)elf->hdr + sechdrs[section].sh_offset +
r->r_offset;
} }
static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
...@@ -2005,20 +1992,20 @@ static void read_symbols(const char *modname) ...@@ -2005,20 +1992,20 @@ static void read_symbols(const char *modname)
if (!parse_elf(&info, modname)) if (!parse_elf(&info, modname))
return; return;
mod = new_module(modname); {
char *tmp;
/* When there's no vmlinux, don't print warnings about /* strip trailing .o */
* unresolved symbols (since there'll be too many ;) */ tmp = NOFAIL(strdup(modname));
if (is_vmlinux(modname)) { tmp[strlen(tmp) - 2] = '\0';
have_vmlinux = 1; mod = new_module(tmp);
mod->skip = 1; free(tmp);
} }
if (!mod->is_vmlinux) {
license = get_modinfo(&info, "license"); license = get_modinfo(&info, "license");
if (!license && !is_vmlinux(modname)) if (!license)
warn("missing MODULE_LICENSE() in %s\n" warn("missing MODULE_LICENSE() in %s\n", modname);
"see include/linux/module.h for "
"more information\n", modname);
while (license) { while (license) {
if (license_is_gpl_compatible(license)) if (license_is_gpl_compatible(license))
mod->gpl_compatible = 1; mod->gpl_compatible = 1;
...@@ -2032,7 +2019,9 @@ static void read_symbols(const char *modname) ...@@ -2032,7 +2019,9 @@ static void read_symbols(const char *modname)
namespace = get_modinfo(&info, "import_ns"); namespace = get_modinfo(&info, "import_ns");
while (namespace) { while (namespace) {
add_namespace(&mod->imported_namespaces, namespace); add_namespace(&mod->imported_namespaces, namespace);
namespace = get_next_modinfo(&info, "import_ns", namespace); namespace = get_next_modinfo(&info, "import_ns",
namespace);
}
} }
for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
...@@ -2070,16 +2059,14 @@ static void read_symbols(const char *modname) ...@@ -2070,16 +2059,14 @@ static void read_symbols(const char *modname)
} }
} }
if (!is_vmlinux(modname) || vmlinux_section_warnings)
check_sec_ref(mod, modname, &info); check_sec_ref(mod, modname, &info);
if (!mod->is_vmlinux) {
version = get_modinfo(&info, "version"); version = get_modinfo(&info, "version");
if (version) if (version || all_versions)
maybe_frob_rcs_version(modname, version, info.modinfo,
version - (char *)info.hdr);
if (version || (all_versions && !is_vmlinux(modname)))
get_src_version(modname, mod->srcversion, get_src_version(modname, mod->srcversion,
sizeof(mod->srcversion)-1); sizeof(mod->srcversion) - 1);
}
parse_elf_finish(&info); parse_elf_finish(&info);
...@@ -2143,20 +2130,18 @@ void buf_write(struct buffer *buf, const char *s, int len) ...@@ -2143,20 +2130,18 @@ void buf_write(struct buffer *buf, const char *s, int len)
static void check_for_gpl_usage(enum export exp, const char *m, const char *s) static void check_for_gpl_usage(enum export exp, const char *m, const char *s)
{ {
const char *e = is_vmlinux(m) ?"":".ko";
switch (exp) { switch (exp) {
case export_gpl: case export_gpl:
fatal("GPL-incompatible module %s%s " fatal("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n",
"uses GPL-only symbol '%s'\n", m, e, s); m, s);
break; break;
case export_unused_gpl: case export_unused_gpl:
fatal("GPL-incompatible module %s%s " fatal("GPL-incompatible module %s.ko uses GPL-only symbol marked UNUSED '%s'\n",
"uses GPL-only symbol marked UNUSED '%s'\n", m, e, s); m, s);
break; break;
case export_gpl_future: case export_gpl_future:
warn("GPL-incompatible module %s%s " warn("GPL-incompatible module %s.ko uses future GPL-only symbol '%s'\n",
"uses future GPL-only symbol '%s'\n", m, e, s); m, s);
break; break;
case export_plain: case export_plain:
case export_unused: case export_unused:
...@@ -2168,13 +2153,11 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s) ...@@ -2168,13 +2153,11 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s)
static void check_for_unused(enum export exp, const char *m, const char *s) static void check_for_unused(enum export exp, const char *m, const char *s)
{ {
const char *e = is_vmlinux(m) ?"":".ko";
switch (exp) { switch (exp) {
case export_unused: case export_unused:
case export_unused_gpl: case export_unused_gpl:
warn("module %s%s " warn("module %s.ko uses symbol '%s' marked UNUSED\n",
"uses symbol '%s' marked UNUSED\n", m, e, s); m, s);
break; break;
default: default:
/* ignore */ /* ignore */
...@@ -2349,7 +2332,7 @@ static void add_depends(struct buffer *b, struct module *mod) ...@@ -2349,7 +2332,7 @@ static void add_depends(struct buffer *b, struct module *mod)
/* Clear ->seen flag of modules that own symbols needed by this. */ /* Clear ->seen flag of modules that own symbols needed by this. */
for (s = mod->unres; s; s = s->next) for (s = mod->unres; s; s = s->next)
if (s->module) if (s->module)
s->module->seen = is_vmlinux(s->module->name); s->module->seen = s->module->is_vmlinux;
buf_printf(b, "\n"); buf_printf(b, "\n");
buf_printf(b, "MODULE_INFO(depends, \""); buf_printf(b, "MODULE_INFO(depends, \"");
...@@ -2382,6 +2365,25 @@ static void add_srcversion(struct buffer *b, struct module *mod) ...@@ -2382,6 +2365,25 @@ static void add_srcversion(struct buffer *b, struct module *mod)
} }
} }
static void write_buf(struct buffer *b, const char *fname)
{
FILE *file;
file = fopen(fname, "w");
if (!file) {
perror(fname);
exit(1);
}
if (fwrite(b->p, 1, b->pos, file) != b->pos) {
perror(fname);
exit(1);
}
if (fclose(file) != 0) {
perror(fname);
exit(1);
}
}
static void write_if_changed(struct buffer *b, const char *fname) static void write_if_changed(struct buffer *b, const char *fname)
{ {
char *tmp; char *tmp;
...@@ -2414,32 +2416,24 @@ static void write_if_changed(struct buffer *b, const char *fname) ...@@ -2414,32 +2416,24 @@ static void write_if_changed(struct buffer *b, const char *fname)
close_write: close_write:
fclose(file); fclose(file);
write: write:
file = fopen(fname, "w"); write_buf(b, fname);
if (!file) {
perror(fname);
exit(1);
}
if (fwrite(b->p, 1, b->pos, file) != b->pos) {
perror(fname);
exit(1);
}
fclose(file);
} }
/* parse Module.symvers file. line format: /* parse Module.symvers file. line format:
* 0x12345678<tab>symbol<tab>module<tab>export<tab>namespace * 0x12345678<tab>symbol<tab>module<tab>export<tab>namespace
**/ **/
static void read_dump(const char *fname, unsigned int kernel) static void read_dump(const char *fname)
{ {
unsigned long size, pos = 0; char *buf, *pos, *line;
void *file = grab_file(fname, &size);
char *line;
if (!file) buf = read_text_file(fname);
if (!buf)
/* No symbol versions, silently ignore */ /* No symbol versions, silently ignore */
return; return;
while ((line = get_next_line(&pos, file, size))) { pos = buf;
while ((line = get_line(&pos))) {
char *symname, *namespace, *modname, *d, *export; char *symname, *namespace, *modname, *d, *export;
unsigned int crc; unsigned int crc;
struct module *mod; struct module *mod;
...@@ -2463,21 +2457,18 @@ static void read_dump(const char *fname, unsigned int kernel) ...@@ -2463,21 +2457,18 @@ static void read_dump(const char *fname, unsigned int kernel)
goto fail; goto fail;
mod = find_module(modname); mod = find_module(modname);
if (!mod) { if (!mod) {
if (is_vmlinux(modname))
have_vmlinux = 1;
mod = new_module(modname); mod = new_module(modname);
mod->skip = 1; mod->from_dump = 1;
} }
s = sym_add_exported(symname, mod, export_no(export)); s = sym_add_exported(symname, mod, export_no(export));
s->kernel = kernel;
s->is_static = 0; s->is_static = 0;
sym_set_crc(symname, crc); sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace); sym_update_namespace(symname, namespace);
} }
release_file(file, size); free(buf);
return; return;
fail: fail:
release_file(file, size); free(buf);
fatal("parse error in symbol dump file\n"); fatal("parse error in symbol dump file\n");
} }
...@@ -2489,7 +2480,7 @@ static int dump_sym(struct symbol *sym) ...@@ -2489,7 +2480,7 @@ static int dump_sym(struct symbol *sym)
{ {
if (!external_module) if (!external_module)
return 1; return 1;
if (sym->vmlinux || sym->kernel) if (sym->module->from_dump)
return 0; return 0;
return 1; return 1;
} }
...@@ -2515,7 +2506,7 @@ static void write_dump(const char *fname) ...@@ -2515,7 +2506,7 @@ static void write_dump(const char *fname)
symbol = symbol->next; symbol = symbol->next;
} }
} }
write_if_changed(&buf, fname); write_buf(&buf, fname);
free(buf.p); free(buf.p);
} }
...@@ -2527,7 +2518,7 @@ static void write_namespace_deps_files(const char *fname) ...@@ -2527,7 +2518,7 @@ static void write_namespace_deps_files(const char *fname)
for (mod = modules; mod; mod = mod->next) { for (mod = modules; mod; mod = mod->next) {
if (mod->skip || !mod->missing_namespaces) if (mod->from_dump || !mod->missing_namespaces)
continue; continue;
buf_printf(&ns_deps_buf, "%s.ko:", mod->name); buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
...@@ -2542,8 +2533,8 @@ static void write_namespace_deps_files(const char *fname) ...@@ -2542,8 +2533,8 @@ static void write_namespace_deps_files(const char *fname)
free(ns_deps_buf.p); free(ns_deps_buf.p);
} }
struct ext_sym_list { struct dump_list {
struct ext_sym_list *next; struct dump_list *next;
const char *file; const char *file;
}; };
...@@ -2551,28 +2542,24 @@ int main(int argc, char **argv) ...@@ -2551,28 +2542,24 @@ int main(int argc, char **argv)
{ {
struct module *mod; struct module *mod;
struct buffer buf = { }; struct buffer buf = { };
char *kernel_read = NULL;
char *missing_namespace_deps = NULL; char *missing_namespace_deps = NULL;
char *dump_write = NULL, *files_source = NULL; char *dump_write = NULL, *files_source = NULL;
int opt; int opt;
int err; int err;
int n; int n;
struct ext_sym_list *extsym_iter; struct dump_list *dump_read_start = NULL;
struct ext_sym_list *extsym_start = NULL; struct dump_list **dump_read_iter = &dump_read_start;
while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) { while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
switch (opt) { switch (opt) {
case 'i':
kernel_read = optarg;
external_module = 1;
break;
case 'e': case 'e':
external_module = 1; external_module = 1;
extsym_iter = break;
NOFAIL(malloc(sizeof(*extsym_iter))); case 'i':
extsym_iter->next = extsym_start; *dump_read_iter =
extsym_iter->file = optarg; NOFAIL(calloc(1, sizeof(**dump_read_iter)));
extsym_start = extsym_iter; (*dump_read_iter)->file = optarg;
dump_read_iter = &(*dump_read_iter)->next;
break; break;
case 'm': case 'm':
modversions = 1; modversions = 1;
...@@ -2586,9 +2573,6 @@ int main(int argc, char **argv) ...@@ -2586,9 +2573,6 @@ int main(int argc, char **argv)
case 'a': case 'a':
all_versions = 1; all_versions = 1;
break; break;
case 's':
vmlinux_section_warnings = 0;
break;
case 'T': case 'T':
files_source = optarg; files_source = optarg;
break; break;
...@@ -2609,13 +2593,13 @@ int main(int argc, char **argv) ...@@ -2609,13 +2593,13 @@ int main(int argc, char **argv)
} }
} }
if (kernel_read) while (dump_read_start) {
read_dump(kernel_read, 1); struct dump_list *tmp;
while (extsym_start) {
read_dump(extsym_start->file, 0); read_dump(dump_read_start->file);
extsym_iter = extsym_start->next; tmp = dump_read_start->next;
free(extsym_start); free(dump_read_start);
extsym_start = extsym_iter; dump_read_start = tmp;
} }
while (optind < argc) while (optind < argc)
...@@ -2624,12 +2608,19 @@ int main(int argc, char **argv) ...@@ -2624,12 +2608,19 @@ int main(int argc, char **argv)
if (files_source) if (files_source)
read_symbols_from_files(files_source); read_symbols_from_files(files_source);
/*
* When there's no vmlinux, don't print warnings about
* unresolved symbols (since there'll be too many ;)
*/
if (!have_vmlinux)
warn("Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.\n");
err = 0; err = 0;
for (mod = modules; mod; mod = mod->next) { for (mod = modules; mod; mod = mod->next) {
char fname[PATH_MAX]; char fname[PATH_MAX];
if (mod->skip) if (mod->is_vmlinux || mod->from_dump)
continue; continue;
buf.pos = 0; buf.pos = 0;
...@@ -2662,13 +2653,6 @@ int main(int argc, char **argv) ...@@ -2662,13 +2653,6 @@ int main(int argc, char **argv)
struct symbol *s; struct symbol *s;
for (s = symbolhash[n]; s; s = s->next) { 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;
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,
......
...@@ -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