Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: raj.khem@gmail.com, openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH v3 01/13] toolchain: Provide abstraction for choosing per-recipe toolchain
Date: Thu, 29 May 2025 15:10:51 +0100	[thread overview]
Message-ID: <49561b17ed66b3ac9872da5d5ea578317da40877.camel@linuxfoundation.org> (raw)
In-Reply-To: <20250522-clang-toolchain-v3-1-16cfc6d9891b@gmail.com>

On Thu, 2025-05-22 at 20:52 -0700, Khem Raj via lists.openembedded.org wrote:
> This implements a toolchain selection mechanism with existing defaults
> unchanged.
> 
> It introduces a variable called TOOLCHAIN, which denotes the familiar
> name for toolchain e.g. "gcc" which selects GNU compiler + binutils
> as default C/C++ toolchain or "clang" which will use LLVM/Clang Compiler
> 
> Additionally build-gcc is used for selecting native compiler
> 
> TOOLCHAIN variable has a global fallback to "gcc" in configuration
> metadata. A distro can switch to using say "clang" as default system
> compiler by defining
> 
> TOOLCHAIN ?= "clang"
> 
> In local.conf or other distro specific global configuration metadata
> 
> It is also selectable at recipe scope, since not all packages are
> buildable with either clang or gcc, a recipe can explicitly demand
> a given toolchain e.g. glibc can not be built with clang therefore
> glibc recipe sets.
> 
> TOOLCHAIN = "gcc"
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/classes-global/base.bbclass                   |  4 ++++
>  meta/classes-recipe/cross-canadian.bbclass         |  1 +
>  meta/classes-recipe/cross.bbclass                  |  1 +
>  meta/classes-recipe/crosssdk.bbclass               |  1 +
>  meta/classes-recipe/native.bbclass                 |  1 +
>  meta/classes-recipe/nativesdk.bbclass              |  1 +
>  meta/classes/toolchain/clang-native.bbclass        | 28 ++++++++++++++++++++++
>  .../clang.inc => classes/toolchain/clang.bbclass}  |  8 +++----
>  .../toolchain/gcc-native.bbclass}                  |  1 -
>  .../gcc.inc => classes/toolchain/gcc.bbclass}      |  1 -
>  meta/conf/bitbake.conf                             |  5 ++--
>  11 files changed, 43 insertions(+), 9 deletions(-)
> 
> diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
> index 8215969c7bb37c1a1b91e260cd31714fee2db87c..1e7d6fe9b6ac34c17820d9f6378a5aa50f00dff4 100644
> --- a/meta/classes-global/base.bbclass
> +++ b/meta/classes-global/base.bbclass
> @@ -19,6 +19,10 @@ PACKAGECONFIG_CONFARGS ??= ""
>  
>  inherit metadata_scm
>  
> +inherit toolchain/gcc-native
> +inherit toolchain/gcc
> +inherit_defer ${@oe.utils.ifelse(d.getVar('TOOLCHAIN') == 'clang', 'toolchain/clang', '')}

The fact we can't conditionally inherit gcc is bothering me quite a
bit. I did experiment a bit locally and I can certainly see the
challenge. The trouble is that even with the approach in this patch, I
think we're going to run into trouble as soon as we want to use clang
for native or sdk recipes.

The big problem is the ordering of the two deferred inherits (e.g.
native and toolchain/gcc) and how that interacts with class overrides.
You couldn't do something like:

TOOLCHAIN = "clang"
TOOLCHAIN:class-native = "gcc"

for example, since the class-native override isn't set until after
TOOLCHAIN is expanded in the deferred inherit.

I'll continue to give this some thought but I wanted to at least give a
headsup warning that this isn't going to scale as we might need it to.

Cheers,

Richard




  reply	other threads:[~2025-05-29 14:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  3:52 [PATCH v3 00/13] clang: Add clang C/C++ toolchain Khem Raj
2025-05-23  3:52 ` [PATCH v3 01/13] toolchain: Provide abstraction for choosing per-recipe toolchain Khem Raj
2025-05-29 14:10   ` Richard Purdie [this message]
2025-05-29 23:44   ` [OE-core] " Peter Kjellerstedt
2025-05-23  3:52 ` [PATCH v3 02/13] clang.bbclass: Specify ldso when using usermerge Khem Raj
2025-05-23  3:52 ` [PATCH v3 03/13] vte: Disable gi data generation when using clang on arm Khem Raj
2025-05-23  3:52 ` [PATCH v3 04/13] clang: Add compiler-rt to default deps when using clang compiler Khem Raj
2025-05-23  3:52 ` [PATCH v3 05/13] tcf-agent: Fix ranlib call when using llvm-ranlib Khem Raj
2025-05-29  9:20   ` [OE-core] " Richard Purdie
2025-05-29 17:59     ` Khem Raj
2025-05-29 20:15       ` Richard Purdie
2025-05-29 20:47         ` Khem Raj
2025-05-23  3:52 ` [PATCH v3 06/13] libjpeg-turbo: Fix build on mips/clang Khem Raj
2025-05-29  9:22   ` [OE-core] " Richard Purdie
2025-05-29 16:28     ` Khem Raj
2025-05-29 20:26       ` Richard Purdie
2025-05-29 20:48         ` Khem Raj
2025-05-23  3:52 ` [PATCH v3 07/13] pixman: Fix build with mips/clang Khem Raj
2025-05-29  9:23   ` [OE-core] " Richard Purdie
2025-05-29 20:05     ` Khem Raj
2025-05-29  9:24   ` Ross Burton
2025-05-29 20:43     ` Khem Raj
2025-05-23  3:52 ` [PATCH v3 08/13] vulkan-samples: Disable overriding-option as error Khem Raj
2025-05-23  3:52 ` [PATCH v3 09/13] bluez: Disable invalid-pp-token warning with clang Khem Raj
2025-05-23  3:52 ` [PATCH v3 10/13] systemtap: Pin to build with GCC Khem Raj
2025-05-23  3:52 ` [PATCH v3 11/13] seatd: Disable sign-compare warning as error on clang Khem Raj
2025-05-23  3:52 ` [PATCH v3 12/13] systemd-boot: Pin to use gcc toolchain on arm Khem Raj
2025-05-23  3:52 ` [PATCH v3 13/13] meta: Add TCOVERRIDE for toolchain selection at recipe scope Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49561b17ed66b3ac9872da5d5ea578317da40877.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=raj.khem@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox