Bug 15992

Summary: Unexpected behaviour with TOOLCHAIN
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Ross Burton <ross.burton>
Component: devtools / tool chainAssignee: Ross Burton <ross.burton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: antonin.godard, meta.mr.watcher, meta.watcher, raj.khem, randy.macleod
Version: 5.2   
Target Milestone: 5.3 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Ross Burton 2025-10-09 17:04:04 UTC
If I set TOOLCHAIN=clang in local.conf and then build a native recipe, the overrides that are used as not quite as expected:

$ bitbake-getvar -r gn-native --value OVERRIDES
linux:aarch64:pn-gn-native:layer-core::poky:class-native:toolchain-clang:forcevariable

Specifically, "toolchain-clang" is unexpected because the build will be using the host GCC.

I suspect the answer is "set PREFERRED_TOOLCHAIN instead", which is fine. But should native.bbclass be setting TOOLCHAIN=TOOLCHAIN_NATIVE too?
Comment 1 Khem Raj 2025-10-09 20:23:10 UTC
(In reply to Ross Burton from comment #0)
> If I set TOOLCHAIN=clang in local.conf and then build a native recipe, the
> overrides that are used as not quite as expected:
> 
> $ bitbake-getvar -r gn-native --value OVERRIDES
> linux:aarch64:pn-gn-native:layer-core::poky:class-native:toolchain-clang:
> forcevariable
> 
> Specifically, "toolchain-clang" is unexpected because the build will be
> using the host GCC.
>

PREFERRED_TOOLCHAIN_{TARGET|NATIVE|SDK} are new interfaces
 
> I suspect the answer is "set PREFERRED_TOOLCHAIN instead", which is fine.
> But should native.bbclass be setting TOOLCHAIN=TOOLCHAIN_NATIVE too?

yeah perhaps might be ok, I also wonder if we have similar issue with SDK case.
Comment 2 Ross Burton 2025-10-16 14:39:37 UTC
We should at least have something in the migration guide about this. We should say that clang has been integrated into core, meta-clang is no longer essential, but when picking a compiler at a distro level PREFERRED_TOOLCHAIN should be used instead of TOOLCHAIN.

Antonin, can you add something like that?
Comment 3 Antonin Godard 2025-10-16 15:18:05 UTC
I added a note on that to the release note updates I sent today:

>     .. warning::
>        The :term:`TOOLCHAIN` should **not** be set globally. For overridding
>        the toolchain globally, use :term:`PREFERRED_TOOLCHAIN_TARGET`,
>        :term:`PREFERRED_TOOLCHAIN_NATIVE` and :term:`PREFERRED_TOOLCHAIN_SDK`.

(I realize now I'm missing "variable" after TOOLCHAIN, will fix that)

https://lore.kernel.org/yocto-docs/20251016-release-note-5-3-second-hunk-v1-17-20f21db1f93c@bootlin.com/

Do you think that's enough or should I mention something else?
Comment 4 Ross Burton 2026-03-12 15:14:14 UTC
The doc changes look good.