Merge bitcoin-core/secp256k1#1304: build: Rename arm to arm32 and check if it's really supported
c6bb29b3037c6b5264f2d2916c5a2d38de25df19 build: Rename `64bit` to `x86_64` (Hennadii Stepanov) 03246457a8f7091e13af13a50d7ae33cf42e08b5 autotools: Add `SECP_ARM32_ASM_CHECK` macro (Hennadii Stepanov) ed4ba238e2cb2f24301c1add238cf7ff062286c3 cmake: Add `check_arm32_assembly` function (Hennadii Stepanov) e5cf4bf3ff9aac5b5897a8a9852cfbb84da0bfb1 build: Rename `arm` to `arm32` (Hennadii Stepanov) Pull request description: Closes https://github.com/bitcoin-core/secp256k1/issues/1034. Solves one item in https://github.com/bitcoin-core/secp256k1/issues/1235. ACKs for top commit: real-or-random: ACK c6bb29b3037c6b5264f2d2916c5a2d38de25df19 tested on x86_64 but not on ARM Tree-SHA512: c3615a18cfa30bb2cc53be18c09ccab08fc800b84444d8c6b333347b4db039a3981da61e7da5086dd9f4472838d7c031d554be9ddc7c435ba906852bba593982
This commit is contained in:
commit
b54a0672ef
@ -176,7 +176,7 @@ task:
|
|||||||
CTIMETESTS: no
|
CTIMETESTS: no
|
||||||
matrix:
|
matrix:
|
||||||
- env: {}
|
- env: {}
|
||||||
- env: {EXPERIMENTAL: yes, ASM: arm}
|
- env: {EXPERIMENTAL: yes, ASM: arm32}
|
||||||
<< : *MERGE_BASE
|
<< : *MERGE_BASE
|
||||||
test_script:
|
test_script:
|
||||||
- ./ci/cirrus.sh
|
- ./ci/cirrus.sh
|
||||||
|
@ -102,16 +102,22 @@ if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
|||||||
endif()
|
endif()
|
||||||
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
|
||||||
|
|
||||||
set(SECP256K1_ASM "AUTO" CACHE STRING "Assembly optimizations to use: \"AUTO\", \"OFF\", \"x86_64\" or \"arm\" (experimental). [default=AUTO]")
|
set(SECP256K1_ASM "AUTO" CACHE STRING "Assembly optimizations to use: \"AUTO\", \"OFF\", \"x86_64\" or \"arm32\" (experimental). [default=AUTO]")
|
||||||
set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm")
|
set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm32")
|
||||||
check_string_option_value(SECP256K1_ASM)
|
check_string_option_value(SECP256K1_ASM)
|
||||||
if(SECP256K1_ASM STREQUAL "arm")
|
if(SECP256K1_ASM STREQUAL "arm32")
|
||||||
enable_language(ASM)
|
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)
|
elseif(SECP256K1_ASM)
|
||||||
include(Check64bitAssembly)
|
include(CheckX86_64Assembly)
|
||||||
check_64bit_assembly()
|
check_x86_64_assembly()
|
||||||
if(HAS_64BIT_ASM)
|
if(HAVE_X86_64_ASM)
|
||||||
set(SECP256K1_ASM "x86_64")
|
set(SECP256K1_ASM "x86_64")
|
||||||
add_compile_definitions(USE_ASM_X86_64=1)
|
add_compile_definitions(USE_ASM_X86_64=1)
|
||||||
elseif(SECP256K1_ASM STREQUAL "AUTO")
|
elseif(SECP256K1_ASM STREQUAL "AUTO")
|
||||||
@ -123,8 +129,8 @@ endif()
|
|||||||
|
|
||||||
option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." OFF)
|
option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." OFF)
|
||||||
if(NOT SECP256K1_EXPERIMENTAL)
|
if(NOT SECP256K1_EXPERIMENTAL)
|
||||||
if(SECP256K1_ASM STREQUAL "arm")
|
if(SECP256K1_ASM STREQUAL "arm32")
|
||||||
message(FATAL_ERROR "ARM assembly optimization is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
|
message(FATAL_ERROR "ARM32 assembly optimization is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,12 +1,31 @@
|
|||||||
dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
|
dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
|
||||||
AC_DEFUN([SECP_64BIT_ASM_CHECK],[
|
AC_DEFUN([SECP_X86_64_ASM_CHECK],[
|
||||||
AC_MSG_CHECKING(for x86_64 assembly availability)
|
AC_MSG_CHECKING(for x86_64 assembly availability)
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||||
#include <stdint.h>]],[[
|
#include <stdint.h>]],[[
|
||||||
uint64_t a = 11, tmp;
|
uint64_t a = 11, tmp;
|
||||||
__asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
|
__asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
|
||||||
]])],[has_64bit_asm=yes],[has_64bit_asm=no])
|
]])], [has_x86_64_asm=yes], [has_x86_64_asm=no])
|
||||||
AC_MSG_RESULT([$has_64bit_asm])
|
AC_MSG_RESULT([$has_x86_64_asm])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([SECP_ARM32_ASM_CHECK], [
|
||||||
|
AC_MSG_CHECKING(for ARM32 assembly availability)
|
||||||
|
SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="-x assembler"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
.syntax unified
|
||||||
|
.eabi_attribute 24, 1
|
||||||
|
.eabi_attribute 25, 1
|
||||||
|
.text
|
||||||
|
.global main
|
||||||
|
main:
|
||||||
|
ldr r0, =0x002A
|
||||||
|
mov r7, #1
|
||||||
|
swi 0
|
||||||
|
]])], [has_arm32_asm=yes], [has_arm32_asm=no])
|
||||||
|
AC_MSG_RESULT([$has_arm32_asm])
|
||||||
|
CFLAGS="$SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS"
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([SECP_VALGRIND_CHECK],[
|
AC_DEFUN([SECP_VALGRIND_CHECK],[
|
||||||
|
6
cmake/CheckArm32Assembly.cmake
Normal file
6
cmake/CheckArm32Assembly.cmake
Normal file
@ -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()
|
@ -1,6 +1,6 @@
|
|||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
function(check_64bit_assembly)
|
function(check_x86_64_assembly)
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -9,6 +9,6 @@ function(check_64bit_assembly)
|
|||||||
uint64_t a = 11, tmp;
|
uint64_t a = 11, tmp;
|
||||||
__asm__ __volatile__(\"movq $0x100000000,%1; mulq %%rsi\" : \"+a\"(a) : \"S\"(tmp) : \"cc\", \"%rdx\");
|
__asm__ __volatile__(\"movq $0x100000000,%1; mulq %%rsi\" : \"+a\"(a) : \"S\"(tmp) : \"cc\", \"%rdx\");
|
||||||
}
|
}
|
||||||
" HAS_64BIT_ASM)
|
" HAVE_X86_64_ASM)
|
||||||
set(HAS_64BIT_ASM ${HAS_64BIT_ASM} PARENT_SCOPE)
|
set(HAVE_X86_64_ASM ${HAVE_X86_64_ASM} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
9
cmake/source_arm32.s
Normal file
9
cmake/source_arm32.s
Normal file
@ -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
|
26
configure.ac
26
configure.ac
@ -197,8 +197,8 @@ AC_ARG_ENABLE(external_default_callbacks,
|
|||||||
# * and auto (the default).
|
# * and auto (the default).
|
||||||
AC_ARG_WITH([test-override-wide-multiply], [] ,[set_widemul=$withval], [set_widemul=auto])
|
AC_ARG_WITH([test-override-wide-multiply], [] ,[set_widemul=$withval], [set_widemul=auto])
|
||||||
|
|
||||||
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm|no|auto],
|
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm32|no|auto],
|
||||||
[assembly optimizations to use (experimental: arm) [default=auto]])],[req_asm=$withval], [req_asm=auto])
|
[assembly optimizations to use (experimental: arm32) [default=auto]])],[req_asm=$withval], [req_asm=auto])
|
||||||
|
|
||||||
AC_ARG_WITH([ecmult-window], [AS_HELP_STRING([--with-ecmult-window=SIZE|auto],
|
AC_ARG_WITH([ecmult-window], [AS_HELP_STRING([--with-ecmult-window=SIZE|auto],
|
||||||
[window size for ecmult precomputation for verification, specified as integer in range [2..24].]
|
[window size for ecmult precomputation for verification, specified as integer in range [2..24].]
|
||||||
@ -263,8 +263,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$req_asm" = x"auto"; then
|
if test x"$req_asm" = x"auto"; then
|
||||||
SECP_64BIT_ASM_CHECK
|
SECP_X86_64_ASM_CHECK
|
||||||
if test x"$has_64bit_asm" = x"yes"; then
|
if test x"$has_x86_64_asm" = x"yes"; then
|
||||||
set_asm=x86_64
|
set_asm=x86_64
|
||||||
fi
|
fi
|
||||||
if test x"$set_asm" = x; then
|
if test x"$set_asm" = x; then
|
||||||
@ -274,12 +274,16 @@ else
|
|||||||
set_asm=$req_asm
|
set_asm=$req_asm
|
||||||
case $set_asm in
|
case $set_asm in
|
||||||
x86_64)
|
x86_64)
|
||||||
SECP_64BIT_ASM_CHECK
|
SECP_X86_64_ASM_CHECK
|
||||||
if test x"$has_64bit_asm" != x"yes"; then
|
if test x"$has_x86_64_asm" != x"yes"; then
|
||||||
AC_MSG_ERROR([x86_64 assembly optimization requested but not available])
|
AC_MSG_ERROR([x86_64 assembly optimization requested but not available])
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
arm)
|
arm32)
|
||||||
|
SECP_ARM32_ASM_CHECK
|
||||||
|
if test x"$has_arm32_asm" != x"yes"; then
|
||||||
|
AC_MSG_ERROR([ARM32 assembly optimization requested but not available])
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
no)
|
no)
|
||||||
;;
|
;;
|
||||||
@ -296,7 +300,7 @@ case $set_asm in
|
|||||||
x86_64)
|
x86_64)
|
||||||
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DUSE_ASM_X86_64=1"
|
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DUSE_ASM_X86_64=1"
|
||||||
;;
|
;;
|
||||||
arm)
|
arm32)
|
||||||
enable_external_asm=yes
|
enable_external_asm=yes
|
||||||
;;
|
;;
|
||||||
no)
|
no)
|
||||||
@ -413,8 +417,8 @@ if test x"$enable_experimental" = x"yes"; then
|
|||||||
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
|
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
|
||||||
AC_MSG_NOTICE([******])
|
AC_MSG_NOTICE([******])
|
||||||
else
|
else
|
||||||
if test x"$set_asm" = x"arm"; then
|
if test x"$set_asm" = x"arm32"; then
|
||||||
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
|
AC_MSG_ERROR([ARM32 assembly optimization is experimental. Use --enable-experimental to allow.])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -436,7 +440,7 @@ AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"ye
|
|||||||
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
|
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
|
||||||
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
|
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
|
||||||
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
|
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
|
||||||
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
|
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm32"])
|
||||||
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
|
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
|
||||||
AC_SUBST(LIB_VERSION_CURRENT, _LIB_VERSION_CURRENT)
|
AC_SUBST(LIB_VERSION_CURRENT, _LIB_VERSION_CURRENT)
|
||||||
AC_SUBST(LIB_VERSION_REVISION, _LIB_VERSION_REVISION)
|
AC_SUBST(LIB_VERSION_REVISION, _LIB_VERSION_REVISION)
|
||||||
|
@ -11,7 +11,7 @@ add_library(secp256k1_precomputed OBJECT EXCLUDE_FROM_ALL
|
|||||||
add_library(secp256k1 secp256k1.c $<TARGET_OBJECTS:secp256k1_precomputed>)
|
add_library(secp256k1 secp256k1.c $<TARGET_OBJECTS:secp256k1_precomputed>)
|
||||||
|
|
||||||
add_library(secp256k1_asm INTERFACE)
|
add_library(secp256k1_asm INTERFACE)
|
||||||
if(SECP256K1_ASM STREQUAL "arm")
|
if(SECP256K1_ASM STREQUAL "arm32")
|
||||||
add_library(secp256k1_asm_arm OBJECT EXCLUDE_FROM_ALL)
|
add_library(secp256k1_asm_arm OBJECT EXCLUDE_FROM_ALL)
|
||||||
target_sources(secp256k1_asm_arm PUBLIC
|
target_sources(secp256k1_asm_arm PUBLIC
|
||||||
asm/field_10x26_arm.s
|
asm/field_10x26_arm.s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user