Skip to contentSkip to conversation

compiler-rt: Consolidate and fix cmake arguments

PATCH New Khem Raj 1 participant 4 messages May 8, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/4 compiler-rt: Consolidate and fix cmake arguments

Specify CMAKE_C_COMPILER_TARGET and COMPILER_RT_DEFAULT_TARGET_ARCH in common for native/target/nativesdk

set COMPILER_RT_DEFAULT_TARGET_ARCH to use HOST_ARCH across all recipe variants

It is not needed to set COMPILER_RT_DEFAULT_TARGET_ARCH for powerpc anymore as it is already fixed by setting COMPILER_RT_DEFAULT_TARGET_ARCH to HOST_ARCH

---
 meta/recipes-devtools/clang/compiler-rt_git.bb | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
meta/recipes-devtools/clang/compiler-rt_git.bb +2 -8
index a0f9c769a06..22dec883298 100644
@@ -63,6 +63,7 @@ OECMAKE_TARGET_COMPILE = "compiler-rt"
 OECMAKE_TARGET_INSTALL = "install-compiler-rt install-compiler-rt-headers"
 OECMAKE_SOURCEPATH = "${S}/llvm"
 EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+                  -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
                   -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
                   -DCOMPILER_RT_STANDALONE_BUILD=ON \
                   -DCOMPILER_RT_INCLUDE_TESTS=OFF \
@@ -70,6 +71,7 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
                   -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
                   -DCOMPILER_RT_BUILD_MEMPROF=OFF \
                   -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
+                  -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${HOST_ARCH} \
                   -DLLVM_ENABLE_RUNTIMES='compiler-rt' \
                   -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
                   -DLLVM_APPEND_VC_REV=OFF \
@@ -77,16 +79,10 @@ EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
                   -S ${S}/runtimes \
 "
 
-EXTRA_OECMAKE:append:class-native = "\
-                  -DCOMPILER_RT_DEFAULT_TARGET_ARCH=${HOST_ARCH} \
-                  -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
-"
-
 EXTRA_OECMAKE:append:class-target = "\
                -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
                -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
                -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
-               -DCMAKE_C_COMPILER_TARGET=${HOST_ARCH}${HOST_VENDOR}-${HOST_OS}${HF} \
                -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
 "
 
@@ -96,9 +92,7 @@ EXTRA_OECMAKE:append:class-nativesdk = "\
                -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
                -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
                -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
-               -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
 "
-EXTRA_OECMAKE:append:powerpc = " -DCOMPILER_RT_DEFAULT_TARGET_ARCH=powerpc "
 
 do_install:append () {
     mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
author
#1 lore raw

PATCH 2/4 libcxx: Fix cflags and ldflags for using compiler runtime

-stdlib is needed in both cxxflags and ldflags since c++ compiler will use these to chose the right c++ headers and libraries during link

-rtlib and -unwindlib are only needed during linking

Use LLVM_HOST_TRIPLE during cross compiling compiler-rt for target this is used by cmake to compute target and compiler triples

Fix LLVM_RUNTIME_TARGETS to use HOST_ARCH, it does not need cross compile triple which HOST_SYS is passing here

---
 meta/recipes-devtools/clang/libcxx_git.bb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-devtools/clang/libcxx_git.bb +4 -4
index f5987199ecf..c99617c228a 100644
@@ -51,8 +51,8 @@ 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}"
+LDFLAGS += "${COMPILER_RT} ${UNWINDLIB} ${LIBCPLUSPLUS}"
+CXXFLAGS += "${LIBCPLUSPLUS}"
 
 OECMAKE_SOURCEPATH = "${S}/llvm"
 EXTRA_OECMAKE += "\
@@ -71,7 +71,7 @@ EXTRA_OECMAKE += "\
                   -DLIBCXX_CXX_ABI_LIBRARY_PATH=${B}/lib${LLVM_LIBDIR_SUFFIX} \
                   -S ${S}/runtimes \
                   -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
-                  -DLLVM_RUNTIME_TARGETS=${HOST_SYS} \
+                  -DLLVM_RUNTIME_TARGETS=${HOST_ARCH} \
                   -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
                   -DLLVM_APPEND_VC_REV=OFF \
                   -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
@@ -81,7 +81,7 @@ EXTRA_OECMAKE:append:class-target = " \
                   -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${AR} \
                   -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${NM} \
                   -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${RANLIB} \
-                  -DLLVM_DEFAULT_TARGET_TRIPLE=${HOST_SYS} \
+                  -DLLVM_HOST_TRIPLE=${TARGET_SYS} \
                   -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
 "
 
author
#2 lore raw

PATCH 3/4 compiler-rt: Rename the rt libraries if compiled with arm hardfloat ABI

In reply to Khem Raj

OE does not rely on tuple to deduce hardfloat ABI, but clang/llvm does arm-yoe-linux-gnueabi is used for both soft and softfp and hardfp float ABIs in OE, LLVM expects arm-yoe-linux-gnueabihf for it to be treated as hardfloat ABI, and look for correct name for rt libraries.

We know when we compile them with Hard-float ABI so rename them in such case so clang can find it when using -rtlib=compiler-rt it needs to has 'armhf' suffix

---
 meta/recipes-devtools/clang/compiler-rt_git.bb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta/recipes-devtools/clang/compiler-rt_git.bb +6 -1
index 22dec883298..0a0ef6be807 100644
@@ -50,7 +50,6 @@ PACKAGECONFIG[ctx-profile] = "-DCOMPILER_RT_BUILD_CTX_PROFILE=ON,-DCOMPILER_RT_B
 
 HF = ""
 HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
-HF[vardepvalue] = "${HF}"
 
 CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
@@ -97,6 +96,12 @@ EXTRA_OECMAKE:append:class-nativesdk = "\
 do_install:append () {
     mkdir -p ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
     mv ${D}${nonarch_libdir}/linux ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib
+    if [ "${HF}" = "hf" ]; then
+        mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-arm.a \
+              ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/libclang_rt.builtins-armhf.a
+        mv -f ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-arm.a \
+              ${D}${nonarch_libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/liborc_rt-armhf.a
+    fi
 }
 
 FILES_SOLIBSDEV = ""
author
#3 lore raw

PATCH 4/4 clang: Upgrade to 20.1.4

In reply to Khem Raj

Brings following fixes

* ec28b8f9cc7f [libcxx] [test] Extend mingw workarounds for armv7/aarch64 too (#136419)
* 8c2dc1b5aa7f [clang-repl] Implement LoadDynamicLibrary for clang-repl wasm use cases (#133037)
* 02afcbf63fee [SystemZ] Fix compile time regression in adjustInliningThreshold(). (#137527)
* c877757659e8 [clang-repl] : Fix clang-repl crash with --cuda flag (#136404)
* f4779c389868 [InstCombine] Preserve signbit semantics of NaN with fold to fabs (#136648)
* 57a31e183dc8 [InstCombine] Do not fold logical is_finite test (#136851)
* 1cf8c7797d2b [GlobalOpt] Do not promote malloc if there are atomic loads/stores (#137158)
* 24805c2e0817 [lldb] Use correct path for lldb-server executable (#131519)
* 182e8b7f8a71 [clang-format] Correctly annotate kw_operator in using decls (#136545)
* 425d1aad294f [RISCV] Handle scalarized reductions in getArithmeticReductionCost
* 2d7ad98ec0a8 [clang][analyzer] Fix error path of builtin overflow (#136345)
* e7ae5532bc27 [clang-format] Fix mismatched break in BlockIndent (#124998)
* 8f288eb619db [lldb][test] Adjust TestTargetReadInstructionsFlavor skipIfs
* d76ec6a75d39 [lldb] Fix SBTarget::ReadInstruction with flavor (#134626)
* 62072e7f877e [clang][AST] Handle implicit first argument in CallExpr::getBeginLoc()
* 581772ed077e [LoongArch] Don't crash on instruction prefetch intrinsics (#135760)
* 89adc2d4f93b [HEXAGON] Fix corner cases for hwloops pass (#135439)
* 78f6719ca9b5 [GlobalMerge][PPC] Don't merge globals in llvm.metadata section (#131801)
* ab0074fe306f Bump version to 20.1.4

---
 meta/conf/distro/include/maintainers.inc     | 2 +-
 meta/recipes-devtools/clang/common-clang.inc | 2 +-
 meta/recipes-devtools/clang/common.inc       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
meta/conf/distro/include/maintainers.inc +1 -1
index 7d4a8e24174..69f6a2d2846 100644
@@ -478,7 +478,7 @@ RECIPE_MAINTAINER:pn-linux-yocto = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-linux-yocto-tiny = "Bruce Ashfield <[email protected]>"
-RECIPE_MAINTAINER:pn-llvm-project-source-20.1.3 = "Khem Raj <[email protected]>"
+RECIPE_MAINTAINER:pn-llvm-project-source-20.1.4 = "Khem Raj <[email protected]>"
 RECIPE_MAINTAINER:pn-logrotate = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-log4cplus = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-lrzsz = "Anuj Mittal <[email protected]>"
meta/recipes-devtools/clang/common-clang.inc +1 -1
index 41944265ba5..1099274d900 100644
@@ -5,7 +5,7 @@ LLVM_HTTP ?= "https://github.com/llvm"
 
 MAJOR_VER = "20"
 MINOR_VER = "1"
-PATCH_VER = "3"
+PATCH_VER = "4"
 # could be 'rcX' or 'git' or empty ( for release )
 VER_SUFFIX = ""
 
meta/recipes-devtools/clang/common.inc +1 -1
index a7b508039f7..f3b0ba7cbdf 100644
@@ -15,7 +15,7 @@ LICENSE = "Apache-2.0-with-LLVM-exception"
 RELEASE ?= "${PV}"
 BASEURI ?= "${LLVM_HTTP}/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz"
 SOURCEDIR ?= "llvm-project-${PV}.src"
-SRC_URI[sha256sum] = "b6183c41281ee3f23da7fda790c6d4f5877aed103d1e759763b1008bdd0e2c50"
+SRC_URI[sha256sum] = "a95365b02536ed4aef29b325c205dd89c268cba41503ab2fc05f81418613ab63"
 
 SRC_URI = "\
     ${BASEURI} \