Fixes: #31049
Updates the instructions for fuzzing on macOS to use lld
instead of ld
.
Tested instructions on M1 Mac running 14.6.1
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31954.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | l0rinc, brunoerg, hebasto |
Concept ACK | jonatack |
Stale ACK | Prabhat1308 |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Running the build after these configurations on MacOs 15.3.1 M4 Pro, the fuzz tests are running but I do get these warnings on almost every object being built . Is this expected ?
04 warnings generated.
1[ 12%] Linking CXX static library libbitcoin_cli.a
24 warnings generated.
3[ 12%] Building CXX object src/test/fuzz/util/CMakeFiles/test_fuzz.dir/net.cpp.o
4[ 12%] Built target bitcoin_cli
5[ 12%] Building CXX object src/CMakeFiles/bitcoin_common.dir/base58.cpp.o
6clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
7clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
8warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
9warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
10warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
11warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
124 warnings generated.
13clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
14clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
15warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
16warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
17warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
18warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
19[ 13%] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/primitives/block.cpp.o
20clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
21clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
22warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
23warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
24warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
25warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
264 warnings generated.
27[ 14%] Linking CXX static library libunivalue.a
284 warnings generated.
29[ 14%] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/primitives/transaction.cpp.o
30clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
31clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
32warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
33warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
34warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
35warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
36[ 14%] Built target univalue
37[ 14%] Building CXX object src/test/util/CMakeFiles/test_util.dir/setup_common.cpp.o
38clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
39clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
40warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
41warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
42warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
43warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
444 warnings generated.
45[ 15%] Linking CXX static library libbitcoin_clientversion.a
464 warnings generated.
47[ 15%] Built target bitcoin_clientversion
48[ 15%] Building CXX object src/crypto/CMakeFiles/bitcoin_crypto.dir/ripemd160.cpp.o
49[ 15%] Building CXX object CMakeFiles/leveldb.dir/src/leveldb/db/log_writer.cc.o
50clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
51clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
52warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
53warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
54warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
55warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
56clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
57clang++: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
58warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
59warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
60warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
61warning: unknown warning option '-Wbidi-chars=any' [-Wunknown-warning-option]
624 warnings generated.
634 warnings generated.
152@@ -153,13 +153,18 @@ You may also need to take care of giving the correct path for `clang` and
153 `clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
154 `clang` does not come first in your path.
155
156+Currently the default linker on macOS `ld` does not work with recent versions of `llvm` so you will need to install llvm's linker `lld` and use it with the CXX_FLAG `-fuse-ld=lld`.
ld
issue - not critical
157+
158 Full configuration step that was tested on macOS with `brew` installed `llvm`:
159
160 ```sh
161+$ brew install llvm
162+$ brew install lld
we can likely do this in a single command:
0$ brew install llvm lld
We also likely need to remove the command from https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md?plain=1#L150 now
152@@ -153,13 +153,18 @@ You may also need to take care of giving the correct path for `clang` and
153 `clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
154 `clang` does not come first in your path.
155
156+Currently the default linker on macOS `ld` does not work with recent versions of `llvm` so you will need to install llvm's linker `lld` and use it with the CXX_FLAG `-fuse-ld=lld`.
157+
158 Full configuration step that was tested on macOS with `brew` installed `llvm`:
This seems to need an update - though I’d just remove the command from the comment:
0Full configuration steps:
163 $ cmake --preset=libfuzzer \
164 -DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
165 -DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
166- -DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries
167+ -DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries \
168+ -DCMAKE_CXX_FLAGS="-fuse-ld=lld"
I’m getting:
clang++: warning: argument unused during compilation: ‘-fuse-ld=lld’ [-Wunused-command-line-argument]
Concept ACK
Finally fuzzing is working with these changes (tested on M4 Max with Clang 19.1.7), but we’re still getting warnings - and a I left a few more suggestions
152@@ -153,13 +153,17 @@ You may also need to take care of giving the correct path for `clang` and
153 `clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
154 `clang` does not come first in your path.
155
156-Full configuration step that was tested on macOS with `brew` installed `llvm`:
157+Currently the default linker on macOS `ld` does not work with recent versions of `llvm` so you will need to install llvm's linker `lld` and use it with the CMAKE_EXE_LINKER_FLAG `-fuse-ld=lld`.
158+
159+Full configuration step for macOS:
It’s not exactly full, we still need:
0$ cmake --build build_fuzz -j$(nproc)
1$ FUZZ=process_message build_fuzz/src/test/fuzz/fuzz
tACK 725c0fd
-Checked by running the fuzz tests on several fuzz targets . No warnings displayed now.
162+$ brew install llvm lld
163 $ cmake --preset=libfuzzer \
164 -DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
165 -DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
166- -DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries
167+ -DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries \
no_warn_duplicate_libraries
isn’t an lld option, so this can be dropped.
152@@ -153,13 +153,17 @@ You may also need to take care of giving the correct path for `clang` and
153 `clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
154 `clang` does not come first in your path.
155
156-Full configuration step that was tested on macOS with `brew` installed `llvm`:
157+Currently the default linker on macOS `ld` does not work with recent versions of `llvm` so you will need to install llvm's linker `lld` and use it with the CMAKE_EXE_LINKER_FLAG `-fuse-ld=lld`.
ld
and LLVM”.
152@@ -153,13 +153,16 @@ You may also need to take care of giving the correct path for `clang` and
153 `clang++`, like `CC=/path/to/clang CXX=/path/to/clang++` if the non-systems
154 `clang` does not come first in your path.
155
156-Full configuration step that was tested on macOS with `brew` installed `llvm`:
157+Using lld is required to due to issues with Apples ld and LLVM.
Typo, maybe something like:
0Using `lld` is required due to issues with Apple's `ld` and `LLVM`.
gah, taken!
Thanks for the spot.
Default linker on macOS does not work with recent versions of LLVM. Updated the instructions for fuzzing to use lld instead.
ACK 75486c8ed87a480b9f0c4dc7a10f3cd4eee87b12
Compared to previous review, APPEND_LDFLAGS
was removed and the description simplified to avoid repetition.
ACK 75486c8ed87a480b9f0c4dc7a10f3cd4eee87b12
I just tested it on macOS 14.3 and worked fine.
tACK 75486c8ed87a480b9f0c4dc7a10f3cd4eee87b12
Managed to reproduce the issue in master
(before merge) and this PR fixes it.
Post-merge tested ACK using the following incantation with arm64 macos 15.3.1:
0$ rm -rf ./build_fuzz/ && cmake -B ./build_fuzz -DAPPEND_CXXFLAGS="-std=c++23" --preset=libfuzzer -DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" && cmake --build ./build_fuzz --parallel 11 --
1
2$ FUZZ=process_message ./build_fuzz/src/test/fuzz/fuzz