compiler-rt,libcxx: Use clang for native-libcxx and gcc for compiler-rt-native
PATCH v6 1/2 compiler-rt,libcxx: Use clang for native-libcxx and gcc for compiler-rt-native
compiler-rt configure calls for c++ compiler which can cause C++ runtime to not be detected on some Yocto autobuilder workers running ubuntu 24.04 therefore let it use gcc for native version
Set TOOLCHAIN_NATIVE for using clang for libcxx
---
v6: Use gcc for native compiler-rt
.../recipes-devtools/clang/compiler-rt-sanitizers_git.bb | 1 + meta/recipes-devtools/clang/compiler-rt_git.bb | 9 ++++----- meta/recipes-devtools/clang/libcxx_git.bb | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-)
meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb +1 -0
@@ -37,6 +37,7 @@ CFLAGS += "${COMPILER_RT}" CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}" TOOLCHAIN = "clang" +TOOLCHAIN_NATIVE = "clang" DEPENDS += "ninja-native virtual/crypt compiler-rt" DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native"
meta/recipes-devtools/clang/compiler-rt_git.bb +4 -5
@@ -29,14 +29,15 @@ DEPENDS += "ninja-native libgcc" DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc gcc-runtime" DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-native clang-crosssdk-${SDK_SYS} nativesdk-gcc-runtime" DEPENDS:append:class-native = " clang-native" +DEPENDS:remove:class-native = "libcxx-native compiler-rt-native" # Trick clang.bbclass into not creating circular dependencies UNWINDLIB:class-nativesdk = "--unwindlib=libgcc" COMPILER_RT:class-nativesdk = "-rtlib=libgcc" LIBCPLUSPLUS:class-nativesdk = "-stdlib=libstdc++" -UNWINDLIB:class-native = "--unwindlib=libgcc" -COMPILER_RT:class-native = "-rtlib=libgcc" -LIBCPLUSPLUS:class-native = "-stdlib=libstdc++" +UNWINDLIB:class-native = "" +COMPILER_RT:class-native = "" +LIBCPLUSPLUS:class-native = "" UNWINDLIB:class-target = "--unwindlib=libgcc" COMPILER_RT:class-target = "-rtlib=libgcc" LIBCPLUSPLUS:class-target = "-stdlib=libstdc++"
@@ -52,8 +53,6 @@ HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" -BUILD_CC = "${CCACHE}clang ${BUILD_CC_ARCH}" -BUILD_CXX = "${CCACHE}clang++ ${BUILD_CC_ARCH}" LDFLAGS += "${COMPILER_RT} ${UNWINDLIB}" CXXFLAGS += "${LIBCPLUSPLUS}"
meta/recipes-devtools/clang/libcxx_git.bb +2 -0
@@ -25,6 +25,7 @@ DEPENDS += "ninja-native" DEPENDS:append:class-target = " virtual/cross-c++ clang-cross-${TARGET_ARCH} virtual/${MLPREFIX}libc virtual/${MLPREFIX}compilerlibs" DEPENDS:append:class-nativesdk = " virtual/cross-c++ clang-crosssdk-${SDK_SYS} nativesdk-compiler-rt" DEPENDS:append:class-native = " clang-native compiler-rt-native" +DEPENDS:remove:class-native = "libcxx-native" COMPILER_RT ?= "${@bb.utils.contains("PACKAGECONFIG", "compiler-rt", "-rtlib=compiler-rt", "-rtlib=libgcc", d)}" UNWINDLIB ?= "${@bb.utils.contains("PACKAGECONFIG", "unwind", "-unwindlib=none", "-unwindlib=libgcc", d)}"
@@ -55,6 +56,7 @@ LDFLAGS += "${COMPILER_RT} ${UNWINDLIB} ${LIBCPLUSPLUS}" CXXFLAGS += "${LIBCPLUSPLUS}" TOOLCHAIN = "clang" +TOOLCHAIN_NATIVE = "clang" OECMAKE_SOURCEPATH = "${S}/llvm" EXTRA_OECMAKE += "\
PATCH v6 2/2 base.bbclass: Deferred inherit native toolchain class
use TOOLCHAIN_NATIVE variable for selecting native compiler
Default it to PREFERRED_TOOLCHAIN_NATIVE, a recipe which wants to enforce a toolchain can do so with
for cross toolchains ( e.g. target, nativesdk )
TOOLCHAIN = "gcc"
For native
TOOLCHAIN_NATIVE = "gcc"
This helps build native recipe with clang as native compiler.
---
v6: Rebased
meta/classes-global/base.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-global/base.bbclass +2 -1
@@ -30,8 +30,9 @@ PREFERRED_TOOLCHAIN:class-crosssdk = "${PREFERRED_TOOLCHAIN_SDK}" PREFERRED_TOOLCHAIN:class-nativesdk = "${PREFERRED_TOOLCHAIN_SDK}" TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}" +TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}" -inherit toolchain/gcc-native +inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native inherit_defer toolchain/${TOOLCHAIN} def lsb_distro_identifier(d):