1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-07 07:55:04 -05:00

Compare commits

..

3 Commits

Author SHA1 Message Date
XMRig
57a4998ae2 Fix Linux build. 2025-06-13 04:05:30 +07:00
XMRig
34b4448a81 Split BasicCpuInfo_arm. 2025-06-13 03:57:13 +07:00
XMRig
650d794fb1 Initial Windows ARM64 support via MSYS2. 2025-06-13 03:00:34 +07:00
11 changed files with 164 additions and 71 deletions

View File

@@ -240,7 +240,10 @@ add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${HEADE
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB} ${ARGON2_LIBRARY} ${ETHASH_LIBRARY} ${GHOSTRIDER_LIBRARY}) target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB} ${ARGON2_LIBRARY} ${ETHASH_LIBRARY} ${GHOSTRIDER_LIBRARY})
if (WIN32) if (WIN32)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/bin/WinRing0/WinRing0x64.sys" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) if (NOT ARM_TARGET)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/bin/WinRing0/WinRing0x64.sys" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
endif()
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_1M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_1M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_10M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_10M.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/pool_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/pool_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
@@ -249,5 +252,5 @@ if (WIN32)
endif() endif()
if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release AND NOT CMAKE_GENERATOR STREQUAL Xcode) if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release AND NOT CMAKE_GENERATOR STREQUAL Xcode)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} ${CMAKE_PROJECT_NAME}) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:${CMAKE_PROJECT_NAME}>")
endif() endif()

View File

@@ -38,7 +38,7 @@ elseif (ARM_V7)
endif() endif()
if (NOT ARM_TARGET) if (NOT ARM_TARGET)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv8-a)$") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64|armv8-a)$")
set(ARM_TARGET 8) set(ARM_TARGET 8)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7|armv7f|armv7s|armv7k|armv7-a|armv7l|armv7ve)$") elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7|armv7f|armv7s|armv7k|armv7-a|armv7l|armv7ve)$")
set(ARM_TARGET 7) set(ARM_TARGET 7)

View File

@@ -84,7 +84,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
endif() endif()
endif() endif()
if (BUILD_STATIC) if (BUILD_STATIC OR WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif() endif()

View File

@@ -49,8 +49,15 @@ endif()
if (XMRIG_ARM) if (XMRIG_ARM)
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm.cpp) list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm.cpp)
if (XMRIG_OS_UNIX) if (XMRIG_OS_WIN)
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/lscpu_arm.cpp) list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm_win.cpp)
elseif(XMRIG_OS_APPLE)
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm_mac.cpp)
else()
list(APPEND SOURCES_BACKEND_CPU
src/backend/cpu/platform/lscpu_arm.cpp
src/backend/cpu/platform/BasicCpuInfo_arm_unix.cpp
)
endif() endif()
else() else()
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo.cpp) list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo.cpp)

View File

@@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> * Copyright (c) 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <support@xmrig.com> * Copyright (c) 2016-2025 XMRig <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -85,6 +85,8 @@ private:
uint32_t m_family = 0; uint32_t m_family = 0;
uint32_t m_model = 0; uint32_t m_model = 0;
uint32_t m_stepping = 0; uint32_t m_stepping = 0;
# else
void init_arm();
# endif # endif
Assembly m_assembly = Assembly::NONE; Assembly m_assembly = Assembly::NONE;

View File

@@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <support@xmrig.com> * Copyright (c) 2016-2025 XMRig <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -16,44 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "base/tools/String.h"
#include <array> #include <array>
#include <cstring> #include <cstring>
#include <fstream>
#include <thread> #include <thread>
#if __ARM_FEATURE_CRYPTO && !defined(__APPLE__)
# include <sys/auxv.h>
# if !defined(XMRIG_OS_FREEBSD)
# include <asm/hwcap.h>
# else
# include <stdint.h>
# include <machine/armreg.h>
# ifndef ID_AA64ISAR0_AES_VAL
# define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
# endif
# endif
#endif
#include "backend/cpu/platform/BasicCpuInfo.h" #include "backend/cpu/platform/BasicCpuInfo.h"
#include "3rdparty/rapidjson/document.h" #include "3rdparty/rapidjson/document.h"
#if defined(XMRIG_OS_UNIX)
namespace xmrig {
extern String cpu_name_arm();
} // namespace xmrig
#elif defined(XMRIG_OS_MACOS)
# include <sys/sysctl.h>
#endif
xmrig::BasicCpuInfo::BasicCpuInfo() : xmrig::BasicCpuInfo::BasicCpuInfo() :
m_threads(std::thread::hardware_concurrency()) m_threads(std::thread::hardware_concurrency())
{ {
@@ -68,28 +39,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
memcpy(m_brand, "ARMv7", 5); memcpy(m_brand, "ARMv7", 5);
# endif # endif
# if __ARM_FEATURE_CRYPTO init_arm();
# if defined(__APPLE__)
m_flags.set(FLAG_AES, true);
# elif defined(XMRIG_OS_FREEBSD)
uint64_t isar0 = READ_SPECIALREG(id_aa64isar0_el1);
m_flags.set(FLAG_AES, ID_AA64ISAR0_AES_VAL(isar0) >= ID_AA64ISAR0_AES_BASE);
# else
m_flags.set(FLAG_AES, getauxval(AT_HWCAP) & HWCAP_AES);
# endif
# endif
# if defined(XMRIG_OS_UNIX)
auto name = cpu_name_arm();
if (!name.isNull()) {
strncpy(m_brand, name, sizeof(m_brand) - 1);
}
m_flags.set(FLAG_PDPE1GB, std::ifstream("/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages").good());
# elif defined(XMRIG_OS_MACOS)
size_t buflen = sizeof(m_brand);
sysctlbyname("machdep.cpu.brand_string", &m_brand, &buflen, nullptr, 0);
# endif
} }

View File

@@ -0,0 +1,32 @@
/* XMRig
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/cpu/platform/BasicCpuInfo.h"
#include <sys/sysctl.h>
void xmrig::BasicCpuInfo::init_arm()
{
# if __ARM_FEATURE_CRYPTO
m_flags.set(FLAG_AES, true); // FIXME
# endif
size_t buflen = sizeof(m_brand);
sysctlbyname("machdep.cpu.brand_string", &m_brand, &buflen, nullptr, 0);
}

View File

@@ -0,0 +1,68 @@
/* XMRig
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/cpu/platform/BasicCpuInfo.h"
#include "base/tools/String.h"
#include <fstream>
#if __ARM_FEATURE_CRYPTO
# include <sys/auxv.h>
# if !defined(XMRIG_OS_FREEBSD)
# include <asm/hwcap.h>
# else
# include <stdint.h>
# include <machine/armreg.h>
# ifndef ID_AA64ISAR0_AES_VAL
# define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
# endif
# endif
#endif
namespace xmrig {
extern String cpu_name_arm();
} // namespace xmrig
void xmrig::BasicCpuInfo::init_arm()
{
# if __ARM_FEATURE_CRYPTO
# if defined(XMRIG_OS_FREEBSD)
uint64_t isar0 = READ_SPECIALREG(id_aa64isar0_el1);
m_flags.set(FLAG_AES, ID_AA64ISAR0_AES_VAL(isar0) >= ID_AA64ISAR0_AES_BASE);
# else
m_flags.set(FLAG_AES, getauxval(AT_HWCAP) & HWCAP_AES);
# endif
# endif
# if defined(XMRIG_OS_UNIX)
auto name = cpu_name_arm();
if (!name.isNull()) {
strncpy(m_brand, name, sizeof(m_brand) - 1);
}
m_flags.set(FLAG_PDPE1GB, std::ifstream("/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages").good());
# endif
}

View File

@@ -0,0 +1,27 @@
/* XMRig
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2025 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/cpu/platform/BasicCpuInfo.h"
void xmrig::BasicCpuInfo::init_arm()
{
# if __ARM_FEATURE_CRYPTO
m_flags.set(FLAG_AES, true); // FIXME
# endif
}

View File

@@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2025 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
#include <windows.h> #include <windows.h>
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__clang__)
# include <fcntl.h> # include <fcntl.h>
# include <sys/stat.h> # include <sys/stat.h>
# include <ext/stdio_filebuf.h> # include <ext/stdio_filebuf.h>
@@ -39,7 +39,7 @@
namespace xmrig { namespace xmrig {
#if defined(_MSC_VER) || defined (__GNUC__) #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__))
static std::wstring toUtf16(const char *str) static std::wstring toUtf16(const char *str)
{ {
const int size = static_cast<int>(strlen(str)); const int size = static_cast<int>(strlen(str));
@@ -62,7 +62,7 @@ static std::wstring toUtf16(const char *str)
if (!ifs.is_open()) { \ if (!ifs.is_open()) { \
return false; \ return false; \
} }
#elif defined(__GNUC__) #elif defined(__GNUC__) && !defined(__clang__)
# define OPEN_IFS(name) \ # define OPEN_IFS(name) \
const int fd = _wopen(toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ const int fd = _wopen(toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \
if (fd == -1) { \ if (fd == -1) { \
@@ -103,7 +103,7 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
if (!ofs.is_open()) { if (!ofs.is_open()) {
return false; return false;
} }
# elif defined(__GNUC__) # elif defined(__GNUC__) && !defined(__clang__)
const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE);
if (fd == -1) { if (fd == -1) {
return false; return false;

View File

@@ -392,13 +392,17 @@ FORCE_INLINE rx_vec_f128 rx_cvt_packed_int_vec_f128(const void* addr) {
typedef uint8x16_t rx_vec_i128; typedef uint8x16_t rx_vec_i128;
typedef float64x2_t rx_vec_f128; typedef float64x2_t rx_vec_f128;
#if !defined(XMRIG_OS_WIN) // FIXME
inline void* rx_aligned_alloc(size_t size, size_t align) { inline void* rx_aligned_alloc(size_t size, size_t align) {
void* p; void* p;
if (posix_memalign(&p, align, size) == 0) if (posix_memalign(&p, align, size) == 0)
return p; return p;
return 0; return 0;
}; };
#else
# define rx_aligned_alloc(a, b) malloc(a)
#endif
#define rx_aligned_free(a) free(a) #define rx_aligned_free(a) free(a)