Merge bitcoin/bitcoin#31954: doc: update fuzz instructions when on macOS

75486c8ed8 doc: update fuzz instructions when on macOS (Max Edwards)

Pull request description:

  Fixes: #31049

  Updates the instructions for fuzzing on macOS to use `lld` instead of `ld`.

  Tested instructions on M1 Mac running 14.6.1

ACKs for top commit:
  l0rinc:
    ACK 75486c8ed8
  brunoerg:
    ACK 75486c8ed8
  hebasto:
    ACK 75486c8ed8, tested on macOS 15.3.1 (Apple M1) + Clang 19.1.7.

Tree-SHA512: 2c5645d78fce1644964dee55c8ca6a6549bfd4f4a9a5719bbe49264f7216f0267c27999e23402a47eecbc8502985d812b986bf6850a5d63d110bdb98769f23c2
This commit is contained in:
Hennadii Stepanov 2025-03-05 14:31:07 +00:00
commit 0c0a2717bc
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -153,13 +153,16 @@ You may also need to take care of giving the correct path for `clang` and
`clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
`clang` does not come first in your path.
Full configuration step that was tested on macOS with `brew` installed `llvm`:
Using `lld` is required due to issues with Apple's `ld` and `LLVM`.
Full configuration step for macOS:
```sh
$ brew install llvm lld
$ cmake --preset=libfuzzer \
-DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
-DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld"
```
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.