diff mbox series

libcxx,compiler-rt-sanitizers: Add cflags to build with clang compiler

Message ID 20250502190237.4083287-1-raj.khem@gmail.com
State New
Headers show
Series libcxx,compiler-rt-sanitizers: Add cflags to build with clang compiler | expand

Commit Message

Khem Raj May 2, 2025, 7:02 p.m. UTC
We are using clang-native to build the native versions of these recipes
but we are missing the needed compiler flags to let it c/c++ runtime
appropriately. This also ensures that meta-clang does not have to worry
about the compiler settings for nativesdk/native pieces separately.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb | 6 ++++++
 meta/recipes-devtools/clang/libcxx_git.bb                 | 5 +++++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
index b3c4bfcffdc..b987a5cc768 100644
--- a/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
+++ b/meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb
@@ -18,9 +18,15 @@  inherit cmake pkgconfig python3native
 LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a"
 
 TUNE_CCARGS:remove = "-no-integrated-as"
+COMPILER_RT ??= "-rtlib=libgcc -unwindlib=libgcc"
+LIBCPLUSPLUS ??= "-stdlib=libstdc++"
 
 CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+BUILD_CC = "${CCACHE}${HOST_PREFIX}clang ${BUILD_CC_ARCH}"
+BUILD_CXX = "${CCACHE}${HOST_PREFIX}clang++ ${BUILD_CC_ARCH}$"
+CFLAGS += "${COMPILER_RT}"
+CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}"
 
 DEPENDS += "ninja-native virtual/crypt compiler-rt"
 DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native"
diff --git a/meta/recipes-devtools/clang/libcxx_git.bb b/meta/recipes-devtools/clang/libcxx_git.bb
index d2655d9da94..f5987199ecf 100644
--- a/meta/recipes-devtools/clang/libcxx_git.bb
+++ b/meta/recipes-devtools/clang/libcxx_git.bb
@@ -49,6 +49,11 @@  OECMAKE_TARGET_INSTALL = "${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "instal
 
 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}"
+CFLAGS += "${COMPILER_RT}"
+CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}"
+
 OECMAKE_SOURCEPATH = "${S}/llvm"
 EXTRA_OECMAKE += "\
                   -DCMAKE_BUILD_TYPE=RelWithDebInfo \