Skip to content

Commit

Permalink
Merge #316: cmake: Amend docs per feedback
Browse files Browse the repository at this point in the history
7c37119 fixup! cmake: Generate `obj/build.h` header (Hennadii Stepanov)
f548661 fixup! doc: Update for CMake-based build system (Hennadii Stepanov)

Pull request description:

  A few amendments to the `fuzzing.md`:
  1. Removed non-portable $(nproc), mirrors the master branch.
  2. Removed stray back slash.
  3. Added a linker workaround for macOS.

  Also a "TODO" prefix has been added to the comment.

ACKs for top commit:
  paplorinc:
    ACK 7c37119

Tree-SHA512: 7acf2dcedfaa592a4fab9e15d65a82cb46efba2e27d4d5f94bb4825665916763d92926756c1731c7364ebe98c809bc6e51620c3a6bb5d3e60d13532571ca0d2c
  • Loading branch information
hebasto committed Aug 10, 2024
2 parents 783a27b + 7c37119 commit 97bc580
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ cmake -B build_fuzz \
-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
$ cmake --build build_fuzz -j$(nproc)
$ cmake --build build_fuzz
$ FUZZ=process_message build_fuzz/src/test/fuzz/fuzz
# abort fuzzing using ctrl-c
```
Expand Down Expand Up @@ -150,6 +150,7 @@ $ cmake -B build_fuzz \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=undefined,address,fuzzer \
-DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries
```
Read the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for more information. This [libFuzzer tutorial](https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md) might also be of interest.
Expand All @@ -171,9 +172,9 @@ $ cmake -B build_fuzz \
-DCMAKE_C_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto" \
-DCMAKE_CXX_COMPILER="$(pwd)/AFLplusplus/afl-clang-lto++" \
-DBUILD_FOR_FUZZING=ON
$ cmake --build build_fuzz -j$(nproc)
$ cmake --build build_fuzz
# 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)`
# try compiling using: AFL_NO_X86=1 cmake --build build_fuzz
$ mkdir -p inputs/ outputs/
$ echo A > inputs/thin-air-input
$ FUZZ=bech32 ./AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- build_fuzz/src/test/fuzz/fuzz
Expand Down Expand Up @@ -201,7 +202,7 @@ $ cmake -B build_fuzz \
-DCMAKE_CXX_COMPILER="$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang++" \
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=address,undefined
$ cmake --build build_fuzz -j$(nproc)
$ cmake --build build_fuzz
$ mkdir -p inputs/
$ FUZZ=process_message ./honggfuzz/honggfuzz -i inputs/ -- build_fuzz/src/test/fuzz/fuzz
```
Expand Down Expand Up @@ -275,7 +276,7 @@ $ cmake -B build_fuzz \
-DENABLE_WALLET=OFF \
-DBUILD_GUI=OFF \
-DSANITIZERS=address,undefined
$ cmake --build build_fuzz --target bitcoind -j$(nproc)
$ cmake --build build_fuzz --target bitcoind
$ mkdir -p inputs/
$ ./honggfuzz/honggfuzz --exit_upon_crash --quiet --timeout 4 -n 1 -Q \
-E HFND_TCP_PORT=18444 -f inputs/ -- \
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ include(AddWindowsResources)
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

# After the transition from Autotools to CMake, the obj/ subdirectory
# could be dropped as its only purpose was to separate a generated header
# from source files.
# TODO: After the transition from Autotools to CMake, the obj/ subdirectory
# could be dropped as its only purpose was to separate a generated header
# from source files.
add_custom_target(generate_build_info
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/obj/build.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/src/obj
Expand Down

0 comments on commit 97bc580

Please sign in to comment.