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 12, 2023
1 parent e5cf4bf commit ed4ba23
Show file tree
Hide file tree
Showing 3 changed files with 22 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
6 changes: 6 additions & 0 deletions cmake/CheckArm32Assembly.cmake
Original file line number Diff line number Diff line change
@@ -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()
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 main
main:
ldr r0, =0x002A
mov r7, #1
swi 0

0 comments on commit ed4ba23

Please sign in to comment.