This is an archive of the discontinued LLVM Phabricator instance.

lib Fuzzer FreeBSD support
ClosedPublic

Authored by devnexen on Dec 30 2017, 8:47 AM.

Diff Detail

Event Timeline

devnexen created this revision.Dec 30 2017, 8:47 AM

From llvm as if I m correct lib buzzer does not belong to compiler rt anymore.

What are the results for check-fuzzer?

krytarowski added inline comments.Jan 3 2018, 6:57 AM
lib/fuzzer/FuzzerUtilPosix.cpp
121

Please add || LIBFUZZER_NETBSD too.

devnexen updated this revision to Diff 128600.Jan 4 2018, 12:55 AM

Updated accordingly + one forgotten change to be able to build the target.

devnexen updated this revision to Diff 128875.Jan 7 2018, 9:43 AM

What are the results for check-fuzzer?

Sorry for late reply.
In my FreeBSD machines I m unable to build the clang target (linkage ... machine hanging) but all the rest does (e.g. I m able on Linux with similar hw). I tried the patch on libfuzzer alone (with h2o) and seemed working ok.

krytarowski added inline comments.Jan 9 2018, 9:36 AM
lib/fuzzer/tests/CMakeLists.txt
18 ↗(On Diff #128875)

Why -lpthread here? Is it needed for a particular test only? Or all of them?

Maybe this should be moved to the clang frontend.

devnexen updated this revision to Diff 129328.Jan 10 2018, 1:13 PM
morehouse added inline comments.Jan 10 2018, 3:44 PM
lib/fuzzer/build.sh
1

Is this change necessary? All our shell scripts use #!/bin/sh or #!/bin/bash.

lib/fuzzer/tests/CMakeLists.txt
18 ↗(On Diff #129328)

Can you combine this into the original if expression with OR?

krytarowski added inline comments.Jan 10 2018, 3:48 PM
lib/fuzzer/build.sh
1

This is necessary, better to rewrite it to /bin/sh (POSIX shell) if possible. The env fallback is usually good enough for scripts with bash-specific features.

There is no bash in the basesystem of BSD. It can be installed optionally and if so, it's located in a different location dedicated for external software - in the NetBSD case, it's /usr/pkg/bin/bash.

devnexen updated this revision to Diff 129363.Jan 10 2018, 4:04 PM
devnexen updated this revision to Diff 129449.Jan 11 2018, 7:05 AM

With this change (alongside with this one https://reviews.llvm.org/D41809) I m finally able to build fuzz binaries.

Can you run 'check-fuzzer'?

devnexen updated this revision to Diff 129455.Jan 11 2018, 8:37 AM

The tests pass with those changes.

Can you run 'check-fuzzer'?

I got 147 tests but had to disable some.

lib/fuzzer/tests/CMakeLists.txt
18 ↗(On Diff #129328)

Yes sure I just feared either it would make the expression too long or ... in case we might need to add later on some FreeBSD specificities.

18 ↗(On Diff #128875)

When I did the change I think one test required it indeed but might not be necessary now I ve update the tree locally but still struggle to compile the whole :-) we ll see

krytarowski added inline comments.Jan 11 2018, 11:20 AM
test/fuzzer/strcmp.test
1 ↗(On Diff #129455)

I think that the style is to put UNSUPPORTED after RUN:

devnexen added inline comments.Jan 11 2018, 11:37 AM
test/fuzzer/strcmp.test
1 ↗(On Diff #129455)

Oh ok I looked at others and were put first.

krytarowski added a subscriber: george.karpenkov.

I can land this for you (and for the benefit of NetBSD), assuming that it will be accepted by other developer. Maybe @george.karpenkov can have a look?

@krytarowski CMake changes look good to me, but I'm not the code owner, so probably @kcc (or @morehouse) would have to approve it first.
It's interesting that tests requiring intrinsics instrumentation are failing, is it hard to port those as well? (though that could be done in a separate patch)

This revision is now accepted and ready to land.Jan 12 2018, 9:09 AM
krytarowski edited the summary of this revision. (Show Details)Jan 12 2018, 9:14 AM
This revision was automatically updated to reflect the committed changes.
Herald added subscribers: Restricted Project, llvm-commits. · View Herald TranscriptJan 12 2018, 9:16 AM
dim added inline comments.Jan 12 2018, 10:37 AM
lib/fuzzer/build.sh
1

I see nothing in this script that requires bash. Maybe just use /bin/sh here?

But indeed, /bin/bash is normally only available on Linux. BSDs put it in a ports or pkgsrc specific installation directory, and that directory will be in the user's PATH.

Something similar goes for e.g. perl and python, one should *never* use /usr/bin/perl or /usr/bin/python, always /usr/bin/env perl and /usr/bin/env python.

krytarowski added inline comments.Jan 12 2018, 12:48 PM
lib/fuzzer/build.sh
1

Can you prepare a patch please?

devnexen added inline comments.Jan 12 2018, 12:59 PM
lib/fuzzer/build.sh
1