diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index d27e42c..3ecf560 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -115,8 +115,9 @@ jobs: strategy: matrix: config: - - {os: ubuntu-20.04, c: gcc-11, cpp: g++-11} - - {os: ubuntu-22.04, c: gcc-12, cpp: g++-12} + - {os: ubuntu-20.04, c: gcc-7, cpp: g++-7, flags: "-Wno-lto-type-mismatch"} + - {os: ubuntu-20.04, c: gcc-11, cpp: g++-11, flags: ""} + - {os: ubuntu-22.04, c: gcc-12, cpp: g++-12, flags: ""} steps: - name: Install dependencies @@ -134,7 +135,7 @@ jobs: run: | mkdir build cd build - cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cpp }} -DCMAKE_C_FLAGS='-flto=2' -DCMAKE_CXX_FLAGS='-flto=2' + cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cpp }} -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -flto=2' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -flto=2' make -j$(nproc) - name: Run RandomX tests @@ -147,7 +148,7 @@ jobs: cd tests mkdir build cd build - cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cpp }} -DCMAKE_C_FLAGS='-flto=2' -DCMAKE_CXX_FLAGS='-flto=2' + cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cpp }} -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -flto=2' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -flto=2' make -j$(nproc) - name: Run tests diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 7b81e86..f1520d8 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -1,6 +1,6 @@ -set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) @@ -35,7 +35,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(GENERAL_FLAGS "${GENERAL_FLAGS} -fno-omit-frame-pointer -fsanitize=address") endif() - set(WARNING_FLAGS "-Wall -Wextra -Wcast-qual -Wlogical-op -Wstrict-overflow=2 -Wundef -Wformat=2 -Wpointer-arith -Werror") + set(WARNING_FLAGS "-Wall -Wextra -Wcast-qual -Wlogical-op -Wundef -Wformat=2 -Wpointer-arith -Werror") + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.5.0) + set(WARNING_FLAGS "${WARNING_FLAGS} -Wstrict-overflow=2") + endif() if (DEV_WITH_TSAN OR DEV_WITH_UBSAN OR DEV_WITH_ASAN) set(OPTIMIZATION_FLAGS "-Og -g") diff --git a/cppcheck/run.cmd b/cppcheck/run.cmd index fa96b95..12875bf 100644 --- a/cppcheck/run.cmd +++ b/cppcheck/run.cmd @@ -1,5 +1,5 @@ @echo off -"..\cppcheck-main\bin\cppcheck.exe" --project=..\build\p2pool.vcxproj --project-configuration="Release|x64" -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN --platform=win64 --std=c++14 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt +"..\cppcheck-main\bin\cppcheck.exe" --project=..\build\p2pool.vcxproj --project-configuration="Release|x64" -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN --platform=win64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt findstr /V /C:"external\src" errors_full.txt > errors_filtered0.txt findstr /V /C:":checkersReport" errors_filtered0.txt > errors_filtered.txt for /f %%i in ("errors_filtered.txt") do set size=%%~zi diff --git a/cppcheck/run.sh b/cppcheck/run.sh index e4ad949..1bd54a7 100755 --- a/cppcheck/run.sh +++ b/cppcheck/run.sh @@ -1,5 +1,5 @@ #!/bin/bash -../cppcheck-main/cppcheck --project=../build/compile_commands.json -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D__SSE2__=1 --platform=unix64 --std=c++14 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt +../cppcheck-main/cppcheck --project=../build/compile_commands.json -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D__SSE2__=1 --platform=unix64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt grep -v 'external' errors_full.txt > errors_filtered0.txt grep -v ':checkersReport' errors_filtered0.txt > errors_filtered.txt if [ -s errors_filtered.txt ]; then diff --git a/external/src/RandomX b/external/src/RandomX index 7b1e4df..121f6dd 160000 --- a/external/src/RandomX +++ b/external/src/RandomX @@ -1 +1 @@ -Subproject commit 7b1e4df779cae4eb0a33e74fc292b94158d7f69f +Subproject commit 121f6dda58e6b3d0bc428f0dede1a11728acd8fe diff --git a/src/util.h b/src/util.h index d58385e..74dd9e8 100644 --- a/src/util.h +++ b/src/util.h @@ -19,7 +19,7 @@ #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable : 4623 5026 5027) +#pragma warning(disable : 4623 5026 5027 5262) #endif #define ROBIN_HOOD_MALLOC(size) p2pool::malloc_hook(size) @@ -60,27 +60,15 @@ struct nocopy_nomove }; template -struct ScopeGuard +struct ScopeGuard : public nocopy_nomove { explicit FORCEINLINE ScopeGuard(T&& handler) : m_handler(std::move(handler)) {} FORCEINLINE ~ScopeGuard() { m_handler(); } T m_handler; - - // Disable copying/moving of ScopeGuard objects - - // We can't declare copy constructor as explicitly deleted because of copy elision semantics - // Just leave it without definition and it'll fail when linking if someone tries to copy a ScopeGuard object - ScopeGuard(const ScopeGuard&); - -private: - ScopeGuard& operator=(const ScopeGuard&) = delete; - ScopeGuard& operator=(ScopeGuard&&) = delete; }; -template FORCEINLINE ScopeGuard on_scope_leave(T&& handler) { return ScopeGuard(std::move(handler)); } - -#define ON_SCOPE_LEAVE(...) auto CONCAT(scope_guard_, __LINE__) = on_scope_leave(__VA_ARGS__); +#define ON_SCOPE_LEAVE(...) auto CONCAT(scope_guard_, __LINE__) = ScopeGuard{ __VA_ARGS__ }; struct MinerCallbackHandler { diff --git a/tests/cmake/flags.cmake b/tests/cmake/flags.cmake index dd283a7..47f201a 100644 --- a/tests/cmake/flags.cmake +++ b/tests/cmake/flags.cmake @@ -1,6 +1,6 @@ -set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON)