build(crypto): select randomx sources by architecture
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
9c5b179375
commit
d5070cce15
1 changed files with 39 additions and 14 deletions
|
|
@ -49,8 +49,6 @@ set(CXX_SOURCES
|
||||||
set(RANDOMX_SOURCES
|
set(RANDOMX_SOURCES
|
||||||
randomx/aes_hash.cpp
|
randomx/aes_hash.cpp
|
||||||
randomx/argon2_ref.c
|
randomx/argon2_ref.c
|
||||||
randomx/argon2_ssse3.c
|
|
||||||
randomx/argon2_avx2.c
|
|
||||||
randomx/bytecode_machine.cpp
|
randomx/bytecode_machine.cpp
|
||||||
randomx/cpu.cpp
|
randomx/cpu.cpp
|
||||||
randomx/dataset.cpp
|
randomx/dataset.cpp
|
||||||
|
|
@ -58,23 +56,47 @@ set(RANDOMX_SOURCES
|
||||||
randomx/virtual_memory.c
|
randomx/virtual_memory.c
|
||||||
randomx/vm_interpreted.cpp
|
randomx/vm_interpreted.cpp
|
||||||
randomx/allocator.cpp
|
randomx/allocator.cpp
|
||||||
randomx/assembly_generator_x86.cpp
|
|
||||||
randomx/instruction.cpp
|
randomx/instruction.cpp
|
||||||
randomx/randomx.cpp
|
randomx/randomx.cpp
|
||||||
randomx/superscalar.cpp
|
randomx/superscalar.cpp
|
||||||
randomx/vm_compiled.cpp
|
|
||||||
randomx/vm_interpreted_light.cpp
|
randomx/vm_interpreted_light.cpp
|
||||||
randomx/argon2_core.c
|
randomx/argon2_core.c
|
||||||
randomx/blake2_generator.cpp
|
randomx/blake2_generator.cpp
|
||||||
randomx/instructions_portable.cpp
|
randomx/instructions_portable.cpp
|
||||||
randomx/reciprocal.c
|
randomx/reciprocal.c
|
||||||
randomx/virtual_machine.cpp
|
randomx/virtual_machine.cpp
|
||||||
|
randomx/vm_compiled.cpp
|
||||||
randomx/vm_compiled_light.cpp
|
randomx/vm_compiled_light.cpp
|
||||||
randomx/blake2/blake2b.c
|
randomx/blake2/blake2b.c
|
||||||
randomx/jit_compiler_x86.cpp
|
|
||||||
randomx/jit_compiler_x86_static.S
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$")
|
||||||
|
list(APPEND RANDOMX_SOURCES
|
||||||
|
randomx/argon2_ssse3.c
|
||||||
|
randomx/argon2_avx2.c
|
||||||
|
randomx/assembly_generator_x86.cpp
|
||||||
|
randomx/jit_compiler_x86.cpp
|
||||||
|
randomx/jit_compiler_x86_static.S
|
||||||
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)$")
|
||||||
|
list(APPEND RANDOMX_SOURCES
|
||||||
|
randomx/jit_compiler_a64.cpp
|
||||||
|
randomx/jit_compiler_a64_static.S
|
||||||
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv64|rv64)$")
|
||||||
|
list(APPEND RANDOMX_SOURCES
|
||||||
|
randomx/aes_hash_rv64_vector.cpp
|
||||||
|
randomx/aes_hash_rv64_zvkned.cpp
|
||||||
|
randomx/cpu_rv64.S
|
||||||
|
randomx/jit_compiler_rv64.cpp
|
||||||
|
randomx/jit_compiler_rv64_static.S
|
||||||
|
randomx/jit_compiler_rv64_vector.cpp
|
||||||
|
randomx/jit_compiler_rv64_vector_static.S
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unsupported RandomX architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(randomx STATIC ${RANDOMX_SOURCES})
|
add_library(randomx STATIC ${RANDOMX_SOURCES})
|
||||||
target_include_directories(randomx PRIVATE
|
target_include_directories(randomx PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/randomx
|
${CMAKE_CURRENT_SOURCE_DIR}/randomx
|
||||||
|
|
@ -85,15 +107,18 @@ set_property(TARGET randomx PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# Platform-specific flags for RandomX
|
# Platform-specific flags for RandomX
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
target_compile_options(randomx PRIVATE -maes)
|
|
||||||
|
|
||||||
check_c_compiler_flag(-mssse3 HAVE_SSSE3)
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$")
|
||||||
if(HAVE_SSSE3)
|
target_compile_options(randomx PRIVATE -maes)
|
||||||
set_source_files_properties(randomx/argon2_ssse3.c PROPERTIES COMPILE_FLAGS -mssse3)
|
|
||||||
endif()
|
check_c_compiler_flag(-mssse3 HAVE_SSSE3)
|
||||||
check_c_compiler_flag(-mavx2 HAVE_AVX2)
|
if(HAVE_SSSE3)
|
||||||
if(HAVE_AVX2)
|
set_source_files_properties(randomx/argon2_ssse3.c PROPERTIES COMPILE_FLAGS -mssse3)
|
||||||
set_source_files_properties(randomx/argon2_avx2.c PROPERTIES COMPILE_FLAGS -mavx2)
|
endif()
|
||||||
|
check_c_compiler_flag(-mavx2 HAVE_AVX2)
|
||||||
|
if(HAVE_AVX2)
|
||||||
|
set_source_files_properties(randomx/argon2_avx2.c PROPERTIES COMPILE_FLAGS -mavx2)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(randomx PRIVATE
|
target_compile_options(randomx PRIVATE
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue