libclang_rt.fuzzer_osx.a is not found on macOS

475 Views Asked by At

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.

1

There are 1 best solutions below

1
anthony shaw On

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