Skip to content

Commit

Permalink
CMake: added DEV_DEBUG option
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Oct 29, 2024
1 parent c9193c5 commit 3c4cf09
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ jobs:
strategy:
matrix:
config:
- {os: macos-13, flags: "-Og -ftrapv"}
- {os: macos-14, flags: "-Og -ftrapv -target arm64-apple-macos-11"}
- {os: macos-13, flags: ""}
- {os: macos-14, flags: "-target arm64-apple-macos-11"}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -312,7 +312,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@15)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@15)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@15)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@15)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DDEV_TEST_SYNC=ON
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@15)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@15)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@15)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@15)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DDEV_TEST_SYNC=ON -DDEV_DEBUG=ON
make -j4 p2pool
- name: Run p2pool
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ option(DEV_WITH_UBSAN "[Developer only] Compile with undefined behavior sanitize
option(DEV_WITH_ASAN "[Developer only] Compile with address sanitizer" OFF)
option(DEV_CLANG_TIDY "[Developer only] Compile for clang-tidy" OFF)
option(DEV_TRACK_MEMORY "[Developer only] Track memory allocations" OFF)
option(DEV_DEBUG "[Developer only] Compile a debug build" OFF)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool)

Expand Down Expand Up @@ -83,6 +84,10 @@ if (DEV_TRACK_MEMORY)
add_definitions(-DDEV_TRACK_MEMORY)
endif()

if (DEV_DEBUG)
add_definitions(-DDEV_DEBUG)
endif()

include(cmake/flags.cmake)

set(HEADERS
Expand Down
8 changes: 4 additions & 4 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(WARNING_FLAGS "-w")
endif()

if (DEV_WITH_TSAN OR DEV_WITH_UBSAN OR DEV_WITH_ASAN)
set(OPTIMIZATION_FLAGS "-Og -g")
if (DEV_WITH_TSAN OR DEV_WITH_UBSAN OR DEV_WITH_ASAN OR DEV_DEBUG)
set(OPTIMIZATION_FLAGS "-Og -g -ftrapv")
else()
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -s")
endif()
Expand Down Expand Up @@ -99,8 +99,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(WARNING_FLAGS "-w")
endif()

if (DEV_WITH_MSAN)
set(OPTIMIZATION_FLAGS "-Og -g")
if (DEV_WITH_MSAN OR DEV_DEBUG)
set(OPTIMIZATION_FLAGS "-Og -g -ftrapv")
else()
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -fmerge-all-constants")
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#define __has_feature(x) 0
#endif

#if defined(_DEBUG) || defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) || defined(__SANITIZE_THREAD__) || __has_feature(thread_sanitizer)
#if defined(_DEBUG) || defined(DEV_DEBUG) || defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) || defined(__SANITIZE_THREAD__) || __has_feature(thread_sanitizer)
#define P2POOL_DEBUGGING 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/pool_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "uv_util.h"
#include "wallet.h"

#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEV_DEBUG)
#define POOL_BLOCK_DEBUG 1
#else
#define POOL_BLOCK_DEBUG 0
Expand Down

0 comments on commit 3c4cf09

Please sign in to comment.