Skip to content

Support building the Linux kernel out of tree

Florian Fainelli via buildroot buildroot 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest23 patches 1 replyIn review
  2. v123 patches 22 repliesSuperseded

Changes in v2 from the cover letter

- patch 3: removed a leftover "WIP" note from the commit message;
- patch 9: as suggested by Thomas and Arnout, out-of-tree is no longer only used with <pkg>_OVERRIDE_SRCDIR: a package that sets <pkg>_SUPPORTS_OUT_OF_TREE is always built out of tree, with its sources extracted in output/source. SRC_DIR is now a separate directory, and dirclean and make clean remove it. Patches 20 and 23 are adapted accordingly;
- patch 12 (lua): the host variant also modified luaconf.h, to set LUA_ROOT, in a host-only post-patch hook. As suggested, this is no longer done on the shared sources: the Buildroot patch now lets LUA_ROOT be overridden, host-lua sets it in its CFLAGS, and the installed host luaconf.h is adjusted in a post-install hook;
- patch 17 (perl): as suggested, revert 8dea6e7c089c ("package/perl:
apply perl-cross patch only on target perl"): the perl-cross patch is a normal package patch again, applied to both variants, and the PERL_POST_PATCH_HOOKS hook is dropped;
- the subject no longer mentions LINUX_OVERRIDE_SRCDIR.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23package: prepare removal of <pkg>_DIRpackage/pkg-generic.mk+19 -190 replies
2/23infra: introduce a global SRC_DIR variableMakefile+1 -00 replies
3/23package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR valuespackage/pkg-autotools.mk package/pkg-cmake.mk package/pkg-generic.mk +2 more+44 -430 replies
4/23boot/boot-wrapper-aarch64: needs LINUX_BUILDDIRboot/boot-wrapper-aarch64/boot-wrapper-aarch64.mk+4 -40 replies
5/23boot/mxs-bootlets: needs (BAREBOX, LINUX, UBOOT)_BUILDDIRboot/mxs-bootlets/mxs-bootlets.mk+3 -30 replies
6/23linux/extensions: point to proper _SRCDIR and @Dlinux/linux-ext-rtai.mk linux/linux-ext-xenomai.mk+6 -60 replies
7/23linux/linux: LINUX_VERSION_PROBED should run from build directorylinux/linux.mk+1 -10 replies
8/23package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include _SUBDIRpackage/gcc/gcc-final/gcc-final.mk package/pkg-cargo.mk package/pkg-hare.mk +4 more+34 -340 replies
9/23linux: build out of treeMakefile linux/linux.mk package/pkg-generic.mk +1 more+45 -160 replies
10/23packages: sync host and target patch hookspackage/icu/icu.mk+1 -00 replies
11/23omniorb: avoid target-only patch hookpackage/omniorb/0002-optional-appl-services.patch package/omniorb/omniorb.mk+42 -130 replies
12/23lua: rework post-patch hook usagepackage/lua/5.1.5/0001-root-path.patch package/lua/5.3.6/0001-root-path.patch package/lua/5.4.9/0001-root-path.patch +1 more+43 -250 replies
13/23infra: host packages inherit the target extra downloadspackage/android-tools/android-tools.mk package/binutils/binutils.mk package/gdb/gdb.mk +1 more+6 -30 replies
14/23package/libtool: use post-patch hookspackage/libtool/libtool.mk+2 -20 replies
15/23package/libtool: also apply libtool-patch to host libtoolpackage/libtool/libtool.mk package/pkg-autotools.mk+0 -50 replies
16/23package/{ffmpeg, libvpx}: use $(@D) instead of $(pkg_SRCDIR) when possiblepackage/ffmpeg/ffmpeg.mk package/libvpx/libvpx.mk+2 -20 replies
17/23package/perl: apply the perl-cross even for the host variantpackage/perl/0001-configure-keep-_GNU_SOURCE-in-build-flags.patch package/perl/perl.mk+2 -90 replies
18/23infra/autotools: warn for package that autoreconf without libtool patchpackage/pkg-autotools.mk+4 -00 replies
19/23packages: replace $(PKG)_DIR with @D where possiblepackage/linux-backports/linux-backports.mk package/ncftp/ncftp.mk package/pciutils/pciutils.mk +1 more+4 -40 replies
20/23linux: support custom logo and devicetree files in out-of-tree buildslinux/linux.mk package/pkg-generic.mk support/scripts/symlink-tree+89 -80 replies
21/23package/linux-tools: support an out-of-tree kernel buildpackage/linux-tools/linux-tool-cpupower.mk.in package/linux-tools/linux-tool-gpio.mk.in package/linux-tools/linux-tool-hv.mk.in +9 more+81 -530 replies
22/23package: read kernel headers from LINUX_SRCDIRpackage/a10disp/a10disp.mk package/freescale-imx/imx-alsa-plugins/imx-alsa-plugins.mk package/freescale-imx/imx-lib/imx-lib.mk +2 more+5 -50 replies
23/23docs/manual: document out-of-tree package builds and the new srcdir variablesdocs/manual/adding-packages-generic.adoc docs/manual/using-buildroot-development.adoc+50 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Buildroot] [PATCH v2 00/23] Support building the Linux kernel out of tree

Hello,

This series lets a package be built out of tree, i.e. with its sources in a directory separate from the build directory, and enables it for the Linux kernel.

For a large source tree such as the kernel, this matters for the LINUX_OVERRIDE_SRCDIR workflow: the rsync step is slow, doubles the disk usage, and leaves the developer's tree and the build directory out of sync. With this series the kernel is configured and built with O=output/build/linux-<version> (or linux-custom with an override), and the sources in the overridden directory are never written to.

A package opts in with <pkg>_SUPPORTS_OUT_OF_TREE = YES, and is then always built out of tree:
- without an override, the tarball is extracted and patched in output/source/<pkg>-<version>, and output/build/<pkg>-<version> only contains the generated files;
- with <pkg>_OVERRIDE_SRCDIR set, the overridden directory is used in place, with no rsync, and the build directory is output/build/<pkg>-custom.
Only linux opts in for now, all the other packages are unchanged.

Most of the groundwork comes from the out-of-tree work Thomas Petazzoni and Yann E. Morin did in 2015-2017, which was never merged. It has been rebased on current master, and extended to cover the custom logo, custom device tree files, and linux-tools. Their authorship is preserved.

Series overview
===============

Patches 1-8, infra preparation:
- introduce <pkg>_SRCDIR (where the sources are) and <pkg>_BUILDDIR (where the package is built, and where the stamp files live), both defaulting to <pkg>_DIR, so nothing changes for existing packages;
- fix up the users of LINUX_DIR that need the build directory (boot-wrapper-aarch64, mxs-bootlets, the linux extensions), and run the kernel version probing from the build directory;
- introduce <pkg>_SRCSUBDIR (<pkg>_SRCDIR/<pkg>_SUBDIR) and convert the infras (cargo, hare, luarocks, meson, perl, waf) and gcc-final to it.

Patch 9, the kernel:
- add <pkg>_SUPPORTS_OUT_OF_TREE, which defaults to NO so that an infrastructure can later change the default (e.g. autotools, with a per-package opt-out). A package that sets it has its sources in $(SRC_DIR) (output/source) and is built in $(BUILD_DIR), with kconfig called with -C $(SRCDIR) O=$(BUILDDIR). When <pkg>_OVERRIDE_SRCDIR is set, the rsync step is skipped and the stamp files go in the build directory. <pkg>-dirclean and make clean also remove the extracted sources;
- opt linux in, in the same patch. When the sources are overridden, Kbuild requires a clean source tree for O=: a tree with a stale .config, include/config or arch/*/include/generated is rejected by kbuild itself.

Patches 10-19, host/target consistency. When the sources are shared between the host and the target variant of a package, they must not be patched differently, so:
- sync the host and target patch hooks, and fix omniorb, lua and perl

    which did different things between the two variants;
  - have host packages inherit the extra downloads and apply the libtool
    patch to host libtool;

- warn about packages that autoreconf without the libtool patch;
- replace $(PKG)_DIR with $(@D) where this is possible.

Patches 20-21, the parts that write to the kernel sources:
- the custom logo (BR2_LINUX_KERNEL_CUSTOM_LOGO_PATH) and custom device tree files (BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) are copied into the kernel sources. With an overridden source directory, linux is built from a "shadow" tree: real directories whose files are symbolic links to the original tree, created by the new support/scripts/symlink-tree. Files are replaced rather than written through the links, so the overridden tree is never modified;
- linux-tools checks which tools are available in $(LINUX_SRCDIR)/tools, and builds them in a shadow of that directory, because several of the kernel tools build in place, and some (mm, tmon) do not support OUTPUT/O= at all. This also covers the PCI endpoint selftests path.

Patches 22-23:
- packages that read kernel headers from the source tree use

    $(LINUX_SRCDIR) instead of $(LINUX_DIR);

- document the feature and the new variables in the manual.

Things this series intentionally does not do
============================================

- Only linux opts in. The other packages still extract and build in output/build/<pkg>-<version>, and still rsync with an override. Other packages can opt in later, with the same variable.
- The "hooks sanity check" and "host inherits the target hooks" patches of the original series are not included: they do not work with the infras that register per-name hooks (e.g. golang).
- The Python 2 and asterisk patches of the original series are dropped:
those packages are gone or no longer need them.

Testing
=======

All of the following build with the series applied on top of master (1cfdb4efd539), from scratch (no build, host, staging or source directory):

- raspberrypi4_64_defconfig, stock, and with the Raspberry Pi kernel

    sources overridden through LINUX_OVERRIDE_SRCDIR;
  - qemu_x86_64 and qemu_arm_vexpress, stock, and with an overridden
    kernel source directory; all four boot to a login prompt in QEMU;
  - a wide package set on top of raspberrypi4_64_defconfig (autotools,
    cmake, meson, perl, python, cargo, golang, waf, luarocks, hare,
    kernel modules, asterisk, ffmpeg, libvpx, u-boot, and the linux-tools
    gpio, iio, perf, pci, cpupower, rtla, tmon, mm, usbtools), both with
    and without an override: the content of target/ is identical;
  - a custom logo and a custom device tree file with a #include, both
    without an override, and with an override where the overridden tree
    is left unmodified;
  - the same package set in the Buildroot CI docker image, offline;
  - <pkg>-dirclean, -rebuild, -reconfigure, -legal-info, -source,
    show-info and linux-rebuild-with-initramfs;

- every patch of the series builds, tested on a small package set.

Known issues, not caused by this series and identical with and without it:
xtables-addons does not build with the Raspberry Pi 6.12 kernel, and some linux-tools selftests (mm) fail to link. I have not tested the selftests in the docker image, as the container has no python yaml.

Not tested: the other kernel extensions (rtai, xenomai), which are adapted but not built, and booting on real hardware.

Changes
=======

Changes since v1:
- patch 3: removed a leftover "WIP" note from the commit message;
- patch 9: as suggested by Thomas and Arnout, out-of-tree is no longer only used with <pkg>_OVERRIDE_SRCDIR: a package that sets <pkg>_SUPPORTS_OUT_OF_TREE is always built out of tree, with its sources extracted in output/source. SRC_DIR is now a separate directory, and dirclean and make clean remove it. Patches 20 and 23 are adapted accordingly;
- patch 12 (lua): the host variant also modified luaconf.h, to set LUA_ROOT, in a host-only post-patch hook. As suggested, this is no longer done on the shared sources: the Buildroot patch now lets LUA_ROOT be overridden, host-lua sets it in its CFLAGS, and the installed host luaconf.h is adjusted in a post-install hook;
- patch 17 (perl): as suggested, revert 8dea6e7c089c ("package/perl:
apply perl-cross patch only on target perl"): the perl-cross patch is a normal package patch again, applied to both variants, and the PERL_POST_PATCH_HOOKS hook is dropped;
- the subject no longer mentions LINUX_OVERRIDE_SRCDIR.

Regards,
Florian

Florian Fainelli (6):
package: use <pkg>_SRCSUBDIR where <pkg>_SRCDIR used to include
_SUBDIR
linux: build out of tree
linux: support custom logo and devicetree files in out-of-tree builds package/linux-tools: support an out-of-tree kernel build
package: read kernel headers from LINUX_SRCDIR docs/manual: document out-of-tree package builds and the new srcdir
variables

Thomas Petazzoni (7):
package: prepare removal of <pkg>_DIR
infra: introduce a global SRC_DIR variable
packages: sync host and target patch hooks
omniorb: avoid target-only patch hook
lua: rework post-patch hook usage
package/libtool: use post-patch hooks package/{ffmpeg,libvpx}: use $(@D) instead of $(pkg_SRCDIR) when
possible

Yann E. MORIN (10):
package: fix <pkg>_SRCDIR and <pkg>_BUILDDIR values boot/boot-wrapper-aarch64: needs LINUX_BUILDDIR boot/mxs-bootlets: needs (BAREBOX,LINUX,UBOOT)_BUILDDIR linux/extensions: point to proper _SRCDIR and @D linux/linux: LINUX_VERSION_PROBED should run from build directory
infra: host packages inherit the target extra downloads package/libtool: also apply libtool-patch to host libtool package/perl: apply the perl-cross even for the host variant infra/autotools: warn for package that autoreconf without libtool
patch
packages: replace $(PKG)_DIR with @D where possible

 Makefile                                      |  3 +-
 .../boot-wrapper-aarch64.mk                   |  8 +-
 boot/mxs-bootlets/mxs-bootlets.mk             |  6 +-
 docs/manual/adding-packages-generic.adoc      | 12 +++
 docs/manual/using-buildroot-development.adoc  | 38 +++++++++
 linux/linux-ext-rtai.mk                       |  8 +-
 linux/linux-ext-xenomai.mk                    |  4 +-
 linux/linux.mk                                | 41 ++++++++--
 package/a10disp/a10disp.mk                    |  2 +-
 package/android-tools/android-tools.mk        |  1 -
 package/binutils/binutils.mk                  |  1 -
 package/ffmpeg/ffmpeg.mk                      |  2 +-
 .../imx-alsa-plugins/imx-alsa-plugins.mk      |  2 +-
 package/freescale-imx/imx-lib/imx-lib.mk      |  2 +-
 package/gcc/gcc-final/gcc-final.mk            |  2 +-
 package/gdb/gdb.mk                            |  1 -
 package/gstreamer1/gst1-imx/gst1-imx.mk       |  2 +-
 package/icu/icu.mk                            |  1 +
 package/libtool/libtool.mk                    |  5 +-
 package/libvpx/libvpx.mk                      |  2 +-
 package/linux-backports/linux-backports.mk    |  2 +-
 package/linux-tools/linux-tool-cpupower.mk.in |  8 +-
 package/linux-tools/linux-tool-gpio.mk.in     |  6 +-
 package/linux-tools/linux-tool-hv.mk.in       |  6 +-
 package/linux-tools/linux-tool-iio.mk.in      |  6 +-
 package/linux-tools/linux-tool-mm.mk.in       | 10 +--
 package/linux-tools/linux-tool-pci.mk.in      | 12 +--
 package/linux-tools/linux-tool-perf.mk.in     | 27 ++++---
 package/linux-tools/linux-tool-rtla.mk.in     | 10 +--
 .../linux-tools/linux-tool-selftests.mk.in    | 15 ++--
 package/linux-tools/linux-tool-tmon.mk.in     |  8 +-
 package/linux-tools/linux-tool-usbtools.mk.in |  6 +-
 package/linux-tools/linux-tools.mk            | 20 ++++-
 package/lua/5.1.5/0001-root-path.patch        | 24 +++---
 package/lua/5.3.6/0001-root-path.patch        | 15 +++-
 package/lua/5.4.9/0001-root-path.patch        | 11 ++-
 package/lua/lua.mk                            | 18 ++++-
 package/ncftp/ncftp.mk                        |  2 +-
 .../omniorb/0002-optional-appl-services.patch | 29 +++++++
 package/omniorb/omniorb.mk                    | 26 +++----
 package/pciutils/pciutils.mk                  |  2 +-
 ...gure-keep-_GNU_SOURCE-in-build-flags.patch |  0
 package/perl/perl.mk                          | 11 +--
 package/php/php.mk                            |  2 +-
 package/pkg-autotools.mk                      | 28 +++----
 package/pkg-cargo.mk                          |  8 +-
 package/pkg-cmake.mk                          |  8 +-
 package/pkg-generic.mk                        | 77 +++++++++++++------
 package/pkg-hare.mk                           |  8 +-
 package/pkg-kconfig.mk                        | 48 ++++++------
 package/pkg-luarocks.mk                       | 10 +--
 package/pkg-meson.mk                          | 26 +++----
 package/pkg-perl.mk                           | 12 +--
 package/pkg-waf.mk                            |  8 +-
 .../xdriver_xf86-video-imx.mk                 |  2 +-
 support/scripts/symlink-tree                  | 58 ++++++++++++++
 56 files changed, 471 insertions(+), 241 deletions(-)
 create mode 100644 package/omniorb/0002-optional-appl-services.patch
 rename package/perl/{perl-cross => }/0001-configure-keep-_GNU_SOURCE-in-build-flags.patch (100%)
 create mode 100755 support/scripts/symlink-tree
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot