Skip to content

Commit a662f89

Browse files
committed
compiler-rt: Exclude sync_fetch_and_* for any pre-ARMv6 targets
Sometimes builds may happen where ABI is not indidated by host_triple e.g. on Yocto the compiler used is called arm-poky-linux-gnueabi-clang for all arm32 cross compilers, it passed the ABI flags on cmdline in addition. e.g. -march=armv5te -mfloat-abi=soft or -march=armv7-a -mfloat-abi=hard compiler-rt's makery tries to add arm to COMPILER_RT_SUPPORTED_ARCH deducing it from triple name. which ends up choosing `arm` as one of compiler-rt arch to build for. This arch is however using armv7+ defaults and then tried to build sync builtins using arm-poky-linux-gnueabi-clang -march=armv5te -mfloat-abi=soft ... Which does not compile correctly, in such cases it should simply remove the sync builtins from list of things to build similar to what is done when we use armv4t or armv5t set(armv4t_SOURCES ${arm_min_SOURCES}) set(armv5te_SOURCES ${arm_min_SOURCES}) This lets compiler-rt build for arm architectures without depending upong compiler triple, but instead of poking the compiler for what it is building for Upstream-Status: Submitted [llvm#139411] Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 parent 8c83948 commit a662f89

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,18 @@ else ()
864864
list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
865865
set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
866866
message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
867+
# For ARM archs, exclude any sync builtins if dmb or mcr p15, #0, r0, c7, c10, #5
868+
# is not supported
869+
if (${arch} MATCHES "^(arm|armhf)$")
870+
try_compile_only(COMPILER_RT_HAS_${arch}_SYNC
871+
SOURCE "#if __ARM_ARCH < 6
872+
#error DMB is only supported on ARMv6+ !
873+
#endif
874+
int main(void) { return 0; }")
875+
if(NOT COMPILER_RT_HAS_${arch}_SYNC)
876+
list(REMOVE_ITEM ${arch}_SOURCES ${arm_sync_SOURCES})
877+
endif()
878+
endif()
867879
# For ARM archs, exclude any VFP builtins if VFP is not supported
868880
if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
869881
string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")

0 commit comments

Comments
 (0)