Skip to content

Commit 27a16a1

Browse files
authored
build: Add option to force assertions (#1474)
Add CMake option `-DASSERTIONS=ON` to force-enable assertions in code. Use this for CI sanitizer builds.
1 parent fabed90 commit 27a16a1

2 files changed

Lines changed: 39 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ endif()
1010

1111
option(BUILD_SHARED_LIBS "Build evmone as a shared library" ON)
1212
option(COVERAGE "Build with coverage instrumentation" OFF)
13+
option(ASSERTIONS "Force enable the assertions in the code ignoring the CMAKE_BUILD_TYPE default" OFF)
1314
option(EVMONE_TESTING "Build tests and test tools" OFF)
1415
option(EVMONE_FUZZING "Instrument libraries and build fuzzing tools" OFF)
1516

@@ -91,6 +92,18 @@ if(COVERAGE)
9192
)
9293
endif()
9394

95+
if(ASSERTIONS)
96+
if(CMAKE_CONFIGURATION_TYPES)
97+
message(FATAL_ERROR "ASSERTIONS option is not supported with multi-configuration generators")
98+
endif()
99+
# Remove -DNDEBUG from default build type flags.
100+
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
101+
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
102+
foreach(LANG IN LISTS ENABLED_LANGUAGES)
103+
string(REGEX REPLACE " *-DNDEBUG" "" CMAKE_${LANG}_FLAGS_${BUILD_TYPE_UPPER} "${CMAKE_${LANG}_FLAGS_${BUILD_TYPE_UPPER}}")
104+
endforeach()
105+
endif()
106+
94107
set(CMAKE_C_VISIBILITY_PRESET hidden)
95108
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
96109
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

circle.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,26 @@ commands:
148148
curl -L --retry 3 -C - --output-dir /tmp -O https://github.com/<<parameters.repo>>/releases/download/<<parameters.release>>/fixtures_<<parameters.fixtures_suffix>>.tar.gz
149149
tar -xzf /tmp/fixtures_*.tar.gz
150150
ls -l
151+
run_execution_spec_tests:
152+
steps:
153+
- download_execution_spec_tests:
154+
release: v5.4.0
155+
# develop includes stable
156+
fixtures_suffix: develop
157+
- run:
158+
name: "Execution spec tests (develop, state_tests)"
159+
# Tests for in-development EVM revision currently passing.
160+
working_directory: ~/build
161+
command: >
162+
LLVM_PROFILE_FILE=state_tests.profraw
163+
bin/evmone-statetest ~/spec-tests/fixtures/state_tests
164+
- run:
165+
name: "Execution spec tests (develop, blockchain_tests)"
166+
# Tests for in-development EVM revision currently passing.
167+
working_directory: ~/build
168+
command: >
169+
LLVM_PROFILE_FILE=blockchain_tests.profraw
170+
bin/evmone-blockchaintest ~/spec-tests/fixtures/blockchain_tests
151171
152172
build:
153173
description: "Build"
@@ -392,24 +412,7 @@ jobs:
392412
CMAKE_OPTIONS: -DCOVERAGE=1
393413
steps:
394414
- build
395-
- download_execution_spec_tests:
396-
release: v5.4.0
397-
# develop includes stable
398-
fixtures_suffix: develop
399-
- run:
400-
name: "Execution spec tests (develop, state_tests)"
401-
# Tests for in-development EVM revision currently passing.
402-
working_directory: ~/build
403-
command: >
404-
LLVM_PROFILE_FILE=state_tests.profraw
405-
bin/evmone-statetest ~/spec-tests/fixtures/state_tests
406-
- run:
407-
name: "Execution spec tests (develop, blockchain_tests)"
408-
# Tests for in-development EVM revision currently passing.
409-
working_directory: ~/build
410-
command: >
411-
LLVM_PROFILE_FILE=blockchain_tests.profraw
412-
bin/evmone-blockchaintest ~/spec-tests/fixtures/blockchain_tests
415+
- run_execution_spec_tests
413416
- collect_coverage_clang:
414417
ignore_filename_regex: lib/evmone/(advanced|cpu_check|eof|lru_cache|tracing|vm)|test/(experimental|t8n|unittests|utils)
415418
binaries: evmone-statetest evmone-blockchaintest
@@ -534,6 +537,7 @@ jobs:
534537
executor: linux-gcc-multilib
535538
environment:
536539
TOOLCHAIN: cxx17-32bit
540+
CMAKE_OPTIONS: -DASSERTIONS=ON
537541
steps:
538542
- build
539543
- test
@@ -542,11 +546,12 @@ jobs:
542546
executor: linux-clang-selfhosted
543547
environment:
544548
TOOLCHAIN: clang-libcxx-debug
545-
CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=NO -DSANITIZE=address,undefined,shift-exponent,implicit-conversion,nullability
549+
CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=NO -DASSERTIONS=ON -DSANITIZE=address,undefined,shift-exponent,implicit-conversion,nullability
546550
UBSAN_OPTIONS: halt_on_error=1
547551
steps:
548552
- build
549553
- test
554+
- run_execution_spec_tests
550555

551556
clang-tidy:
552557
executor: linux-clang-selfhosted
@@ -576,7 +581,7 @@ jobs:
576581
executor: linux-clang-selfhosted
577582
environment:
578583
CMAKE_GENERATOR: Ninja
579-
CMAKE_OPTIONS: -DEVMONE_FUZZING=ON
584+
CMAKE_OPTIONS: -DASSERTIONS=ON -DEVMONE_FUZZING=ON
580585
steps:
581586
- build
582587
- restore_cache:
@@ -597,7 +602,7 @@ jobs:
597602
executor: macos
598603
environment:
599604
BUILD_TYPE: RelWithDebInfo
600-
CMAKE_OPTIONS: -DSANITIZE=address,undefined
605+
CMAKE_OPTIONS: -DASSERTIONS=ON -DSANITIZE=address,undefined
601606
TESTS_FILTER: unittests
602607
steps:
603608
- run:

0 commit comments

Comments
 (0)