toolchain/toolchain-external: introduce BR2_TOOLCHAIN_EXTERNAL_UPDATE_LINUX_HEADERS
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Rustam,
you should add your remark about glibc upward compatibility to the patch description. It helps to understand the context ...
Further remarks below:
Quoted 59 lines · Rustam Abdullaev
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 akernel
# build or a standalone header package.toolchain/Config.in +2
-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_HEADERStoolchain/Config.in +4
-0+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=27597toolchain/helpers.mk +0
-0
toolchain/helpers.mk copy_toolchain_sysroot = \ · line 170
Quoted 9 lines
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) ; \
Do not remove the check completely, but test for BR2_PACKAGE_LINUX_HEADERS additionally, similar to toolchain/toolchain-external/pkg-toolchain-external.mk
Quoted 23 lines
toolchain/helpers.mk +0
-0then \ exit 1; \ fitoolchain/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 +0
-0@@ -157,4 +157,13 @@ config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY Copy the gdbserver provided by the external toolchain to the target.
toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY · line 168
Quoted 10 lines
toolchain/toolchain-external/Config.in +9
-0+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. +
This approach probably works only for glibc toolchains, so the option should depend on BR2_TOOLCHAIN_EXTERNAL_GLIBC (or BR2_TOOLCHAIN_USES_GLIBC).
With (internal) uClibc and musl I had occasional problems updating kernel versions while not rebuilding the toolchain ...
Quoted 25 lines
toolchain/toolchain-external/Config.in +0
-0endif # BR2_TOOLCHAIN_EXTERNALtoolchain/toolchain-external/pkg-toolchain-external.mk +4
-0@@ -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 libraryfeatures.
toolchain/toolchain-external/pkg-toolchain-external.mk +1
-0+# Also updates the kernel headers in the toolchain, if requested. define $(2)_CONFIGURE_CMDS $$(Q)$$(call check_cross_compiler_exists,$$(TOOLCHAIN_EXTERNAL_CC)) $$(Q)$$(callcheck_unusable_toolchain,$$(TOOLCHAIN_EXTERNAL_CC),"$$(TOOLCHAIN_EXTERNAL_CFLAGS)")
$$(Q)SYSROOT_DIR="$$(call
toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC))" ; \
toolchain/toolchain-external/pkg-toolchain-external.mk
Quoted 5 lines
toolchain/toolchain-external/pkg-toolchain-external.mk +5
-0+ 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 ; \
Not a good idea. This might work when the kernel headers are processed initially, but once you upgrade the kernel patch level, you will copy a lot of unrelated headers into your toolchain include directory.
The kernel uses INSTALL_HDR_PATH to determine the install location for the headers. This variable is set in linux-headers.mk and you should adapt the INSTALL_STAGING_CMDS there.
Quoted 11 lines
toolchain/toolchain-external/pkg-toolchain-external.mk +1
-1$$(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)); \
toolchain/toolchain-external/pkg-toolchain-external.mk +0
-1$$(call check_gcc_version,$$(TOOLCHAIN_EXTERNAL_CC),\ $$(call qstrip,$$(BR2_TOOLCHAIN_GCC_AT_LEAST))); \ if test "$$(BR2_arm)" = "y" ; then \ --
Quoted 1 line
2.39.5
Kind regards,
Andreas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot