diff mbox series

compiler-rt: Use specific arm architecture instead of 'arm'

Message ID 20260925142820.853791-1-jst@mbs-solutions.de
State New
Headers show
Series compiler-rt: Use specific arm architecture instead of 'arm' | expand

Commit Message

Jan Strater-Büddefeld Sept. 25, 2026, 2:28 p.m. UTC
Fixes [YOCTO #16424]

The build system of compiler-rt can auto-detect some architectures like
'armv6m' via the `-march` compiler flag.
For other targets, the arch type to build for must be set via the target
triple `CMAKE_C_COMPILER_TARGET`.
Before this commit, the arch type was simply 'arm'.

This commit also removes setting the variable
`COMPILER_RT_DEFAULT_TARGET_ARCH` because it is overridden anyway.

AI-Generated: Uses GitHub Copilot

Signed-off-by: Jan Strater-Büddefeld <jst@mbs-solutions.de>
Cc: Ross Burton <Ross.Burton@arm.com>
---
 .../recipes-devtools/clang/compiler-rt_git.bb | 22 +++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/clang/compiler-rt_git.bb b/meta/recipes-devtools/clang/compiler-rt_git.bb
index a265c2aa93..d6c06302c2 100644
--- a/meta/recipes-devtools/clang/compiler-rt_git.bb
+++ b/meta/recipes-devtools/clang/compiler-rt_git.bb
@@ -49,13 +49,18 @@  TOOLCHAIN = "clang"
 TOOLCHAIN_NATIVE = "clang"
 
 def get_compiler_rt_arch(bb, d):
-    if bb.utils.contains('TUNE_FEATURES', 'armv5 thumb dsp', True, False, d):
-        return 'armv5te'
-    elif bb.utils.contains('TUNE_FEATURES', 'armv4 thumb', True, False, d):
-        return 'armv4t'
-    elif bb.utils.contains('TUNE_FEATURES', 'arm vfp callconvention-hard', True, False, d):
-        return 'armhf'
-    return d.getVar('HOST_ARCH')
+    import re
+    
+    tune_args = d.getVar('TUNE_CCARGS_MARCH') or ''
+
+    match = re.search(r'-march=(\S+)', tune_args)
+    arch = match.group(1) if match else d.getVar('HOST_ARCH')
+
+    return arch
+
+def get_compiler_rt_target(bb, d):
+    host_sys = d.getVar('HOST_SYS')
+    return get_compiler_rt_arch(bb, d) + '-' + host_sys.split('-', 1)[1]
 
 INSTALL_VER ?= "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}${VER_SUFFIX}"
 INSTALL_VER:class-native = "${@oe.utils.trim_version("${PV}", 1)}"
@@ -78,7 +83,6 @@  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=${@get_compiler_rt_arch(bb, d)} \
                   -DLLVM_ENABLE_RUNTIMES=${RUNTIMES} \
                   -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \
                   -DLLVM_APPEND_VC_REV=OFF \
@@ -86,7 +90,7 @@  EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=RelWithDebInfo \
                   -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
                   -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
                   -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-                  -DCMAKE_C_COMPILER_TARGET=${HOST_SYS} \
+                  -DCMAKE_C_COMPILER_TARGET=${@get_compiler_rt_target(bb, d)} \
                   -DCOMPILER_RT_INSTALL_PATH=${nonarch_libdir}/clang/${INSTALL_VER} \
                   ${@bb.utils.contains("TC_CXX_RUNTIME", "llvm", "${LLVMLIBGCCOPTS}", "", d)} \
 "