Bug 15992 - Unexpected behaviour with TOOLCHAIN
Summary: Unexpected behaviour with TOOLCHAIN
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 5.2
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 5.3 M4
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2025-10-09 17:04 UTC by Ross Burton
Modified: 2026-03-12 15:14 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.