On Tue, 2026-06-23 at 23:42 -0700, Hemanth Kumar M D via
lists.openembedded.org wrote:
> From: Hemanth Kumar M D <[email protected]>
> 
> Cargo walks from CWD up to the filesystem root merging every
> .cargo/config.toml it finds. Any such file above TOPDIR is silently
> picked up and can override Yocto's linker, registry or compiler
> settings, leading to build failures.
> 
> Until cargo provides a proper fix upstream, add a warning so users
> get a clear diagnostic instead of a build error.
> 
> Upstream meta-issue: https://github.com/rust-lang/cargo/issues/9769
> 
> [YOCTO #15637]
> 
> Signed-off-by: Hemanth Kumar M D <[email protected]>
> ---
>  meta/classes-global/sanity.bbclass | 33 ++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/meta/classes-global/sanity.bbclass 
> b/meta/classes-global/sanity.bbclass
> index bdfa7f059d..c67c7b8f03 100644
> --- a/meta/classes-global/sanity.bbclass
> +++ b/meta/classes-global/sanity.bbclass
> @@ -854,6 +854,38 @@ def sanity_check_locale(d):
>      except locale.Error:
>          raise_sanity_error("Your system needs to support the en_US.UTF-8 
> locale.", d)
>  
> +def check_cargo_config(d):
> +    # Cargo merges .cargo/config.toml from every directory between CWD and
> +    # the filesystem root. Warn for anything found in ancestor directories
> +    # above TOPDIR that Cargo would pick up silently.
> +    import os
> +
> +    topdir = d.getVar('TOPDIR')

TMPDIR and each package's WORKDIR are under TOPDIR by default, but this
can be overridden. Perhaps we should be checking ancestors of
BASE_WORKDIR instead.

> +    ancestor = os.path.dirname(topdir)
> +    found = []
> +    last_ancestor = None
> +    while True:
> +        for name in ('config.toml', 'config'):
> +            cfg = os.path.join(ancestor, '.cargo', name)
> +            if os.path.exists(cfg):
> +                found.append(cfg)
> +                last_ancestor = ancestor
> +                break

This `break` should be dropped so that we tell the user about all
offending Cargo config files.

The rest of this patch LGTM, thanks!

Best regards,

-- 
Paul Barker

Attachment: signature.asc
Description: This is a digitally signed message part

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239476): 
https://lists.openembedded.org/g/openembedded-core/message/239476
Mute This Topic: https://lists.openembedded.org/mt/119953525/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to