diff mbox series

[05/19] clang-native.bbclass: Abstraction to enable clang as native compiler

Message ID 20241105184540.3450302-5-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
Some packages demand clang all the way, including for native pieces e.g.
chromium, this helps to get that going

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes-recipe/clang-native.bbclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 meta/classes-recipe/clang-native.bbclass
diff mbox series

Patch

diff --git a/meta/classes-recipe/clang-native.bbclass b/meta/classes-recipe/clang-native.bbclass
new file mode 100644
index 00000000000..a136deeee38
--- /dev/null
+++ b/meta/classes-recipe/clang-native.bbclass
@@ -0,0 +1,24 @@ 
+# inherit this class if you would like to use clang to compile the native
+# version of your recipes instead of system compiler ( which is normally gcc )
+# on build machines
+# to use it add
+#
+# inherit clang-native
+#
+# to the concerned recipe via a bbappend or directly to recipe file
+#
+DEPENDS:append:runtime-llvm = " compiler-rt-native libcxx-native"
+# Use libcxx headers for native parts
+CXXFLAGS:append:runtime-llvm = " -stdlib=libc++"
+BUILD_CXXFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
+# Use libgcc for native parts
+LDFLAGS:append:runtime-llvm = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
+BUILD_LDFLAGS:append:runtime-llvm = " -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
+DEPENDS:append = " clang-native"
+BUILD_CC  = "${CCACHE}clang -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CXX = "${CCACHE}clang++ -isysroot=${STAGING_DIR_NATIVE}"
+BUILD_CPP = "${CCACHE}clang -isysroot=${STAGING_DIR_NATIVE} -E"
+BUILD_CCLD = "${CCACHE}clang"
+BUILD_RANLIB = "llvm-ranlib"
+BUILD_AR = "llvm-ar"
+BUILD_NM = "llvm-nm"