From cf7ce13986e81b7c359a08149bb97b4d78901c04 Mon Sep 17 00:00:00 2001 From: stoffu Date: Thu, 11 Apr 2019 14:01:07 +0900 Subject: [PATCH 1/5] Config: fix std::max issue with msvc2017 to fix the following errors: xmrig\src\core\Config.cpp(165): error C2065: 'max': undeclared identifier xmrig\src\core\Config.cpp(165): error C2275: 'size_t': illegal use of this type as an expression --- src/core/Config.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 82a961178..9216027a5 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -22,6 +22,7 @@ * along with this program. If not, see . */ +#include #include #include #include From 32c3d4b9f6469d57ab4d5fbbb007f3463c2ccac5 Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Mon, 15 Apr 2019 10:39:16 -0600 Subject: [PATCH 2/5] Repair compilation with Clang 9.0.0 (which now includes its own _rotr intrinsic) --- src/crypto/soft_aes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/soft_aes.h b/src/crypto/soft_aes.h index 26c1b06ad..52fd9b7a6 100644 --- a/src/crypto/soft_aes.h +++ b/src/crypto/soft_aes.h @@ -130,7 +130,7 @@ static inline uint32_t sub_word(uint32_t key) saes_sbox[key & 0xff]; } -#if defined(__clang__) || defined(XMRIG_ARM) +#if (defined(__clang__) && __clang_major__ != 9) || defined(XMRIG_ARM) static inline uint32_t _rotr(uint32_t value, uint32_t amount) { return (value >> amount) | (value << ((32 - amount) & 31)); From f9f7ef26b8c9757bb5e6733f420f880fbdb0464a Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 16 Apr 2019 01:20:50 +0700 Subject: [PATCH 3/5] #1012 Added checks for _rotr. --- cmake/flags.cmake | 7 +++++++ src/crypto/soft_aes.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 3989cb71b..2f3eb208a 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -10,6 +10,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") add_definitions(/DNDEBUG) endif() +include(CheckSymbolExists) + if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing") @@ -27,6 +29,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") + + add_definitions(/DHAVE_ROTR) endif() if (WIN32) @@ -50,6 +54,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) add_definitions(/D_CRT_SECURE_NO_WARNINGS) add_definitions(/D_CRT_NONSTDC_NO_WARNINGS) add_definitions(/DNOMINMAX) + add_definitions(/DHAVE_ROTR) elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) @@ -68,6 +73,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") + + check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR) endif() endif() diff --git a/src/crypto/soft_aes.h b/src/crypto/soft_aes.h index 26c1b06ad..4ad9bdd93 100644 --- a/src/crypto/soft_aes.h +++ b/src/crypto/soft_aes.h @@ -130,7 +130,7 @@ static inline uint32_t sub_word(uint32_t key) saes_sbox[key & 0xff]; } -#if defined(__clang__) || defined(XMRIG_ARM) +#ifndef HAVE_ROTR static inline uint32_t _rotr(uint32_t value, uint32_t amount) { return (value >> amount) | (value << ((32 - amount) & 31)); From 9137f59ec1216ceef8e4569640748d8bdc452593 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 16 Apr 2019 02:00:27 +0700 Subject: [PATCH 4/5] #1012 Fixed _rotr detection. --- cmake/flags.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 2f3eb208a..d50b5c84b 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -75,6 +75,9 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR) + if (HAVE_ROTR) + add_definitions(/DHAVE_ROTR) + endif() endif() endif() From 699269bbae408001f19c53f5e130d93f67d06e0b Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Mon, 15 Apr 2019 13:26:55 -0600 Subject: [PATCH 5/5] Upstream fixed it for good with [Added checks for _rotr.] and [Fixed _rotr detection.] --- cmake/flags.cmake | 10 ++++++++++ src/crypto/soft_aes.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 3989cb71b..d50b5c84b 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -10,6 +10,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") add_definitions(/DNDEBUG) endif() +include(CheckSymbolExists) + if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing") @@ -27,6 +29,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") + + add_definitions(/DHAVE_ROTR) endif() if (WIN32) @@ -50,6 +54,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) add_definitions(/D_CRT_SECURE_NO_WARNINGS) add_definitions(/D_CRT_NONSTDC_NO_WARNINGS) add_definitions(/DNOMINMAX) + add_definitions(/DHAVE_ROTR) elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) @@ -68,6 +73,11 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") + + check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR) + if (HAVE_ROTR) + add_definitions(/DHAVE_ROTR) + endif() endif() endif() diff --git a/src/crypto/soft_aes.h b/src/crypto/soft_aes.h index 52fd9b7a6..4ad9bdd93 100644 --- a/src/crypto/soft_aes.h +++ b/src/crypto/soft_aes.h @@ -130,7 +130,7 @@ static inline uint32_t sub_word(uint32_t key) saes_sbox[key & 0xff]; } -#if (defined(__clang__) && __clang_major__ != 9) || defined(XMRIG_ARM) +#ifndef HAVE_ROTR static inline uint32_t _rotr(uint32_t value, uint32_t amount) { return (value >> amount) | (value << ((32 - amount) & 31));