toolchain/toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_UPDATE_LINUX_HEADERS
PATCH 1/1 toolchain/toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_UPDATE_LINUX_HEADERS
This change makes it possible to update kernel headers in the external toolchain with the headers from the current kernel.
It is important to have matching kernel headers when building packages that make use of kernel features such as seccomp, as they depend on system call definitions in linux/unistd.h. A typical example of this is openssh - building it with the official ARM GNU toolchain and kernel 6.x results in a non-working sshd.
Signed-off-by Rustam Abdullaev <[email protected]>
--- package/linux-headers/linux-headers.mk | 3 ++- toolchain/Config.in | 6 ++++++ toolchain/helpers.mk | 4 +--- toolchain/toolchain-buildroot/Config.in | 2 -- toolchain/toolchain-external/Config.in | 9 +++++++++ .../toolchain-external/pkg-toolchain-external.mk | 12 +++++++++++- 6 files changed, 29 insertions(+), 7 deletions(-)
package/linux-headers/linux-headers.mk +2 -1
@@ -5,7 +5,8 @@ ################################################################################ # This package is used to provide Linux kernel headers for the -# internal toolchain backend. +# internal toolchain backend and for external toolchains that need +# updated kernel headers. # Set variables depending on whether we are using headers from a kernel # build or a standalone header package.
toolchain/Config.in +6 -0
@@ -69,6 +69,12 @@ source "toolchain/toolchain-external/Config.in" # so put it here instead source "package/gdb/Config.in.host" +# Linux headers can be used by both internal and external toolchains +if BR2_TOOLCHAIN_BUILDROOT || BR2_TOOLCHAIN_EXTERNAL_UPDATE_LINUX_HEADERS +source "package/linux-headers/Config.in.host" +source "package/linux-headers/Config.in" +endif + comment "Toolchain Generic Options" # https://sourceware.org/bugzilla/show_bug.cgi?id=27597
toolchain/helpers.mk +1 -3
@@ -165,11 +165,9 @@ copy_toolchain_sysroot = \ # $2: sysroot directory # $3: kernel version string, in the form: X.Y # $4: test to do for the latest kernel version, 'strict' or 'loose' -# always 'strict' if this is not the latest version. # check_kernel_headers_version = \ - if ! support/scripts/check-kernel-headers.sh $(1) $(2) $(3) \ - $(if $(BR2_TOOLCHAIN_HEADERS_LATEST),$(4),strict); \ + if ! support/scripts/check-kernel-headers.sh $(1) $(2) $(3) $(4) ; \ then \ exit 1; \ fi
toolchain/toolchain-buildroot/Config.in +0 -2
@@ -104,8 +104,6 @@ config BR2_TOOLCHAIN_BUILDROOT_LIBC default "glibc" if BR2_TOOLCHAIN_BUILDROOT_GLIBC default "musl" if BR2_TOOLCHAIN_BUILDROOT_MUSL -source "package/linux-headers/Config.in.host" -source "package/linux-headers/Config.in" source "package/musl/Config.in" source "package/uclibc/Config.in" source "package/glibc/Config.in"
toolchain/toolchain-external/Config.in +9 -0
@@ -157,4 +157,13 @@ config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY Copy the gdbserver provided by the external toolchain to the target. +config BR2_TOOLCHAIN_EXTERNAL_UPDATE_LINUX_HEADERS + bool "Update kernel headers" + select BR2_PACKAGE_LINUX_HEADERS + help + Select this option to update the kernel headers in the + external toolchain with headers from the kernel being built. + This is useful when the external toolchain has older kernel + headers than the kernel being built. + endif # BR2_TOOLCHAIN_EXTERNAL
toolchain/toolchain-external/pkg-toolchain-external.mk +11 -1
@@ -557,19 +557,29 @@ $(2)_POST_EXTRACT_HOOKS += \ TOOLCHAIN_EXTERNAL_MOVE endif +ifeq ($$(BR2_PACKAGE_LINUX_HEADERS),y) +$(2)_DEPENDENCIES += linux-headers +endif + # Checks for an already installed toolchain: check the toolchain # location, check that it is usable, and then verify that it # matches the configuration provided in Buildroot: ABI, C++ support, # kernel headers version, type of C library and all C library features. +# Also updates the kernel headers in the toolchain, if requested. define $(2)_CONFIGURE_CMDS $$(Q)$$(call check_cross_compiler_exists,$$(TOOLCHAIN_EXTERNAL_CC)) $$(Q)$$(call check_unusable_toolchain,$$(TOOLCHAIN_EXTERNAL_CC),"$$(TOOLCHAIN_EXTERNAL_CFLAGS)") $$(Q)SYSROOT_DIR="$$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC))" ; \ + if test "$$(BR2_PACKAGE_LINUX_HEADERS)" = "y" ; then \ + echo "Updating kernel headers in the external toolchain..." ; \ + rsync -a $$(STAGING_DIR)/usr/include/ \ + $$$${SYSROOT_DIR}/usr/include/ ; \ + fi ; \ $$(call check_kernel_headers_version,\ $$(BUILD_DIR),\ $$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC)),\ $$(call qstrip,$$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)),\ - $$(if $$(BR2_TOOLCHAIN_EXTERNAL_CUSTOM),loose,strict)); \ + $$(if $$(or $$(BR2_TOOLCHAIN_EXTERNAL_CUSTOM),$$(BR2_PACKAGE_LINUX_HEADERS)),loose,strict)); \ $$(call check_gcc_version,$$(TOOLCHAIN_EXTERNAL_CC),\ $$(call qstrip,$$(BR2_TOOLCHAIN_GCC_AT_LEAST))); \ if test "$$(BR2_arm)" = "y" ; then \
Signature · 6 lines
2.39.5 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot