From ec608bbd057ef64c0affa27b106ce3397c9031e3 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 2 Apr 2021 10:05:46 +0200 Subject: [PATCH] Don't use RandomX JIT if WITH_ASM=OFF Because RandomX JIT use asm code --- cmake/randomx.cmake | 6 +++--- src/crypto/randomx/common.hpp | 4 ++-- src/crypto/randomx/jit_compiler.hpp | 4 ++-- src/crypto/randomx/randomx.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/randomx.cmake b/cmake/randomx.cmake index 976f1186..52875597 100644 --- a/cmake/randomx.cmake +++ b/cmake/randomx.cmake @@ -42,20 +42,20 @@ if (WITH_RANDOMX) src/crypto/rx/RxVm.cpp ) - if (CMAKE_C_COMPILER_ID MATCHES MSVC) + if (WITH_ASM AND CMAKE_C_COMPILER_ID MATCHES MSVC) enable_language(ASM_MASM) list(APPEND SOURCES_CRYPTO src/crypto/randomx/jit_compiler_x86_static.asm src/crypto/randomx/jit_compiler_x86.cpp ) - elseif (NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8) + elseif (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND SOURCES_CRYPTO src/crypto/randomx/jit_compiler_x86_static.S src/crypto/randomx/jit_compiler_x86.cpp ) # cheat because cmake and ccache hate each other set_property(SOURCE src/crypto/randomx/jit_compiler_x86_static.S PROPERTY LANGUAGE C) - elseif (XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8) + elseif (WITH_ASM AND XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND SOURCES_CRYPTO src/crypto/randomx/jit_compiler_a64_static.S src/crypto/randomx/jit_compiler_a64.cpp diff --git a/src/crypto/randomx/common.hpp b/src/crypto/randomx/common.hpp index aefbad03..a54081db 100644 --- a/src/crypto/randomx/common.hpp +++ b/src/crypto/randomx/common.hpp @@ -103,11 +103,11 @@ namespace randomx { #endif #endif -#if defined(_M_X64) || defined(__x86_64__) +#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__)) #define RANDOMX_HAVE_COMPILER 1 class JitCompilerX86; using JitCompiler = JitCompilerX86; -#elif defined(__aarch64__) +#elif defined(XMRIG_FEATURE_ASM) && defined(__aarch64__) #define RANDOMX_HAVE_COMPILER 1 class JitCompilerA64; using JitCompiler = JitCompilerA64; diff --git a/src/crypto/randomx/jit_compiler.hpp b/src/crypto/randomx/jit_compiler.hpp index 03b60508..99498254 100644 --- a/src/crypto/randomx/jit_compiler.hpp +++ b/src/crypto/randomx/jit_compiler.hpp @@ -28,9 +28,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#if defined(_M_X64) || defined(__x86_64__) +#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__)) #include "crypto/randomx/jit_compiler_x86.hpp" -#elif defined(__aarch64__) +#elif defined(XMRIG_FEATURE_ASM) && defined(__aarch64__) #include "crypto/randomx/jit_compiler_a64.hpp" #else #include "crypto/randomx/jit_compiler_fallback.hpp" diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 9986a33f..365ff60c 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -148,7 +148,7 @@ RandomX_ConfigurationBase::RandomX_ConfigurationBase() fillAes4Rx4_Key[6] = rx_set_int_vec_i128(0xf63befa7, 0x2ba9660a, 0xf765a38b, 0xf273c9e7); fillAes4Rx4_Key[7] = rx_set_int_vec_i128(0xc0b0762d, 0x0c06d1fd, 0x915839de, 0x7a7cd609); -# if defined(_M_X64) || defined(__x86_64__) +# if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__)) // Workaround for Visual Studio placing trampoline in debug builds. auto addr = [](void (*func)()) { const uint8_t* p = reinterpret_cast(func); @@ -214,7 +214,7 @@ void RandomX_ConfigurationBase::Apply() ScratchpadL3Mask_Calculated = (((ScratchpadL3_Size / sizeof(uint64_t)) - 1) * 8); ScratchpadL3Mask64_Calculated = ((ScratchpadL3_Size / sizeof(uint64_t)) / 8 - 1) * 64; -#if defined(_M_X64) || defined(__x86_64__) +#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__)) *(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1; // Not needed right now because all variants use default dataset base size //const uint32_t DatasetBaseMask = DatasetBaseSize - RANDOMX_DATASET_ITEM_SIZE; @@ -262,7 +262,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \ } while (0) -#elif defined(XMRIG_ARMv8) +#elif defined(XMRIG_FEATURE_ASM) && defined(XMRIG_ARMv8) Log2_ScratchpadL1 = Log2(ScratchpadL1_Size); Log2_ScratchpadL2 = Log2(ScratchpadL2_Size);