What changed, and why it matters
This commit removes leftover code that was only used when building Monero with Microsoft Visual C++ (MSVC). It deletes special-case build rules, compiler-specific macros, and Windows-only helper code. There is no change to how Monero handles money, keys, network messages, or cryptography on supported platforms. It is a cleanup change, not a security fix.
No security action required. Treat as ordinary build cleanup. If the project still supports MSVC, maintainers should verify that the removed code is truly unused; otherwise no response is needed.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes MSVC-specific branches across CMake modules and C/C++ source files. Notable removals include: FindLibUSB.cmake and FindSodium.cmake MSVC library-path logic; epee int-util.h rol32/rol64 and BYTE_ORDER definitions for _MSC_VER; epee warnings.h MSVC pragma macros; memwipe.c __asm scarecrow; scoped_message_writer.h MSVC move-constructor path; difficulty.cpp max macro undef; wallet_errors.h Boost.Preprocessor variadic template fallback; test serialization Windows HANDLE/FlushFileBuffers path; hash test _MSC_VER SSE guards; and tests/io.h variadic template fallback. All changes are conditional-compilation cleanup. No functional logic on currently supported GCC/Clang/MinGW builds is altered.
Changed components
cmake/FindLibUSB.cmakecmake/FindSodium.cmakecontrib/epee/include/int-util.hcontrib/epee/include/string_tools.hcontrib/epee/include/warnings.hcontrib/epee/src/memwipe.csrc/common/scoped_message_writer.hsrc/cryptonote_basic/difficulty.cppsrc/wallet/wallet_errors.htests/core_tests/chaingen_serialization.htests/hash/main.cpptests/io.hInspect captured patch +6 / −212
diff --git a/cmake/FindLibUSB.cmake b/cmake/FindLibUSB.cmake
index 5ce589d..1aab15b 100644
--- a/cmake/FindLibUSB.cmake
+++ b/cmake/FindLibUSB.cmake
@@ -56,17 +56,11 @@ else ( PKGCONFIG_LIBUSB_FOUND )
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
# LibUSB-Win32 binary distribution contains several libs.
# Use the lib that got compiled with the same compiler.
- if ( MSVC )
- if ( WIN32 )
- set ( LibUSB_LIBRARY_PATH_SUFFIX lib/msvc )
- else ( WIN32 )
- set ( LibUSB_LIBRARY_PATH_SUFFIX lib/msvc_x64 )
- endif ( WIN32 )
- elseif ( BORLAND )
+ if ( BORLAND )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/bcc )
elseif ( CMAKE_COMPILER_IS_GNUCC )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/gcc )
- endif ( MSVC )
+ endif ()
endif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
find_library ( usb_LIBRARY
diff --git a/cmake/FindSodium.cmake b/cmake/FindSodium.cmake
index 3c3f124..3655036 100644
--- a/cmake/FindSodium.cmake
+++ b/cmake/FindSodium.cmake
@@ -99,70 +99,7 @@ elseif (WIN32)
PATH_SUFFIXES include
)
- if (MSVC)
- # detect target architecture
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
- #if defined _M_IX86
- #error ARCH_VALUE x86_32
- #elif defined _M_X64
- #error ARCH_VALUE x86_64
- #endif
- #error ARCH_VALUE unknown
- ]=])
- try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
- OUTPUT_VARIABLE _COMPILATION_LOG
- )
- string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")
-
- # construct library path
- if (_TARGET_ARCH STREQUAL "x86_32")
- string(APPEND _PLATFORM_PATH "Win32")
- elseif(_TARGET_ARCH STREQUAL "x86_64")
- string(APPEND _PLATFORM_PATH "x64")
- else()
- message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
- endif()
- string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
-
- if (MSVC_VERSION LESS 1900)
- math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
- else()
- math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
- endif()
- string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
-
- if (sodium_USE_STATIC_LIBS)
- string(APPEND _PLATFORM_PATH "/static")
- else()
- string(APPEND _PLATFORM_PATH "/dynamic")
- endif()
-
- string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
- string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")
-
- find_library(sodium_LIBRARY_DEBUG libsodium.lib
- HINTS ${sodium_DIR}
- PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
- )
- find_library(sodium_LIBRARY_RELEASE libsodium.lib
- HINTS ${sodium_DIR}
- PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
- )
- if (NOT sodium_USE_STATIC_LIBS)
- set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
- set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
- find_library(sodium_DLL_DEBUG libsodium
- HINTS ${sodium_DIR}
- PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
- )
- find_library(sodium_DLL_RELEASE libsodium
- HINTS ${sodium_DIR}
- PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
- )
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
- endif()
-
- elseif(_GCC_COMPATIBLE)
+ if(_GCC_COMPATIBLE)
if (sodium_USE_STATIC_LIBS)
find_library(sodium_LIBRARY_DEBUG libsodium.a
HINTS ${sodium_DIR}
diff --git a/contrib/epee/include/int-util.h b/contrib/epee/include/int-util.h
index 9593882..bf1bb47 100644
--- a/contrib/epee/include/int-util.h
+++ b/contrib/epee/include/int-util.h
@@ -34,10 +34,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
-
-#ifndef _MSC_VER
#include <sys/param.h>
-#endif
#if defined(__ANDROID__)
#include <byteswap.h>
@@ -47,20 +44,6 @@
#include <endian.h>
#endif
-#if defined(_MSC_VER)
-#include <stdlib.h>
-
-static inline uint32_t rol32(uint32_t x, int r) {
- static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers");
- return _rotl(x, r);
-}
-
-static inline uint64_t rol64(uint64_t x, int r) {
- return _rotl64(x, r);
-}
-
-#else
-
static inline uint32_t rol32(uint32_t x, int r) {
return (x << (r & 31)) | (x >> (-r & 31));
}
@@ -69,8 +52,6 @@ static inline uint64_t rol64(uint64_t x, int r) {
return (x << (r & 63)) | (x >> (-r & 63));
}
-#endif
-
static inline uint64_t hi_dword(uint64_t val) {
return val >> 32;
}
@@ -255,12 +236,6 @@ static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
}
}
-#ifdef _MSC_VER
-# define LITTLE_ENDIAN 1234
-# define BIG_ENDIAN 4321
-# define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
#endif
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index a8f5055..2a138c7 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -40,10 +40,6 @@
#define OUT
#endif
-#ifdef WINDOWS_PLATFORM
-#pragma comment (lib, "Rpcrt4.lib")
-#endif
-
namespace epee
{
namespace string_tools
diff --git a/contrib/epee/include/warnings.h b/contrib/epee/include/warnings.h
index df5c7d1..213f3b7 100644
--- a/contrib/epee/include/warnings.h
+++ b/contrib/epee/include/warnings.h
@@ -1,16 +1,5 @@
#pragma once
-#if defined(_MSC_VER)
-
-#define PUSH_WARNINGS __pragma(warning(push))
-#define POP_WARNINGS __pragma(warning(pop))
-#define DISABLE_VS_WARNINGS(w) __pragma(warning(disable: w))
-#define DISABLE_GCC_WARNING(w)
-#define DISABLE_CLANG_WARNING(w)
-#define DISABLE_GCC_AND_CLANG_WARNING(w)
-
-#else
-
#include <boost/preprocessor/stringize.hpp>
#define PUSH_WARNINGS _Pragma("GCC diagnostic push")
@@ -26,5 +15,3 @@
#endif
#define DISABLE_GCC_AND_CLANG_WARNING(w) _Pragma(BOOST_PP_STRINGIZE(GCC diagnostic ignored BOOST_PP_STRINGIZE(-W##w)))
-
-#endif
diff --git a/contrib/epee/src/memwipe.c b/contrib/epee/src/memwipe.c
index d5d9ae1..d259f3e 100644
--- a/contrib/epee/src/memwipe.c
+++ b/contrib/epee/src/memwipe.c
@@ -38,13 +38,8 @@
#endif
#include "memwipe.h"
-#if defined(_MSC_VER)
-#define SCARECROW \
- __asm;
-#else
#define SCARECROW \
__asm__ __volatile__("" : : "r"(ptr) : "memory");
-#endif
#ifdef HAVE_MEMSET_S
diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h
index fbaf47c..6b95ffe 100644
--- a/src/common/scoped_message_writer.h
+++ b/src/common/scoped_message_writer.h
@@ -70,12 +70,8 @@ public:
scoped_message_writer(scoped_message_writer&& rhs)
: m_flush(std::move(rhs.m_flush))
-#if defined(_MSC_VER)
- , m_oss(std::move(rhs.m_oss))
-#else
// GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316
, m_oss(rhs.m_oss.str(), std::ios_base::out | std::ios_base::ate)
-#endif
, m_color(std::move(rhs.m_color))
, m_log_level(std::move(rhs.m_log_level))
{
diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp
index ca07882..ef94666 100644
--- a/src/cryptonote_basic/difficulty.cpp
+++ b/src/cryptonote_basic/difficulty.cpp
@@ -162,12 +162,6 @@ namespace cryptonote {
return (low + time_span - 1) / time_span;
}
-#if defined(_MSC_VER)
-#ifdef max
-#undef max
-#endif
-#endif
-
const difficulty_type max64bit(std::numeric_limits<std::uint64_t>::max());
const boost::multiprecision::uint256_t max128bit(std::numeric_limits<boost::multiprecision::uint128_t>::max());
const boost::multiprecision::uint512_t max256bit(std::numeric_limits<boost::multiprecision::uint256_t>::max());
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index 1ca1b21..a451a69 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -990,8 +990,6 @@ namespace tools
};
//----------------------------------------------------------------------------------------------------
-#if !defined(_MSC_VER)
-
template<typename TException, typename... TArgs>
[[noreturn]] void throw_wallet_ex(std::string&& loc, const TArgs&... args)
{
@@ -999,31 +997,6 @@ namespace tools
LOG_PRINT_L0(e.to_string());
throw e;
}
-
-#else
- #include <boost/preprocessor/repetition/enum_binary_params.hpp>
- #include <boost/preprocessor/repetition/enum_params.hpp>
- #include <boost/preprocessor/repetition/repeat_from_to.hpp>
-
- template<typename TException>
- [[noreturn]] void throw_wallet_ex(std::string&& loc)
- {
- TException e(std::move(loc));
- LOG_PRINT_L0(e.to_string());
- throw e;
- }
-
-#define GEN_throw_wallet_ex(z, n, data) \
- template<typename TException, BOOST_PP_ENUM_PARAMS(n, typename TArg)> \
- [[noreturn]] void throw_wallet_ex(std::string&& loc, BOOST_PP_ENUM_BINARY_PARAMS(n, const TArg, &arg)) \
- { \
- TException e(std::move(loc), BOOST_PP_ENUM_PARAMS(n, arg)); \
- LOG_PRINT_L0(e.to_string()); \
- throw e; \
- }
-
- BOOST_PP_REPEAT_FROM_TO(1, 6, GEN_throw_wallet_ex, ~)
-#endif
}
}
diff --git a/tests/core_tests/chaingen_serialization.h b/tests/core_tests/chaingen_serialization.h
index 8fc3b41..5591b4b 100644
--- a/tests/core_tests/chaingen_serialization.h
+++ b/tests/core_tests/chaingen_serialization.h
@@ -43,40 +43,10 @@ namespace tools
bool serialize_obj_to_file(t_object& obj, const std::string& file_path)
{
TRY_ENTRY();
-#if defined(_MSC_VER)
- // Need to know HANDLE of file to call FlushFileBuffers
- HANDLE data_file_handle = ::CreateFile(file_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (INVALID_HANDLE_VALUE == data_file_handle)
- return false;
-
- int data_file_descriptor = _open_osfhandle((intptr_t)data_file_handle, 0);
- if (-1 == data_file_descriptor)
- {
- ::CloseHandle(data_file_handle);
- return false;
- }
-
- const std::unique_ptr<FILE, tools::close_file> data_file_file{_fdopen(data_file_descriptor, "wb")};
- if (nullptr == data_file_file)
- {
- // Call CloseHandle is not necessary
- _close(data_file_descriptor);
- return false;
- }
-
- // HACK: undocumented constructor, this code may not compile
- std::ofstream data_file(data_file_file.get());
- if (data_file.fail())
- {
- // Call CloseHandle and _close are not necessary
- return false;
- }
-#else
std::ofstream data_file;
data_file.open(file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
if (data_file.fail())
return false;
-#endif
boost::archive::portable_binary_oarchive a(data_file);
a << obj;
@@ -84,10 +54,6 @@ namespace tools
return false;
data_file.flush();
-#if defined(_MSC_VER)
- // To make sure the file is fully stored on disk
- ::FlushFileBuffers(data_file_handle);
-#endif
return true;
CATCH_ENTRY_L0("serialize_obj_to_file", false);
diff --git a/tests/hash/main.cpp b/tests/hash/main.cpp
index f44aba2..9840be8 100644
--- a/tests/hash/main.cpp
+++ b/tests/hash/main.cpp
@@ -267,11 +267,11 @@ int main(int argc, char *argv[]) {
CATCH_ENTRY_L0("main", 1);
}
-#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64))
+#if defined(__x86_64__)
#include <emmintrin.h>
-#if defined(_MSC_VER) || defined(__MINGW32__)
+#if defined(__MINGW32__)
#include <intrin.h>
#else
#include <wmmintrin.h>
@@ -281,7 +281,7 @@ int main(int argc, char *argv[]) {
static inline bool test_variant2_int_sqrt_sse(const uint64_t sqrt_input, const uint64_t correct_result)
{
-#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64))
+#if defined(__x86_64__)
uint64_t sqrt_result;
VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2();
VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result);
diff --git a/tests/io.h b/tests/io.h
index 8a0137a..254fbdb 100644
--- a/tests/io.h
+++ b/tests/io.h
@@ -106,28 +106,9 @@ inline void get(std::istream &input, std::vector<char> &res) {
}
}
-#if !defined(_MSC_VER) || _MSC_VER >= 1800
-
template<typename T, typename... TT>
typename std::enable_if<(sizeof...(TT) > 0), void>::type
get(std::istream &input, T &res, TT &... resres) {
get(input, res);
get(input, resres...);
}
-
-#else
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/repeat.hpp>
-#include <boost/preprocessor/repetition/repeat_from_to.hpp>
-
-#define NESTED_GET(z, n, data) get(input, BOOST_PP_CAT(res, n));
-#define GET(z, n, data) \
-template<BOOST_PP_ENUM_PARAMS(n, typename T)> \
-void get(std::istream &input, BOOST_PP_ENUM_BINARY_PARAMS(n, T, &res)) { \
- BOOST_PP_REPEAT(n, NESTED_GET, ~) \
-}
-BOOST_PP_REPEAT_FROM_TO(2, 5, GET, ~)
-
-#endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.