[PATCH 8/8] kernel: remove pkg-config variables for old (<5.15) kernels

Ross Burton
2026-01-23T18:05:09Z

The kernel has supported setting an alternative binary for pkg-config
with a variable since 5.19 (in 2022[1]) and we set that to
pkg-config-native, so there is no longer any need to also manually set
the PKG_CONFIG_* variables.

The relevant commit was backported and is present in 5.15.91 onwards,
but is not yet in 5.10.x.

[1] linux d5ea4fece450 ("kbuild: Allow kernel installation packaging to override pkg-config")

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
meta/classes-recipe/kernel.bbclass | 9 ---------
meta/recipes-kernel/linux/linux-yocto.inc | 7 ++-----
2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index b43b4ff4fb..1ebf027281 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -251,7 +251,6 @@ KERNEL_EXTRA_ARGS ?= ""
EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" STRIP="${KERNEL_STRIP}"'
EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"'
EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"'
-# Only for newer kernels (5.19+), native pkg-config variables are set for older kernels when building kernel and modules
EXTRA_OEMAKE += ' HOSTPKG_CONFIG="pkg-config-native"'

KERNEL_ALT_IMAGETYPE ??= ""
@@ -364,10 +363,6 @@ KERNEL_DEBUG_TIMESTAMPS ??= "0"
kernel_do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE

- # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
- export PKG_CONFIG_LIBDIR="${STAGING_LIBDIR_NATIVE}/pkgconfig:${STAGING_DATADIR_NATIVE}/pkgconfig"
- export PKG_CONFIG_SYSROOT_DIR=""
-
if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
# be set....
@@ -418,10 +413,6 @@ addtask transform_kernel after do_compile before do_install
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE

- # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
- export PKG_CONFIG_LIBDIR="${STAGING_LIBDIR_NATIVE}/pkgconfig:${STAGING_DATADIR_NATIVE}/pkgconfig"
- export PKG_CONFIG_SYSROOT_DIR=""
-
if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
# be set....
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index d57c1aae25..4e230d405a 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -88,9 +88,6 @@ do_kernel_configme[depends] += '${@bb.utils.contains("KERNEL_DEBUG", "True", "pa
EXTRA_OEMAKE += '${@bb.utils.contains("KERNEL_DEBUG", "True", "", "PAHOLE=false", d)}'

do_devshell:prepend() {
- # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
- d.setVar("PKG_CONFIG_PATH", "")
- d.setVar("PKG_CONFIG_LIBDIR", "${STAGING_LIBDIR_NATIVE}/pkgconfig:${STAGING_DATADIR_NATIVE}/pkgconfig")
- d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1")
- d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR")
+ d.setVar("HOSTPKG_CONFIG", "pkg-config-native")
+ d.appendVar("OE_TERMINAL_EXPORTS", " HOSTPKG_CONFIG")
}
--
2.43.0