From 3ff41f7c94724c66497cb3a8f102fd3bf6110209 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 14 Jun 2025 15:38:25 +0700 Subject: [PATCH] Fixed UTF-8 paths support for the config file with Clang compiler on Windows ARM64. --- cmake/cpu.cmake | 2 +- cmake/flags.cmake | 2 +- src/base/io/json/Json_win.cpp | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake index 32c043a0..12dbe9b1 100644 --- a/cmake/cpu.cmake +++ b/cmake/cpu.cmake @@ -51,7 +51,7 @@ if (ARM_TARGET AND ARM_TARGET GREATER 6) message(STATUS "Use ARM_TARGET=${ARM_TARGET} (${CMAKE_SYSTEM_PROCESSOR})") - if (ARM_TARGET EQUAL 8) + if (ARM_TARGET EQUAL 8 AND (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)) CHECK_CXX_COMPILER_FLAG(-march=armv8-a+crypto XMRIG_ARM_CRYPTO) if (XMRIG_ARM_CRYPTO) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 347e1758..cdce9336 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -84,7 +84,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) endif() endif() - if (BUILD_STATIC OR WIN32) + if ((WIN32 AND ARM_TARGET) OR BUILD_STATIC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") endif() endif() diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index 4512fe83..9de1caf6 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -39,7 +39,7 @@ namespace xmrig { -#if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__)) +#if defined(_MSC_VER) || defined(__GNUC__) static std::wstring toUtf16(const char *str) { const int size = static_cast(strlen(str)); @@ -56,13 +56,13 @@ static std::wstring toUtf16(const char *str) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(_LIBCPP_HAS_OPEN_WITH_WCHAR) # define OPEN_IFS(name) \ - std::ifstream ifs(toUtf16(name), std::ios_base::in | std::ios_base::binary); \ + std::ifstream ifs(toUtf16(name).c_str(), std::ios_base::in | std::ios_base::binary);\ if (!ifs.is_open()) { \ return false; \ } -#elif defined(__GNUC__) && !defined(__clang__) +#elif defined(__GNUC__) # define OPEN_IFS(name) \ const int fd = _wopen(toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ if (fd == -1) { \ @@ -98,12 +98,12 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) using namespace rapidjson; constexpr const std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary | std::ios_base::trunc; -# if defined(_MSC_VER) - std::ofstream ofs(toUtf16(fileName), mode); +# if defined(_MSC_VER) || defined(_LIBCPP_HAS_OPEN_WITH_WCHAR) + std::ofstream ofs(toUtf16(fileName).c_str(), mode); if (!ofs.is_open()) { return false; } -# elif defined(__GNUC__) && !defined(__clang__) +# elif defined(__GNUC__) const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); if (fd == -1) { return false;