Skip to content

Commit

Permalink
build: rename ENABLE_FUZZ to BUILD_FOR_FUZZING
Browse files Browse the repository at this point in the history
The name `ENABLE_FUZZ` is confusing because that option
does not enable fuzzing. `-DSANITIZERS=fuzzer` is what
enables fuzzing.

Fixes: bitcoin#30318
  • Loading branch information
vasild authored and hebasto committed Jul 24, 2024
1 parent f02f514 commit 8853a2e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ endif()

option(BUILD_BENCH "Build bench_bitcoin executable." OFF)
option(BUILD_FUZZ_BINARY "Build fuzz binary." OFF)
cmake_dependent_option(ENABLE_FUZZ "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)
cmake_dependent_option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)

option(INSTALL_MAN "Install man pages." ON)

Expand Down Expand Up @@ -219,8 +219,8 @@ target_link_libraries(core_interface INTERFACE
$<$<CONFIG:Debug>:core_interface_debug>
)

if(ENABLE_FUZZ)
message(WARNING "ENABLE_FUZZ=ON will disable all other targets and force BUILD_FUZZ_BINARY=ON.")
if(BUILD_FOR_FUZZING)
message(WARNING "BUILD_FOR_FUZZING=ON will disable all other targets and force BUILD_FUZZ_BINARY=ON.")
set(BUILD_DAEMON OFF)
set(BUILD_CLI OFF)
set(BUILD_TX OFF)
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export RUN_FUZZ_TESTS=true
export GOAL="install"
export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the container needs access to ptrace (https://github.com/google/sanitizers/issues/764)
export BITCOIN_CONFIG="\
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=fuzzer,address,undefined,float-divide-by-zero,integer \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_fuzz_with_msan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FL
export GOAL="install"
# _FORTIFY_SOURCE is not compatible with MSAN.
export BITCOIN_CONFIG="\
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=fuzzer,memory \
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE' \
"
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_fuzz_with_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export RUN_FUZZ_TESTS=true
export FUZZ_TESTS_CONFIG="--valgrind"
export GOAL="install"
export BITCOIN_CONFIG="\
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=fuzzer \
-DCMAKE_C_COMPILER=clang-16 \
-DCMAKE_CXX_COMPILER=clang++-16 \
Expand Down
10 changes: 5 additions & 5 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ cd bitcoin/
$ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_CXX_COMPILER="clang++" \
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=undefined,address,fuzzer
# macOS users: If you have problem with this step then make sure to read "macOS hints for
# libFuzzer" on https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer
Expand Down Expand Up @@ -148,7 +148,7 @@ Full configuration step that was tested on macOS with `brew` installed `llvm`:
$ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=undefined,address,fuzzer \
```
Expand All @@ -170,7 +170,7 @@ $ make -C AFLplusplus/ source-only
$ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto" \
-DCMAKE_CXX_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto++" \
-DENABLE_FUZZ=ON
-DBUILD_FOR_FUZZING=ON
$ cmake --build build_fuzz -j$(nproc)
# For macOS you may need to ignore x86 compilation checks when running "cmake --build". If so,
# try compiling using: `AFL_NO_X86=1 cmake --build build_fuzz -j$(nproc)`
Expand Down Expand Up @@ -199,7 +199,7 @@ $ cd ..
$ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang" \
-DCMAKE_CXX_COMPILER="$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang++" \
-DENABLE_FUZZ=ON \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=address,undefined
$ cmake --build build_fuzz -j$(nproc)
$ mkdir -p inputs/
Expand Down Expand Up @@ -319,7 +319,7 @@ $ cd Eclipser
$ git checkout v1.x
$ make
$ cd ..
$ cmake -B build_fuzz -DENABLE_FUZZ=ON
$ cmake -B build_fuzz -DBUILD_FOR_FUZZING=ON
$ mkdir -p outputs/
$ FUZZ=bech32 dotnet ./Eclipser/build/Eclipser.dll fuzz -p build_fuzz/src/test/fuzz/fuzz -t 36000 -o outputs --src stdin
```
Expand Down

0 comments on commit 8853a2e

Please sign in to comment.