1

When compiling with the -fsanitize=fuzzer flag to include libfuzzer in LLVM on macOS, I get the error:

libclang_rt.fuzzer_osx.a is not found

The LLVM/clang compiler I'm using is bundled with Xcode, 14.0.3.

anthony shaw
  • 133
  • 11

1 Answers1

1

The issue is that the version of Clang bundled with LLVM in Xcode excludes libfuzzer.

There are two solutions to this problem:

  1. Install a version of LLVM from homebrew (brew install llvm)
  2. Download the full bundle of LLVM from https://github.com/llvm/llvm-project/releases matching the version installed in Xcode. Extract the archive and copy all libclang_rt.fuzzer* files from the archive's lib/darwin directory into the Xcode path for the libraries - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin
anthony shaw
  • 133
  • 11
  • Ré option 2: I found this answer https://stackoverflow.com/a/46259269/795690 helpful for working out which version of LLVM I actually have; also FWIW the path to copy to, if using only Command Line Tools is something like `/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/lib/darwin` (depending on version). Thank you! – MikeBeaton May 08 '23 at 18:18