From aac92ac7b3da9eacc7b9e21acb6936061d6e565b Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Wed, 25 Sep 2024 08:52:35 +0200 Subject: [PATCH 1/2] improve debugging flags --- crypto3/CMakeLists.txt | 5 +++-- evm-assigner/lib/assigner/CMakeLists.txt | 5 +++-- parallel-crypto3/CMakeLists.txt | 5 +++-- proof-producer/CMakeLists.txt | 5 +++-- transpiler/CMakeLists.txt | 5 +++-- zkevm-framework/CMakeLists.txt | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/crypto3/CMakeLists.txt b/crypto3/CMakeLists.txt index f2a775346f..0d3efb2b89 100644 --- a/crypto3/CMakeLists.txt +++ b/crypto3/CMakeLists.txt @@ -23,8 +23,9 @@ option(BUILD_BENCH_TESTS "Build performance benchmark tests" FALSE) option(BUILD_DOCS "Build with configuring Doxygen documentation compiler" FALSE) option(SANITIZE "Build sanitizers" FALSE) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() if(${SANITIZE}) diff --git a/evm-assigner/lib/assigner/CMakeLists.txt b/evm-assigner/lib/assigner/CMakeLists.txt index 89d54eb966..48e81757d1 100644 --- a/evm-assigner/lib/assigner/CMakeLists.txt +++ b/evm-assigner/lib/assigner/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR) option(BUILD_ASSIGNER_TESTS "Build unit tests" FALSE) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() set(evmone_sources diff --git a/parallel-crypto3/CMakeLists.txt b/parallel-crypto3/CMakeLists.txt index 3921bd0223..bed6462618 100644 --- a/parallel-crypto3/CMakeLists.txt +++ b/parallel-crypto3/CMakeLists.txt @@ -3,8 +3,9 @@ project(parallel-crypto3) find_package(CM) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() # This is useful due to some build systems (Ninja in particular) are piping diff --git a/proof-producer/CMakeLists.txt b/proof-producer/CMakeLists.txt index d958071845..e5cbd3b225 100644 --- a/proof-producer/CMakeLists.txt +++ b/proof-producer/CMakeLists.txt @@ -10,9 +10,10 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(ZK_PLACEHOLDER_DEBUG_ENABLED TRUE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() find_package(CM REQUIRED) diff --git a/transpiler/CMakeLists.txt b/transpiler/CMakeLists.txt index 738b84eae1..160653dddd 100644 --- a/transpiler/CMakeLists.txt +++ b/transpiler/CMakeLists.txt @@ -12,8 +12,9 @@ find_package(CM REQUIRED) include(CMConfig) include(CMSetupVersion) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() cm_workspace(crypto3) diff --git a/zkevm-framework/CMakeLists.txt b/zkevm-framework/CMakeLists.txt index b3ae9dba09..f739039e8b 100644 --- a/zkevm-framework/CMakeLists.txt +++ b/zkevm-framework/CMakeLists.txt @@ -10,8 +10,9 @@ include(GNUInstallDirs) option(BUILD_DOCS "Build documentation" FALSE) option(ENABLE_TESTS "Enable tests" FALSE) -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "-ggdb -O0") +if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") + set(BOOST_FORCEINLINE "OFF") # improves debugging traces endif() add_subdirectory(libs) From 9bfaf7e434b1f0d406a46a3b1071fcc3c4e38ad5 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Wed, 25 Sep 2024 09:32:40 +0200 Subject: [PATCH 2/2] protect find_msb from passing 0 --- .../include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp index 938814bca6..ccc79be072 100644 --- a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp +++ b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp @@ -148,6 +148,8 @@ namespace boost { return i * cpp_int_modular_backend::limb_bits + boost::multiprecision::detail::find_msb(a.limbs()[i]); } + if (a.limbs()[0] == 0) // TODO here should assert/throw + return 1024; // Some big number to indicate that there is no bit 1 return boost::multiprecision::detail::find_msb(a.limbs()[0]); }