Skip to content

Commit

Permalink
cmake: Add check_arm32_assembly function
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed May 11, 2023
1 parent e5cf4bf commit 64f1449
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions cmake/CheckArm32Assembly.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function(check_arm32_assembly)
# This avoids running a linker.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

try_compile(HAVE_ARM32_ASM
${CMAKE_BINARY_DIR}/check_arm32_assembly
SOURCES ${CMAKE_SOURCE_DIR}/cmake/source_arm32.s
)
endfunction()
9 changes: 9 additions & 0 deletions cmake/source_arm32.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.syntax unified
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.text
.global test_function
.type test_function, %function
test_function:
ldr r0, =0x002A
bx lr

0 comments on commit 64f1449

Please sign in to comment.