This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] CMake support for libFuzzer on OS X
AbandonedPublic

Authored by kubamracek on Dec 7 2015, 8:29 AM.

Details

Summary

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

kubamracek updated this revision to Diff 42071.Dec 7 2015, 8:29 AM
kubamracek retitled this revision from to [libFuzzer] CMake support for libFuzzer on OS X.
kubamracek updated this object.
kubamracek added reviewers: kcc, glider, samsonov.
kubamracek added subscribers: llvm-commits, zaks.anna.
samsonov added inline comments.Dec 7 2015, 11:10 AM
lib/Fuzzer/test/uninstrumented/CMakeLists.txt
12 ↗(On Diff #42071)

Why?

kubamracek added inline comments.Dec 7 2015, 11:14 AM
lib/Fuzzer/test/uninstrumented/CMakeLists.txt
12 ↗(On Diff #42071)

Ugh, wrong patch. This is not intended to be here.

kubamracek updated this revision to Diff 42081.Dec 7 2015, 11:14 AM
samsonov accepted this revision.Dec 7 2015, 11:52 AM
samsonov edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 7 2015, 11:52 AM
kcc edited edge metadata.Dec 7 2015, 9:15 PM

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

In D15290#304544, @kcc wrote:

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?

kcc added a comment.Dec 9 2015, 9:21 PM
In D15290#306499, @kubabrecka wrote:
In D15290#304544, @kcc wrote:

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)

In D15290#306779, @kcc wrote:

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().

kcc accepted this revision.Dec 10 2015, 12:02 AM
kcc edited edge metadata.

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.

kubamracek abandoned this revision.Oct 31 2016, 12:38 PM