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() | ||||
option(SECP256K1_USE_ASM "Use assembly if available" ON) | # Guess the target architecture, within the ones with supported ASM. | ||||
# 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") | |||||
set(SECP256K1_ASM_BUILD_TARGET "x86_64") | |||||
set(SECP256K1_DEFAULT_USE_ASM ON) | |||||
elseif(CMAKE_C_COMPILER_TARGET MATCHES "arm-linux-gnueabihf") | |||||
set(SECP256K1_ASM_BUILD_TARGET "arm-linux-gnueabihf") | |||||
set(SECP256K1_DEFAULT_USE_ASM ON) | |||||
endif() | |||||
# Enable ASM by default only if we are building for a compatible target. | |||||
# The user can still enable/disable it manually if needed. | |||||
option(SECP256K1_USE_ASM "Use assembly if available" ${SECP256K1_DEFAULT_USE_ASM}) | |||||
deadalnix: The docstring is wrong. | |||||
if(SECP256K1_USE_ASM) | if(SECP256K1_USE_ASM) | ||||
macro(unsupported_asm_error) | macro(unsupported_asm_error) | ||||
message(FATAL_ERROR | message(FATAL_ERROR | ||||
"Assembly is not supported for your target architecture." | "Assembly is enabled, but not supported for your target architecture." | ||||
"Re-run cmake with -DSECP256K1_USE_ASM=OFF to disable ASM support" | "Re-run cmake with -DSECP256K1_USE_ASM=OFF to disable ASM support." | ||||
) | ) | ||||
endmacro() | endmacro() | ||||
# Guess the target architecture. | if(SECP256K1_ASM_BUILD_TARGET MATCHES "x86_64") | ||||
# 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. | # 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) | if(NOT USE_ASM_X86_64) | ||||
unsupported_asm_error() | unsupported_asm_error() | ||||
endif() | endif() | ||||
elseif(CMAKE_C_COMPILER_TARGET MATCHES "arm-linux-gnueabihf") | elseif(SECP256K1_ASM_BUILD_TARGET MATCHES "arm-linux-gnueabihf") | ||||
enable_language(ASM) | enable_language(ASM) | ||||
set(USE_EXTERNAL_ASM 1) | set(USE_EXTERNAL_ASM 1) | ||||
add_library(secp256k1_common src/asm/field_10x26_arm.s) | add_library(secp256k1_common src/asm/field_10x26_arm.s) | ||||
target_link_libraries(secp256k1 secp256k1_common) | target_link_libraries(secp256k1 secp256k1_common) | ||||
else() | else() | ||||
unsupported_asm_error() | unsupported_asm_error() | ||||
endif() | endif() | ||||
endif() | endif() | ||||
▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines |
The docstring is wrong.