diff mbox series

[17/19] toolchain-scripts.bbclass: Add env variables in SDK to use clang/clang++

Message ID 20241105184540.3450302-17-raj.khem@gmail.com
State New
Headers show
Series [01/19] clang.inc: Global settings for clang toolchain | expand

Commit Message

Khem Raj Nov. 5, 2024, 6:45 p.m. UTC
Make CLANGCC/CLANGCXX/CLANG_TIDY available in SDK

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes-recipe/toolchain-scripts.bbclass | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/toolchain-scripts.bbclass b/meta/classes-recipe/toolchain-scripts.bbclass
index b59a295abcc..f17905d5284 100644
--- a/meta/classes-recipe/toolchain-scripts.bbclass
+++ b/meta/classes-recipe/toolchain-scripts.bbclass
@@ -11,6 +11,17 @@  inherit toolchain-scripts-base siteinfo kernel-arch
 REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}"
 TARGET_CC_ARCH:append:libc-musl = " -mmusl"
 
+# Adjustments for clang in SDK
+export TARGET_CLANGCC_ARCH = "${TARGET_CC_ARCH}"
+TARGET_CLANGCC_ARCH:remove = "-mthumb-interwork"
+TARGET_CLANGCC_ARCH:remove = "-mmusl"
+TARGET_CLANGCC_ARCH:remove = "-muclibc"
+TARGET_CLANGCC_ARCH:remove = "-meb"
+TARGET_CLANGCC_ARCH:remove = "-mel"
+TARGET_CLANGCC_ARCH:append = "${@bb.utils.contains("TUNE_FEATURES", "bigendian", " -mbig-endian", " -mlittle-endian", d)}"
+TARGET_CLANGCC_ARCH:remove:powerpc = "-mhard-float"
+TARGET_CLANGCC_ARCH:remove:powerpc = "-mno-spe"
+
 # default debug prefix map isn't valid in the SDK
 DEBUG_PREFIX_MAP = ""
 
@@ -147,7 +158,10 @@  toolchain_shared_env_script () {
 	echo 'export ARCH=${ARCH}' >> $script
 	echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script
 	echo 'export OECORE_TUNE_CCARGS="${TUNE_CCARGS}"' >> $script
-
+	echo 'export CLANGCC="${TARGET_PREFIX}clang --target=${TARGET_SYS} ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+    echo 'export CLANGCXX="${TARGET_PREFIX}clang++ --target=${TARGET_SYS} ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+    echo 'export CLANGCPP="${TARGET_PREFIX}clang -E --target=${TARGET_SYS} ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+    echo 'export CLANG_TIDY_EXE="${TARGET_PREFIX}clang-tidy"' >> $script
     cat >> $script <<EOF
 
 # Append environment subscripts