From ed4ba238e2cb2f24301c1add238cf7ff062286c3 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 12 May 2023 10:38:50 +0100 Subject: [PATCH] cmake: Add `check_arm32_assembly` function --- CMakeLists.txt | 8 +++++++- cmake/CheckArm32Assembly.cmake | 6 ++++++ cmake/source_arm32.s | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cmake/CheckArm32Assembly.cmake create mode 100644 cmake/source_arm32.s diff --git a/CMakeLists.txt b/CMakeLists.txt index a1d9eb36e3f77..c764e6423e6c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,13 @@ set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm32") check_string_option_value(SECP256K1_ASM) if(SECP256K1_ASM STREQUAL "arm32") enable_language(ASM) - add_compile_definitions(USE_EXTERNAL_ASM=1) + include(CheckArm32Assembly) + check_arm32_assembly() + if(HAVE_ARM32_ASM) + add_compile_definitions(USE_EXTERNAL_ASM=1) + else() + message(FATAL_ERROR "ARM32 assembly optimization requested but not available.") + endif() elseif(SECP256K1_ASM) include(Check64bitAssembly) check_64bit_assembly() diff --git a/cmake/CheckArm32Assembly.cmake b/cmake/CheckArm32Assembly.cmake new file mode 100644 index 0000000000000..15c44b24b0141 --- /dev/null +++ b/cmake/CheckArm32Assembly.cmake @@ -0,0 +1,6 @@ +function(check_arm32_assembly) + try_compile(HAVE_ARM32_ASM + ${CMAKE_BINARY_DIR}/check_arm32_assembly + SOURCES ${CMAKE_SOURCE_DIR}/cmake/source_arm32.s + ) +endfunction() diff --git a/cmake/source_arm32.s b/cmake/source_arm32.s new file mode 100644 index 0000000000000..d3d9347057a03 --- /dev/null +++ b/cmake/source_arm32.s @@ -0,0 +1,9 @@ +.syntax unified +.eabi_attribute 24, 1 +.eabi_attribute 25, 1 +.text +.global main +main: + ldr r0, =0x002A + mov r7, #1 + swi 0