Message ID | 20250701190633.2324784-2-raj.khem@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/2] clang-native: Add class to use clang as native compiler | expand |
On Tue, 2025-07-01 at 12:06 -0700, Khem Raj via lists.openembedded.org wrote: > This helps build native recipe with clang as native compiler. > when PREFERRED_TOOLCHAIN_NATIVE = "clang", otherwise it will > inherit gcc-native, this is a bit redundant when gcc native > is used, ideally we should defer_inherit it always but there > is some code in classes assuming gcc as native compiler e.g. > > oe.utils.host_gcc_version function expects BUILD_CC early during > parsing. > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > --- > meta/classes-global/base.bbclass | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/meta/classes-global/base.bbclass b/meta/classes- > global/base.bbclass > index ac145d9fd64..1fa09b6a16b 100644 > --- a/meta/classes-global/base.bbclass > +++ b/meta/classes-global/base.bbclass > @@ -32,6 +32,7 @@ PREFERRED_TOOLCHAIN:class-nativesdk = > "${PREFERRED_TOOLCHAIN_SDK}" > TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}" > > inherit toolchain/gcc-native > +inherit_defer toolchain/${PREFERRED_TOOLCHAIN_NATIVE}-native > inherit_defer toolchain/${TOOLCHAIN} > > def lsb_distro_identifier(d): The trouble with doing it this way is that a recipe which says TOOLCHAIN = "gcc" will end up getting compiled by clang. We could avoid this by using: TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}" inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native and then having recipes set: TOOLCHAIN = "gcc" TOOLCHAIN_NATIVE = "gcc" I really want to avoid inheriting both gcc-native and clang-native. If we have to remove the host_gcc_version function, that is probably ok. I think it is mostly used for the uninative gcc 4.8 and 4.9 issue but I doubt we have any distro with those older gcc versions on now? Cheers, Richard
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index ac145d9fd64..1fa09b6a16b 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass @@ -32,6 +32,7 @@ PREFERRED_TOOLCHAIN:class-nativesdk = "${PREFERRED_TOOLCHAIN_SDK}" TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}" inherit toolchain/gcc-native +inherit_defer toolchain/${PREFERRED_TOOLCHAIN_NATIVE}-native inherit_defer toolchain/${TOOLCHAIN} def lsb_distro_identifier(d):
This helps build native recipe with clang as native compiler. when PREFERRED_TOOLCHAIN_NATIVE = "clang", otherwise it will inherit gcc-native, this is a bit redundant when gcc native is used, ideally we should defer_inherit it always but there is some code in classes assuming gcc as native compiler e.g. oe.utils.host_gcc_version function expects BUILD_CC early during parsing. Signed-off-by: Khem Raj <raj.khem@gmail.com> --- meta/classes-global/base.bbclass | 1 + 1 file changed, 1 insertion(+)