From 3327e7f54ac2a8d11c57601eff4ace10da789ec2 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:08:28 +0100 Subject: [PATCH] Fixed MSVC builds --- .github/workflows/c-cpp.yml | 4 ++-- .github/workflows/test-sync.yml | 4 ++-- cmake/grpc.cmake | 2 +- external/src/common/sanitizer/asan_interface.h | 12 ++++++++++++ external/src/common/stdalign.h | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 external/src/common/sanitizer/asan_interface.h diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index ff3faec..715e5d9 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -425,7 +425,7 @@ jobs: run: | mkdir build cd build - cmake .. -G "${{ matrix.config.vs }}" -DWITH_RANDOMX=${{ matrix.config.rx }} -DWITH_UPNP=${{ matrix.config.upnp }} + cmake .. -G "${{ matrix.config.vs }}" -DCMAKE_SYSTEM_VERSION="10.0" -DWITH_RANDOMX=${{ matrix.config.rx }} -DWITH_UPNP=${{ matrix.config.upnp }} & "${{ matrix.config.vspath }}\\MSBuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Release p2pool.vcxproj - name: Check Windows 7 compatibility @@ -449,7 +449,7 @@ jobs: cd tests mkdir build cd build - cmake .. -G "${{ matrix.config.vs }}" -DDEV_WITH_ASAN=ON + cmake .. -G "${{ matrix.config.vs }}" -DCMAKE_SYSTEM_VERSION="10.0" -DDEV_WITH_ASAN=ON & "${{ matrix.config.vspath }}\\MSBuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Debug p2pool_tests.vcxproj - name: Run tests diff --git a/.github/workflows/test-sync.yml b/.github/workflows/test-sync.yml index d269a88..b288ce5 100644 --- a/.github/workflows/test-sync.yml +++ b/.github/workflows/test-sync.yml @@ -357,7 +357,7 @@ jobs: run: | mkdir build cd build - cmake .. -G "Visual Studio 17 2022" -DDEV_TEST_SYNC=ON -DDEV_WITH_ASAN=ON + cmake .. -G "Visual Studio 17 2022" -DCMAKE_SYSTEM_VERSION="10.0" -DDEV_TEST_SYNC=ON -DDEV_WITH_ASAN=ON & "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Msbuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Debug p2pool.vcxproj - name: Run p2pool @@ -405,7 +405,7 @@ jobs: run: | mkdir build cd build - cmake .. -G "Visual Studio 17 2022" -DDEV_TEST_SYNC=ON -DDEV_TRACK_MEMORY=ON + cmake .. -G "Visual Studio 17 2022" -DCMAKE_SYSTEM_VERSION="10.0" -DDEV_TEST_SYNC=ON -DDEV_TRACK_MEMORY=ON & "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Msbuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=RelWithDebInfo p2pool.vcxproj - name: Run p2pool diff --git a/cmake/grpc.cmake b/cmake/grpc.cmake index 7483acd..fa517b2 100644 --- a/cmake/grpc.cmake +++ b/cmake/grpc.cmake @@ -36,7 +36,7 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -w") endif() -if (CMAKE_CXX_COMPILER_ID MATCHES MSVC) +if ((CMAKE_C_COMPILER_ID MATCHES MSVC) OR (CMAKE_CXX_COMPILER_ID MATCHES MSVC)) include_directories(external/src/common) endif() diff --git a/external/src/common/sanitizer/asan_interface.h b/external/src/common/sanitizer/asan_interface.h new file mode 100644 index 0000000..ac2e3d7 --- /dev/null +++ b/external/src/common/sanitizer/asan_interface.h @@ -0,0 +1,12 @@ +#ifndef P2POOL_EXTERNAL_SRC_COMMON_SANITIZER_ASAN_INTERFACE_H +#define P2POOL_EXTERNAL_SRC_COMMON_SANITIZER_ASAN_INTERFACE_H + +#ifndef ASAN_POISON_MEMORY_REGION +#define ASAN_POISON_MEMORY_REGION(addr, size) __asan_poison_memory_region((addr), (size)) +#endif + +#ifndef ASAN_UNPOISON_MEMORY_REGION +#define ASAN_UNPOISON_MEMORY_REGION(addr, size) __asan_unpoison_memory_region((addr), (size)) +#endif + +#endif // P2POOL_EXTERNAL_SRC_COMMON_SANITIZER_ASAN_INTERFACE_H diff --git a/external/src/common/stdalign.h b/external/src/common/stdalign.h index 24c73d5..546de36 100644 --- a/external/src/common/stdalign.h +++ b/external/src/common/stdalign.h @@ -1,7 +1,7 @@ #ifndef P2POOL_EXTERNAL_SRC_COMMON_STDALIGN_H #define P2POOL_EXTERNAL_SRC_COMMON_STDALIGN_H -#if !defined(__cplusplus) && defined(_MSC_VER) && (_MSC_VER < 1930) +#if !defined(__cplusplus) && defined(_MSC_VER) #define alignas(x) __declspec(align(x)) #define alignof __alignof #endif