[cfe-dev] Build issues when trying to use LibFuzzer on Mac OS X

Kostya Serebryany kcc at google.com
Tue Jul 7 22:47:22 PDT 2015


As I've just replied in another thread:

libFuzzer was also never tested on Mac, but I think it should be trivial to
make it work there.
I suspect that the errors you see are caused by the weak function
declarations which don't (???) work on Mac.
You'll need to #ifdef the weak functions on Mac somehow. Patches and Mac
buildbots are welcome :)

--kcc

On Mon, Jun 1, 2015 at 8:52 AM, Jack Howarth <
howarth.mailing.lists at gmail.com> wrote:

> Marshall,
>       From cmake/config-ix.cmake in compiler-rt. it appears that the
> Fuzzer support may be Linux only at the moment...
>
> if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND
>     OS_NAME MATCHES "Linux")
>   set(COMPILER_RT_HAS_DFSAN TRUE)
> else()
>   set(COMPILER_RT_HAS_DFSAN FALSE)
> endif()
>
>           Jack
>
> On Mon, Jun 1, 2015 at 11:36 AM, Marshall Clow <mclow.lists at gmail.com>
> wrote:
> > I'm trying to use LibFuzzer on my Mac - following the directions here:
> > http://llvm.org/docs/LibFuzzer.html.
> >
> > But when I try to link my program and the Fuzzer object code, I get
> errors.
> >
> > They appear to be symbols from compiler-rt that are missing.
> > Do I need a better (i.e, more recent) compiler-rt than the one that Apple
> > ships?
> >
> >
> > Notes:
> > "totclang" --> freshly built clang.
> >
> > $ export FUZZER=$LLVM/llvm/lib/Fuzzer
> >
> > $ cd ~/fuzz
> > $ cat regex_fuzz.cpp
> > #include <regex>
> >
> > extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data, size_t
> > size) {
> >   if (size > 0) {
> >   std::regex re(std::string((const char *)data, size));
> >   }
> > }
> >
> > $ totclang -c -g -O2 -std=c++11 -I $FUZZER $FUZZER/*.cpp
> > $ totclang -g -fsanitize=address
> > -fsanitize-coverage=edge,indirect-calls,8bit-counters -c -std=c++11
> > regex_fuzz.cpp
> > $ totclang -g -fsanitize=address Fuzzer*.o regex_fuzz.o -Wl
> >
> > Undefined symbols for architecture x86_64:
> >   "_dfsan_create_label", referenced from:
> >       fuzzer::TraceState::DFSanCmpCallback(unsigned long, unsigned long,
> > unsigned long, unsigned long long, unsigned long long, unsigned short,
> > unsigned short) in FuzzerTraceState.o
> >       fuzzer::Fuzzer::InitializeTraceState() in FuzzerTraceState.o
> >   "_dfsan_get_label_info", referenced from:
> >       fuzzer::TraceState::GetLabelRange(unsigned short) in
> > FuzzerTraceState.o
> >   "_dfsan_read_label", referenced from:
> >       _dfsan_weak_hook_memcmp in FuzzerTraceState.o
> >   "_dfsan_set_label", referenced from:
> >       fuzzer::Fuzzer::InitializeTraceState() in FuzzerTraceState.o
> > ld: symbol(s) not found for architecture x86_64
> > clang-3.7: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> >
> > -- Marshall
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150707/99c9dab7/attachment.html>


More information about the cfe-dev mailing list