clangllvmfuzzing

Clang showing compiler error with fuzzer argument


I am trying to experiment with libFuzzer library and going through the toy-example[1].

keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ cat Fuzzme.cpp 
#include <stdint.h>
#include <stddef.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  if (size > 0 && data[0] == 'H')
    if (size > 1 && data[1] == 'I')
       if (size > 2 && data[2] == '!')
       __builtin_trap();
  return 0;
}

keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ clang++ -fsanitize=address,fuzzer Fuzzme.cpp 
ld: file not found: /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.fuzzer_osx.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)

keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ clang++ --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

A quick Google search showed me this [2], but other than that I could not find any meaningful information to resolve it, hence posting here. Could some one please tell me how to solve this ? Thanks in advance.

[1] http://llvm.org/docs/LibFuzzer.html#toy-example
[2] https://bugs.llvm.org/show_bug.cgi?id=39794


Solution

  • As you have noticed, there is no fuzzer runtime shipped with Apple developer tools. So you'd either report this issue to Apple folks, or build the runtime library by yourself from the sources (or both).