<p>If you have access to a Linux machine/VM you should probably do fuzzing on that rather than MacOS. It is likely you will need to do more troubleshooting getting set up on MacOS. However, people have got fuzzing working on MacOS e.g. robot-dreams during this Bitcoin Core PR review club <a href="https://bitcoincore.reviews/18521#l-164" rel="nofollow noreferrer">session</a> on fuzz testing:</p>
<blockquote>
<p>I was able to get things work by following the &quot;macOS hints for libFuzzer&quot;, but I had to remove the <code>--disable-asm</code> flag when running <code>./configure</code></p>
</blockquote>
<p>In addition brakmic has some additional <a href="https://github.com/bitcoin/bitcoin/issues/17657#issuecomment-562869600" rel="nofollow noreferrer">guidance</a> for those trying to get set up on MacOS:</p>
<blockquote>
<ul>
<li>Take care of having an LLVM/Clang environment that contains fuzzing libraries. The default one from Apple is not enough, so that you will have to install it with brew, if not already done.</li>
<li>When executing ./configure you should put --disable-asm to avoid errors with certain assembly code from Bitcoin Core's code. There's an entry about it here and it seems to have something to do with sanitizers you have to compile for fuzzing.</li>
<li>Take care of giving the correct path for clang and clang++, like CC=/path/to/clang CXX=/path/to/clang++</li>
<li>If you run into problems with &quot;boost sleep&quot; or some of boost's libraries can't be found, like boost.thread or boost.filesystem, add this to your configure:</li>
</ul>
</blockquote>
<pre><code>CXXFLAGS=&quot;-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk&quot;
</code></pre>
<blockquote>
<p>Notice: I am using Catalina 10.15.1, so your SDK might be different and you should adapt the path accordingly.
Here's my complete configure, just in case.</p>
</blockquote>
<pre><code>./configure --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address,undefined --with-boost CPPFLAGS=&quot;-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include&quot; CXXFLAGS=&quot;-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk&quot; CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ LDFLAGS=&quot;-L/usr/local/lib/darwin/&quot; --disable-asm
</code></pre>
<p>On the benefit to the Bitcoin Core project overall, I would say the greatest benefit would be onboarding fuzz testers and reviewers of the various fuzzing PRs as quickly as possible. Unit tests and functional tests need to pass on various operating systems but the ultimate aim of fuzz testing is examining for edge cases, the majority of which won't be dependent on the operating system. So whatever will get you up and running the quickest is the optimal approach.</p>

CC BY-SA 4.0
2020-11-11T11:15:04.060Z
2020-11-11T11:55:11.447Z
2020-11-11T11:55:11.447Z
Michael Folkson
<p>The Bitcoin Core fuzzing <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer" rel="nofollow noreferrer">docs</a> contain some hints for getting fuzz testing working on MacOS. But if I have access to a Linux machine/VM should I stick to doing all fuzzing on Linux? I'm assuming there is no little benefit to the project as a whole that people are fuzzing on different operating systems (other than expanding the number of people fuzzing Bitcoin Core).</p>

<bitcoin-core-development><testing><bitcoincore-review><fuzz-test>
Should I try to get fuzz testing working on MacOS or should I stick to Linux?
Michael Folkson
# Should I try to get fuzz testing working on MacOS or should I stick to Linux?

(Asked by: username_0 on 2020-11-11)

The Bitcoin Core fuzzing [docs](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer) contain some hints for getting fuzz testing working on MacOS. But if I have access to a Linux machine/VM should I stick to doing all fuzzing on Linux? I'm assuming there is no little benefit to the project as a whole that people are fuzzing on different operating systems (other than expanding the number of people fuzzing Bitcoin Core).

**Tags:** bitcoin-core-development, testing, bitcoincore-review, fuzz-test


---

## 1 answers

### Answer by username_0 on 2020-11-11. Score: 0 | Accepted answer

If you have access to a Linux machine/VM you should probably do fuzzing on that rather than MacOS. It is likely you will need to do more troubleshooting getting set up on MacOS. However, people have got fuzzing working on MacOS e.g. robot-dreams during this Bitcoin Core PR review club [session](https://bitcoincore.reviews/18521#l-164) on fuzz testing:

> I was able to get things work by following the "macOS hints for libFuzzer", but I had to remove the `--disable-asm` flag when running `./configure`

In addition brakmic has some additional [guidance](https://github.com/bitcoin/bitcoin/issues/17657#issuecomment-562869600) for those trying to get set up on MacOS:

> * Take care of having an LLVM/Clang environment that contains fuzzing libraries. The default one from Apple is not enough, so that you will have to install it with brew, if not already done.
> * When executing ./configure you should put --disable-asm to avoid errors with certain assembly code from Bitcoin Core's code. There's an entry about it here and it seems to have something to do with sanitizers you have to compile for fuzzing.
> * Take care of giving the correct path for clang and clang++, like CC=/path/to/clang CXX=/path/to/clang++
> * If you run into problems with "boost sleep" or some of boost's libraries can't be found, like boost.thread or boost.filesystem, add this to your configure:

```
CXXFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk"

```

> Notice: I am using Catalina 10.15.1, so your SDK might be different and you should adapt the path accordingly.
> Here's my complete configure, just in case.

```
./configure --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address,undefined --with-boost CPPFLAGS="-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" CXXFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk" CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ LDFLAGS="-L/usr/local/lib/darwin/" --disable-asm

```

On the benefit to the Bitcoin Core project overall, I would say the greatest benefit would be onboarding fuzz testers and reviewers of the various fuzzing PRs as quickly as possible. Unit tests and functional tests need to pass on various operating systems but the ultimate aim of fuzz testing is examining for edge cases, the majority of which won't be dependent on the operating system. So whatever will get you up and running the quickest is the optimal approach.


---

