Re: [OE-core] [PATCH v7 01/14] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS

Yoann Congal
2026-03-12T22:21:07Z

On Thu Mar 12, 2026 at 2:34 PM CET, Richard Purdie wrote:
> On Wed, 2026-03-04 at 09:43 -0800, Sadineni, Harish via lists.openembedded.org wrote:
>> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>>
>> Conditionally add 'clang-native', 'rust-native' and 'bindgen-cli-native' to 'DEPENDS'
>> when Kernel Rust Support is enabled.
>>
>> These tools are required for building Rust-enabled kernels and for
>> generating Rust FFI bindings via bindgen during the kernel build.
>>
>> This ensures the additional dependencies are only pulled in when
>> Rust support is explicitly enabled, avoiding unnecessary native
>> dependencies for non-Rust kernel builds.
>>
>> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
>> ---
>>  meta/recipes-kernel/linux/linux-yocto.inc | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 4d0a726bb6..b7961bbcdf 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -76,11 +76,14 @@ do_install:append(){
>>  KERNEL_FEATURES:append:qemuall = " features/kernel-sample/kernel-sample.scc"
>>
>>  KERNEL_DEBUG ?= ""
>> +KERNEL_RUST_SUPPORT ?= ""
>>  # These used to be version specific, but are now common dependencies.  New
>>  # tools / dependencies will continue to be added in version specific recipes.
>>  DEPENDS += '${@bb.utils.contains_any("ARCH", [ "x86", "arm64", "powerpc" ], "elfutils-native", "", d)}'
>>  DEPENDS += "openssl-native util-linux-native"
>>  DEPENDS += "gmp-native libmpc-native"
>> +RUST_KERNEL_DEPENDS ?= "${@bb.utils.contains('KERNEL_RUST_SUPPORT', 'True', 'clang-native rust-native bindgen-cli-native', '', d)}"
>> +DEPENDS += "${RUST_KERNEL_DEPENDS}"
>>
>>  # Some options depend on CONFIG_PAHOLE_VERSION, so need to make pahole-native available before do_kernel_configme
>>  do_kernel_configme[depends] += '${@bb.utils.contains("KERNEL_DEBUG", "True", "pahole-native:do_populate_sysroot", "", d)}'
>
> I get the feeling we're still not quite agreeing on how to make the
> enabling of the feature work. I'm suggesting we do something like this:
>
> diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
> index e53bf151941..9cc7568ab09 100644
> --- a/meta/classes-recipe/kernel-yocto.bbclass
> +++ b/meta/classes-recipe/kernel-yocto.bbclass
> @@ -269,6 +269,9 @@ do_kernel_metadata() {
> KERNEL_FEATURES_FINAL=""
> if [ -n "${KERNEL_FEATURES}" ]; then
> for feature in ${KERNEL_FEATURES}; do
> + if [ "$feature" = "rust" ]; then
> + feature="features/kernel-rust/kernel-rust.scc"
> + fi
> feature_as_specified="$feature"
> feature="$(echo $feature_as_specified | cut -d: -f1)"
> feature_specifier="$(echo $feature_as_specified | cut -d: -f2)"
>
> which means you can then simply add to your config:
>
> KERNEL_FEATURES += "rust"
>
> and things should be enabled. This patch would then become:
>
> RUST_KERNEL_DEPENDS ?= "${@bb.utils.contains('KERNEL_FEATURES', 'rust', 'clang-native rust-native bindgen-cli-native', '', d)}"
>
> Is there some reason we can't do something like this?

I did try and it worked: See "TO SQUASH: switch linux-yocto rust enabling to KERNEL_FEATURES"
https://git.openembedded.org/openembedded-core-contrib/commit/?h=ycongal/master/kernel-rust&id=17d4d7979e9bcf3a1c56c37357940a802a0ff570

Harish, while you rebase over the recently merged rust upgrade. Can you
look at this suggestion and see if that work for you? If you like it
(and I hope you do), please squash it in the right commits of your
series.

Regards,

>
> Cheers,
>
> Richard

--
Yoann Congal
Smile ECS