Commit Graph

110 Commits

Author SHA1 Message Date
Christian Marangi c47532b1ea
kernel-build.mk: add support for compiling only DTS
Add support for compiling DTS for the selected target. This can be
useful for testing if the DTS correctly compile and doesn't produce any
error.

This adds a new make target. To compile only DTS use:

make target/linux/dtb

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-02-08 19:57:28 +01:00
Chuanhong Guo 066b0fee76 kernel: copy only *.ko for debug info
Previous commits installed non-elf files into /lib/modules/$VER/.
COLLECT_KERNEL_DEBUG tries to strip all files and these two files
break the build.
Fix it by copying only kernel modules for debug info collection.

Fixes: e1d8e57614 ("kernel: include modinfo for built-in modules")
Fixes: 29f6da4340 ("kernel: include built-in module list")
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2024-01-07 23:56:05 +08:00
Christian Marangi 53a08e3743
build: make find_md5 reproducible with AUTOREMOVE
While experimenting with the AUTOREMOVE option in search of a way to use
prebuilt host tools in different buildroot, it was discovered that the
md5 generated by find_md5 in depends.mk is not reproducible.

Currently the hash is generated by the path of the file in addition to
the file mod time. Out of confusion, probably, there was an idea that
such command was used on the package build_dir. Reality is that this
command is run on the package files. (Makefile, patches, src)

This is problematic because the package Makefile (for example) change at
each git clone and base the hash on the Makefile mtime doesn't really
reflect if the Makefile actually changes across a buildroot or not.

A better approach is to generate an hash of each file and then generate
an hash on the sort hash list. This way we remove the problem of git
clone setting a wrong mtime while keeping the integrity of checking if a
file changed for the package as any change will result in a different
hash.

Introduce a new kind of find_md5 function, find_md5_reproducible that
apply this new logic and limit it only with AUTOREMOVE option set to
prevent any kind of slowdown due to additional hash generation.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2022-09-30 22:26:51 +02:00
Stijn Tintel b998287b91 build: drop HOST_LOADLIBES
HOST_LOADLIBES was renamed to KBUILD_HOSTLDLIBS in kernel 4.19. As the
oldest kernel version we support is 5.10, cleanup HOST_LOADLIBES use.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2022-05-18 13:32:06 +03:00
David Bauer eaa9c94c75 generic: Kconfig: exit on unset symbol
When a target configuration has unser Kconfig symbols, the build will
fail when OpenWrt is compiled with V=s and stdin is connected to a tty.

In case OpenWrt is compiled without either of these preconditions, the
build will uscceed with the symbols in question being unset.

Modify the kernel configuration in a way it fails on unset symbols
regardless of the aformentioned preconditions.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-08-10 13:14:52 +02:00
Paul Spooren a17b8eaa2e build: use SPDX license tags
The license folder is a core part of OpenWrt and all GPL-2.0 licensed.
Use SPDX license tags to allow machines to check licenses.

Signed-off-by: Paul Spooren <mail@aparcar.org>
[rebase, keep some Copyright lines, sharpen commit message]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-05 14:54:47 +01:00
Rui Salvaterra f3bfff9d7f kernel-build: fix STRIP_KERNEL_EXPORTS for 64-bit kernels
While parsing the nm output, we need to account for the fact that 64-bit kernels
have 64-bit wide addresses. While at it, replace the grep | sed combo with a
single awk invocation and a stronger regex.

Fixes: 2ef0acc5fc "kernel-build: fix
STRIP_KERNEL_EXPORTS for recent kernels"

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
2021-01-01 19:55:59 +01:00
Sebastian Kemper 2127accd44 build: create $(PKG_SYMVERS_DIR) if non-existent
Commit 5d76065 moved the creation of the symvers directory to
include/kernel-build.mk. This is fine when building from scratch. But
when unpacking an SDK the directory doesn't exist and because the kernel
won't be built (again) this directory will not be created by the build
system, causing build failure if make tries to copy files into it.

This moves the creation of the symvers directory back into
include/kernel.mk so that the directory is created in any case.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
2020-11-19 18:52:15 +01:00
Felix Fietkau a8fb12a7d6 build: filter out more autogenerated kernel config options
Define wildcard patterns for filtering in target/linux/generic/config-filter
Preparation for supporting newer kernels

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-11-13 13:18:20 +01:00
Felix Fietkau 5d76065629 build: pass KBUILD_EXTRA_SYMBOLS with symvers files for kernel module packages
This replaces the previous (deprecated) method of collecting symvers data
in $(PKG_BUILD_DIR)/Module.symvers, which does not work on newer kernels

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-11-13 13:16:37 +01:00
Sergio E. Nemirowski 645b1ec3e2 build: add 'make kernel_xconfig' command
This adds the kernel_xconfig make target.

Signed-off-by: Sergio E. Nemirowski <sergio@outerface.net>
2020-07-08 16:07:05 +02:00
Matthias Schiffer 4bd7990488
build: compress kernel debuginfo using zstd
zstd with its default settings (compression level -3) compresses better
than bzip2 -9 (which is the default setting), and is an order of magnitude
faster.

I made the following measurements for the most common compression tools
(all standard Debian Buster versions, default flags unless noted
otherwise), using the debug information of a large x86-64 kernel with
ALL_KMODS:

* kernel-debug.tar: 376M
* kernel-debug.tar.gz: 101M, compressed in ~12s
* kernel-debug.tar.bz2: 91M, compressed in ~15s
* kernel-debug.tar.xz: 57M, compressed in ~101s
* kernel-debug.tar.zst: 86M, compressed in ~1s

With zstd, there is still some room for improvement by increasing the
compression, but the slight increase in compression ratio
(22.83% -> 19.46%) does not justify the significant increase in
compression time (about 5 times on my machine) in my opinion.

Note that multithreaded compression (-T argument) does not affect
reproducibility with zstd.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2020-05-31 11:03:31 +02:00
Felix Fietkau 5c6fe8e850 build: fix kernel_menuconfig on macOS with newer kernel versions
Account for upstream build system changes

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-04-09 09:54:02 +02:00
Petr Štetiar 74acc160a9 kernel-build: ignore runtime config options during reconfig
Don't put CC_HAS_ASM_GOTO, IS_GCC, IS_CLANG and GCC_VERSION runtime
config options into the kernel configs during reconfiguration as it
makes no sense, since these options should be set at runtime.

Fixes: FS#2588
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24 14:19:43 +01:00
Petr Štetiar f962e021d4 kernel-build: fix kernel_menuconfig breakage by forcing YACC
Commit 965f341aa9 ("build: fix host menu config targets using
ncurses") has moved host's path with pkg-config (usually /usr/bin) at
the first place in PATH variable, which is now causing issues with bison
as BISON_PKGDATADIR points into STAGING_DIR_HOST, but the actual bison
used is the one under host PATH (usually /usr/bin/bison), leading to the
following strange failures:

 $ make target/linux/clean kernel_menuconfig V=sc

 export MAKEFLAGS= ;make -C /somewhere/linux-4.19.81 menuconfig
 make -f ./scripts/Makefile.build obj=scripts/kconfig menuconfig
  ...
  bison -oscripts/kconfig/zconf.tab.c -t -l scripts/kconfig/zconf.y
  staging_dir/host/bin/m4: cannot open `staging_dir/host/share/bison/bison.m4': No such file or directory
  staging_dir/host/bin/m4: cannot open `staging_dir/host/share/bison/c-skel.m4': No such file or directory
  ...
  gcc -Wp,-MD,scripts/kconfig/.zconf.tab.o.d <...snip...> -o scripts/kconfig/zconf.tab.o scripts/kconfig/zconf.tab.c
  gcc: error: scripts/kconfig/zconf.tab.c: No such file or directory
  gcc: fatal error: no input files

Fix this by forcing usage of bison under STAGING_DIR_HOST/bin via YACC
make variable.

Cc: Thomas Albers <thomas.gameiro@gmail.com>
Cc: Stijn Tintel <stijn@linux-ipv6.be>
Cc: Eneas U de Queiroz <cotequeiroz@gmail.com>
Tested-by: Ivan Revyakin <LovingFox@GMail.com>
Tested-by: Thomas Albers <thomas.gameiro@googlemail.com>
Ref: https://forum.openwrt.org/t/bpi-r64-kernel-4-19-kernel-menuconfig-error
Fixes: 965f341aa9 ("build: fix host menu config targets using ncurses")
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-14 22:53:31 +01:00
Jo-Philipp Wich fe43969336 include: kernel-build: pass pkg-config overrides to kernel build
Pass suitable pkg-config overrides to the kernel build process in
order to let our pkg-config wrapper discover libraries provided
by tools/.

This mainly affects the use of libelf which is required for the
CONFIG_STACK_VALIDATION features. So far, the build system either
silently used host system libraries or kbuild simply disabled the
feature due to the lack of a suitable libelf.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-03 10:44:21 +02:00
Matthias Schiffer 36fa1bbf6f
include/kernel-build.mk: fix kernel rebuild on backport patch changes
An incorrect variable name was referenced in KERNEL_FILE_DEPENDS, leading
to the omission of the backport-* patch dirs in the generation of the
prepared stamp name.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2018-07-14 13:07:34 +02:00
Alexandru Ardelean ab6a96f3f5 Config-devel.in: rename symbol KERNEL_GIT_BRANCH -> KERNEL_GIT_REF
The Download/git rule will do a `git checkout <git-ref>`.
So, we can use any ref we want.

No need to limit just to branches.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2018-01-27 16:46:45 +01:00
John Crispin 74d00a8c38 kernel: split patches folder up into backport, pending and hack folders
* properly format/comment all patches
* merge debloat patches
* merge Kconfig patches
* merge swconfig patches
* merge hotplug patches
* drop 200-fix_localversion.patch - upstream
* drop 222-arm_zimage_none.patch - unused
* drop 252-mv_cesa_depends.patch - no longer required
* drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused
* drop 661-fq_codel_keep_dropped_stats.patch - outdated
* drop 702-phy_add_aneg_done_function.patch - upstream
* drop 840-rtc7301.patch - unused
* drop 841-rtc_pt7c4338.patch - upstream
* drop 921-use_preinit_as_init.patch - unused
* drop spio-gpio-old and gpio-mmc - unused

Signed-off-by: John Crispin <john@phrozen.org>
2017-08-05 08:46:36 +02:00
Felix Fietkau fec38ebf0d kernel: fix segmentation fault in mconf on linux
Commit 86c966a8ae caused HOST_LOADLIBES to
include -lncurses. This was added for fixing build issues on macOS.
This introduces issues on Linux when wide-character ncurses is being
used for compiling, but the non-wide-character version is linked in.

Fix this by adding the extra override for HOST_LOADLIBES only on macOS.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-06-07 18:31:10 +02:00
Felix Fietkau 0aed054bec build: add KERNEL_MAKE and KERNEL_MAKE_FLAGS variables and move to kernel.mk
This allows packages to use kernel make options without the forced
-C $(LINUX_DIR). It also makes it more clear that it to be called from
kernel module packages directly.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-06-07 18:31:10 +02:00
Felix Fietkau 9467ce42da build: get rid of host.mk
Defined required host related variables in toplevel.mk instead

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-02-26 13:31:44 +01:00
Felix Fietkau dce6eeccc0 build: skip headers install and config on make target/linux/prepare
This simplifies working with quilt on the kernel tree

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-02-15 12:35:17 +01:00
Mirko Vogt c99f881568 git-kernel: $(SUBDIR) should always be $(LINUX_VERSION)
Before SUBDIR was set to $(PATCHVER) which may
or may not include the minor version number of
the linux kernel version. Usually it doesn't.

So the git-clone'd linux kernel was packed without
the minor version number taken into account, which
broke further processing, as it expected the
extracted dir being named linux-$(LINUX_VERSION)
(=with minor version) rather than linux-$(PATCHVER)
(=without minor version).

Changing SUBDIR to $(LINUX_VERSION) creates
consistent behaviour here.

Signed-off-by: Mirko Vogt <mirko-openwrt@nanl.de>
2017-01-18 21:03:26 +01:00
Felix Fietkau 720b99215d treewide: clean up download hashes
Replace *MD5SUM with *HASH, replace MD5 hashes with SHA256

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-12-16 22:39:22 +01:00
Florian Fainelli 9a08c0ba80 include/kernel: Switch to git download method
Utilize the existing git download logic from include/download.mk and migrate
the kernel download over to it. This avoids repeatedly cloning kernel sources
after a make target/linux/clean for instance.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [fix build error]
2016-12-04 11:41:51 +01:00
Felix Fietkau 86c966a8ae build: fix regression on running make kernel_menuconfig
The build system overrides HOST_LOADLIBES to add the staging dir to the
library search path. menuconfig needs -lncurses, add another override
for it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-10-04 17:51:49 +02:00
Jonas Gorski f3923dab7b kernel: check the right directories for rebuild
Pass KERNEL_FILE_DEPENDS to rdep instead of PKG_FILE_DEPENDS, which is
empty. Also don't pass $(CURDIR) as the directory to timestamp, as it
would also pick up non kernel related changes like image building code.

Should fix kernel being rebuild for unrelated changes, as well as not
being rebuild for changes in target/linux/generic.

Fixes: 22ef1c83b3 ("kernel: make the kernel build auto-clean the build dir like package build")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
2016-08-19 11:02:47 +02:00
Felix Fietkau 22ef1c83b3 kernel: make the kernel build auto-clean the build dir like package builds
Previous behavior can be restored by using QUILT=1 on target/prepare

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-08-05 14:17:08 +02:00
Felix Fietkau be6acba4dc build system: have tar use $SOURCE_DATE_EPOCH for --mtime
The --mtime argument to 'tar' sets the modification time for all files within
the archive, which determines the timestamp files will get when they are
extracted. In this case, rootfs and other tarballs will get mtimes which
correspond to the last commit timestamp of the build system, as reported by
git/subversion.

This is a step towards reproducible image builds.

Signed-off-by: bryan newbold <bnewbold@robocracy.org>
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48586
2016-01-31 23:29:16 +00:00
Felix Fietkau 3021d3139b kernel: remove .config.prev when running make kernel_*config to fix rebuild errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48545
2016-01-29 00:38:49 +00:00
Felix Fietkau 51c665bbdb kernel-build.mk: add .NOTPARALLEL
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42876
2014-10-12 15:00:19 +00:00
John Crispin 2ef0acc5fc kernel-build: fix STRIP_KERNEL_EXPORTS for recent kernels
Recent kernels started to mark exported symbols as global.
Adapt expressions in kernel-build.mk to also match global symbols
when grep'ing through nm output.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>

SVN-Revision: 42555
2014-09-15 16:18:48 +00:00
John Crispin 2e240a44c1 include: fix kernel download failure with git & local trees
When using the options EXTERNAL_KERNEL_TREE or KERNEL_GIT_CLONE_URI,
the command "make downloads" fails as it tries to download the kernel
tarball despite the option. This doesn't happen during a regular build
as in that case, the dependency is conditionned through the LINUX_SITE
variable, which is not set in these cases.

Below is a snapshot of the error for an target using a 3.14 kernel:

make[3]: *** No rule to make target `.../dl/linux-3.14.tar.xz',
needed by `download'.  Stop.

Change-Id: I1244969c1bbf9c81a6a64d68ae88ac58b0f8e79e
Signed-off-by: Mathieu Olivari <mathieu@qca.qualcomm.com>

SVN-Revision: 40913
2014-06-02 12:43:13 +00:00
Felix Fietkau 5a6a47e431 build: speed up kernel symbol export stripping
GNU grep has a high per-expression setup overhead when compiling regular
expressions. Use -F to force it to interpret the input as fixed strings,
which is much faster (fraction of a second instead of multiple minutes).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 39049
2013-12-14 13:14:44 +00:00
Florian Fainelli a890ccd6e0 buildroot: build a second pass kernel if initramfs is enabled
If initramfs is enabled, build a second pass kernel containing the CPIO
rootfs, preliminary work to get non exclusive enabling of initramfs.

Signed-off-by: Florian Fainelli <florian@openwrt.org>

SVN-Revision: 37047
2013-06-27 19:58:20 +00:00
Felix Fietkau 8933b918cd kernel: use -ffunction-sections, -fdata-sections and --gc-sections on mips
in combination with kernel symbol export stripping this significantly reduces
the kernel image size

SVN-Revision: 35320
2013-01-26 16:26:13 +00:00
Felix Fietkau 7809d73fd2 kernel: fix module export stripping
SVN-Revision: 35319
2013-01-26 16:26:04 +00:00
Felix Fietkau 24b31c9428 kernel: fix stripping symbol exports
SVN-Revision: 34458
2012-12-02 17:42:17 +00:00
Jo-Philipp Wich 5171edd8d5 kernel-build.mk: there is no tarball when using CONFIG_KERNEL_GIT_CLONE_URI or CONFIG_EXTERNAL_KERNEL_TREE, do not make the prepared stamp file depend on it in this case
SVN-Revision: 28361
2011-10-03 11:33:13 +00:00
Felix Fietkau caf4747f0c build: clean up handling of the kernel config
- support kernel config overlays in env/
- allow overriding the target kernel config with CONFIG_TARGET=platform|subtarget|env

SVN-Revision: 26498
2011-04-06 14:48:55 +00:00
Lars-Peter Clausen a97d6b0c95 Add kernel_nconfig make target
SVN-Revision: 22518
2010-08-06 21:36:35 +00:00
Felix Fietkau fd8142403e add a build system option for collecting all kernel debug information (including modules) in a tarball
SVN-Revision: 22327
2010-07-21 15:18:24 +00:00
Felix Fietkau 8e808a54c2 Revert "sort Kconfig symbols automatically to make Kaloz happy :p" Relying on some sort implementations' weird behaviour of ignoring # and whitespaces at the beginning of a line is not a good idea, and it's certainly not portable
SVN-Revision: 19675
2010-02-16 21:34:50 +00:00
Gabor Juhos 03779da9c6 sort Kconfig symbols automatically to make Kaloz happy :p
SVN-Revision: 19582
2010-02-11 13:07:10 +00:00
Felix Fietkau ea41d3a288 merge target kernel config files with subtarget config files and add a variable override for editing the target kernel config file with make kernel_menuconfig in case the subtarget contains overrides (thx, sn9)
SVN-Revision: 18362
2009-11-11 01:25:06 +00:00
Felix Fietkau bb5a40c64b add an optional config option for stripping all unnecessary symbol exports from the kernel image
SVN-Revision: 17181
2009-08-08 14:22:04 +00:00
Felix Fietkau 6d782f93d8 kernel: make sure all patches are applied before running menuconfig or oldconfig
SVN-Revision: 15325
2009-04-21 13:08:56 +00:00
Felix Fietkau ab8c8b019f enable quilt by default for the kernel tree
SVN-Revision: 12400
2008-08-27 14:14:00 +00:00
Felix Fietkau 811b00f646 fix make kernel_menuconfig for subtarget kernel config files
SVN-Revision: 12376
2008-08-23 23:45:28 +00:00