LLVM currently doesn't build with -DLLVM_USE_SANITIZER=Address -DLLVM_USE_SANITIZE_COVERAGE=YES on OS X. To fix that let's disable DFSan and Uninstrumented tests of libFuzzer (DFSan is not supported on OS X and uninstrumented tests fail to link because of the missing runtime).
Diff Detail
Event Timeline
lib/Fuzzer/test/uninstrumented/CMakeLists.txt | ||
---|---|---|
12 ↗ | (On Diff #42071) | Why? |
lib/Fuzzer/test/uninstrumented/CMakeLists.txt | ||
---|---|---|
12 ↗ | (On Diff #42071) | Ugh, wrong patch. This is not intended to be here. |
Uninstrumented tests should not fail to link. That's what they are testing for.
On Linux this works due to weak function (if there is no run-time, the functions are NULL and libFuzzer will fail at run-time).
DFSAN-related change is ok
What are the expected steps to use libFuzzer in a non-instrumented way? Your link command still needs to include -fsanitize=..., right?
The non-instrumented test should be compiled *and* linked w/o any -fsanitize* flags.
The test should link successfully, and when run, print an error message and exit.
Shouldn't this just work out of the box? (I assume that weak functions are functioning on OSX)
Weak functions work differently on OS X, due to two-level namespaces. Regular __attribute__((weak)) still needs to link against something that provides the symbol, so that we know in which library should we look the symbol up. Otherwise, we simply fail to link with a "Undefined symbol" error. There is a linker flag, -undefined dynamic_lookup, which causes all undefined symbols to be resolved only at runtime and in all loaded libraries (and "weak" then works as you expect). I'd rather not use it, because it then hides a lot of linking errors. And the user is not likely to use this flag. I don't know what's a viable solution here, other than using dlsym().
LGTM
Ok, let's disable the uninstrumented test on Mac,
but may I ask you to add a comment explaining why?
Also, maybe make two separate if(NOT APPLE) sections
with their separate comments.