[compiler-rt] [cmake][compiler-rt][darwin] builtin libraries don't build for armv6m in Darwin (PR #195372)
Ian Anderson via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 15:45:58 PDT 2026
https://github.com/ian-twilightcoder created https://github.com/llvm/llvm-project/pull/195372
darwin_add_builtin_libraries tests for _Float16 and __bf16 for the host architecture rather than the one being built, add -arch to fix that so that armv6m correctly reports that it does not support __bf16. cfcmp/cdcmp get "error: unsupported relocation type" on their "Branch to target address" to c{f,d}cmple. Switch those to "Call a subroutine" instructions on Thumb-1 (e.g. armv6m).
Assisted-by: Claude Code
rdar://167828904
>From 665ae5995b2b4bca5a8e145b039fc8a716d1b5c0 Mon Sep 17 00:00:00 2001
From: Ian Anderson <iana at apple.com>
Date: Fri, 1 May 2026 15:42:04 -0700
Subject: [PATCH] [cmake][compiler-rt][darwin] builtin libraries don't build
for armv6m in Darwin
darwin_add_builtin_libraries tests for _Float16 and __bf16 for the host architecture rather than the one being built, add -arch to fix that so that armv6m correctly reports that it does not support __bf16.
cfcmp/cdcmp get "error: unsupported relocation type" on their "Branch to target address" to c{f,d}cmple. Switch those to "Call a subroutine" instructions on Thumb-1 (e.g. armv6m).
Assisted-by: Claude Code
rdar://167828904
---
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake | 3 +++
compiler-rt/lib/builtins/arm/aeabi_cdcmp.S | 6 ++++++
compiler-rt/lib/builtins/arm/aeabi_cfcmp.S | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 205f8ee7f1762..4864040e02865 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -450,11 +450,14 @@ macro(darwin_add_builtin_libraries)
OS ${os}
ARCH ${arch}
MIN_VERSION ${DARWIN_${os}_BUILTIN_MIN_VER})
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch ${arch}")
check_c_source_compiles("_Float16 foo(_Float16 x) { return x; }"
COMPILER_RT_HAS_${arch}_FLOAT16)
append_list_if(COMPILER_RT_HAS_${arch}_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS_${arch})
check_c_source_compiles("__bf16 foo(__bf16 x) { return x; }"
COMPILER_RT_HAS_${arch}_BFLOAT16)
+ cmake_pop_check_state()
# Build BF16 files only when "__bf16" is available.
if(COMPILER_RT_HAS_${arch}_BFLOAT16)
list(APPEND ${arch}_SOURCES ${BF16_SOURCES})
diff --git a/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S b/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S
index 0271afe7844f2..d7b48ea51b7d7 100644
--- a/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S
+++ b/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S
@@ -156,7 +156,13 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
mov r1, r3
mov r3, ip
+#if defined(USE_THUMB_1)
+ push {lr}
+ bl __aeabi_cdcmple
+ pop {pc}
+#else
b __aeabi_cdcmple
+#endif
END_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
NO_EXEC_STACK_DIRECTIVE
diff --git a/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S b/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S
index 5cb7d16042f42..73ac098a25371 100644
--- a/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S
+++ b/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S
@@ -151,7 +151,13 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
mov r0, r1
mov r1, ip
+#if defined(USE_THUMB_1)
+ push {lr}
+ bl __aeabi_cfcmple
+ pop {pc}
+#else
b __aeabi_cfcmple
+#endif
END_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
NO_EXEC_STACK_DIRECTIVE
More information about the llvm-commits
mailing list