summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
authorMunehisa Kamata <kamatam@amazon.com>2024-03-02 15:23:58 -0800
committerSteve Sakoman <steve@sakoman.com>2024-03-07 08:32:54 -1000
commitd34002348374669528bb884c2d7be1b91938f471 (patch)
treebf9522a71c506ce4de22bbee859884817a63aa27 /meta/classes/kernel.bbclass
parenta73f68616537df6e9e17a0e481092fce86b54a65 (diff)
downloadpoky-d34002348374669528bb884c2d7be1b91938f471.tar.gz
kernel.bbclass: Set pkg-config variables for building modules
[Backport cd2072e5d953 from the master without HOSTPKG_CONFIG setting] The pkg-config workaround has been applied for kernel image building, but not for module building. So pkg-config variables are different between do_compile and do_compile_kernelmodules tasks. It may unnecessary trigger rebuilding of a few host tools at the later task. Especially when CONFIG_DEBUG_INFO_BTF is enabled in the kernel, it may even trigger rebuilding vmlinux at do_compile_kernelmodules due to the rebuilt host tools such as certs/extract-cert or objtool (on x86). This eventually creates an inconsistent set of kernel binaries. Here is the repro steps: - Check out nanbield on x86 - The unexpected rebuild happens on kirkstone or possibly earlier - Ensure that pahole is available (e.g. via meta-oe) - Set KERNEL_DEBUG to "True" to properly set up PAHOLE e.g. $ export KERNEL_DEBUG="True" $ export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS} KERNEL_DEBUG" - Enable CONFIG_DEBUG_INFO_BTF=y e.g. $ bitbake -c menuconfig virtual/kernel -> Kernel hacking -> Compile-time checks and compiler options -> Generate BTF typeinfo - Build the kernel e.g. $ bitbake virtual/kernel The BTF information in the resulting bzImage and kernel modules are inconsistent, because the module's BTF information is generated using the "second" vmlinux that doesn't have the identical BTF to the "first" vmlinux. These modules can't be loaded at runtime due to the BTF mismatch. This also leads to a build-id mismatch between the installed bzImage and vmlinux since the bzImage is created from the first vmlinux, but the installed vmlinux is the second one. $ eu-readelf -n tmp/work/qemux86_64-poky-linux/linux-yocto/6.5.13+git/image/boot/{bzImage*,vmlinux*} | grep "Build ID" Build ID: 4a0d62ee7fef0244950f0f604253729875bea493 Build ID: fb99b3d91399dbe42bf67ddee59e0f5a0c7f74d9 To avoid the unexpected rebuilding that results in such inconsistency, set the same pkg-config variables when building kernel and modules. For kernel 5.19 and above, simply set the HOSTPKG_CONFIG in the make command line. (From OE-Core rev: d63af11e92094487d6e358f27283e5385937e7a8) Signed-off-by: Munehisa Kamata <kamatam@amazon.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass7
1 files changed, 7 insertions, 0 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 96e41b5192..dbd89057f3 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -396,6 +396,13 @@ addtask transform_kernel after do_compile before do_install
396 396
397do_compile_kernelmodules() { 397do_compile_kernelmodules() {
398 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 398 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
399
400 # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
401 export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
402 export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
403 export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
404 export PKG_CONFIG_SYSROOT_DIR=""
405
399 if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then 406 if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
400 # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not 407 # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
401 # be set.... 408 # be set....