Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/CMakeLists.txt
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if(SECP256K1_ENABLE_BIGNUM) | ||||
set(USE_FIELD_INV_NUM 1) | set(USE_FIELD_INV_NUM 1) | ||||
set(USE_SCALAR_INV_NUM 1) | set(USE_SCALAR_INV_NUM 1) | ||||
else() | else() | ||||
set(USE_NUM_NONE 1) | set(USE_NUM_NONE 1) | ||||
set(USE_FIELD_INV_BUILTIN 1) | set(USE_FIELD_INV_BUILTIN 1) | ||||
set(USE_SCALAR_INV_BUILTIN 1) | set(USE_SCALAR_INV_BUILTIN 1) | ||||
endif() | endif() | ||||
# We check if amd64 asm is supported. | |||||
option(SECP256K1_USE_ASM "Use assembly if available" ON) | option(SECP256K1_USE_ASM "Use assembly if available" ON) | ||||
if($SECP256K1_USE_ASM) | |||||
if(SECP256K1_USE_ASM) | |||||
macro(unsupported_asm_error) | |||||
message(FATAL_ERROR | |||||
"Assembly is not supported for your target architecture." | |||||
"Re-run cmake with -DSECP256k1_USE_ASM=OFF to disable ASM support" | |||||
) | |||||
endmacro() | |||||
# Guess the target architecture. | |||||
# First check if the CMAKE_C_COMPILER_TARGET is set (should be when | |||||
# cross compiling), then CMAKE_SYSTEM_PROCESSOR as a fallback if meaningful | |||||
# (this is not the case for ARM as the content is highly non standard). | |||||
if(CMAKE_C_COMPILER_TARGET MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") | |||||
# We check if amd64 asm is supported. | |||||
check_c_source_compiles(" | check_c_source_compiles(" | ||||
#include <stdint.h> | #include <stdint.h> | ||||
int main() { | int main() { | ||||
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\"); | ||||
return 0; | return 0; | ||||
} | } | ||||
" USE_ASM_X86_64) | " USE_ASM_X86_64) | ||||
if(NOT USE_ASM_X86_64) | |||||
unsupported_asm_error() | |||||
endif() | |||||
elseif(CMAKE_C_COMPILER_TARGET MATCHES "arm-linux-gnueabihf") | |||||
enable_language(ASM) | |||||
set(USE_EXTERNAL_ASM 1) | |||||
add_library(secp256k1_common src/asm/field_10x26_arm.s) | |||||
target_link_libraries(secp256k1 secp256k1_common) | |||||
else() | else() | ||||
set(USE_ASM_X86_64 0) | unsupported_asm_error() | ||||
endif() | |||||
endif() | endif() | ||||
# We make sure __int128 is defined | # We make sure __int128 is defined | ||||
include(CheckTypeSize) | include(CheckTypeSize) | ||||
check_type_size(__int128 SIZEOF___INT128) | check_type_size(__int128 SIZEOF___INT128) | ||||
if(SIZEOF___INT128 EQUAL 16) | if(SIZEOF___INT128 EQUAL 16) | ||||
set(HAVE___INT128 1) | set(HAVE___INT128 1) | ||||
else() | else() | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |