diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 5efc4ab0e85bc..011a9d5ea5d25 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -892,6 +892,18 @@ else () ${TARGET_${arch}_CFLAGS}) list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS) message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}") + # For ARM archs, exclude any sync builtins if dmb or mcr p15, #0, r0, c7, c10, #5 + # is not supported + if (${arch} MATCHES "^(arm|armhf)$") + try_compile_only(COMPILER_RT_HAS_${arch}_SYNC + SOURCE "#if __ARM_ARCH < 6 + #error DMB is only supported on ARMv6+ ! + #endif + int main(void) { return 0; }") + if(NOT COMPILER_RT_HAS_${arch}_SYNC) + list(REMOVE_ITEM ${arch}_SOURCES ${arm_sync_SOURCES}) + endif() + endif() # For ARM archs, exclude any VFP builtins if VFP is not supported if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$") check_compile_definition(__ARM_FP "${CMAKE_C_FLAGS}" COMPILER_RT_HAS_${arch}_VFP)