From: Andrew Bartlett Date: Wed, 21 Oct 2020 18:34:35 +0000 (+1300) Subject: fuzzing: Fix the oss-fuzz coverage build X-Git-Tag: talloc-2.3.2~201 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d031391bed0d3c23b602816d968417267535c746;p=thirdparty%2Fsamba.git fuzzing: Fix the oss-fuzz coverage build It was long thought that the issue here was that no seed corpus was provided, but actually the issue is that to obtain coverage output just as we already know for gcc gcov, you must provide fuzzing flags to both the compile and link phase. Thankfully clang as a linker does not mind the strange non-linker options from $COVERAGE_FLAGS. REF: https://stackoverflow.com/questions/56112019/clang-does-not-generate-profraw-file-when-linking-manually REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19495#c48 Reviewed-by: Douglas Bagnall Signed-off-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Wed Oct 21 23:07:37 UTC 2020 on sn-devel-184 --- diff --git a/lib/fuzzing/oss-fuzz/build_samba.sh b/lib/fuzzing/oss-fuzz/build_samba.sh index b27c7b7d5c8..5980f88ad02 100755 --- a/lib/fuzzing/oss-fuzz/build_samba.sh +++ b/lib/fuzzing/oss-fuzz/build_samba.sh @@ -59,7 +59,14 @@ case "$SANITIZER" in SANITIZER_ARG='--undefined-sanitizer' ;; coverage) - SANITIZER_ARG='' + # Thankfully clang operating as ld has no objection to the + # cc style options, so we can just set ADDITIONAL_LDFLAGS + # to ensure the coverage build is done, despite waf splitting + # the compile and link phases. + ADDITIONAL_LDFLAGS="$COVERAGE_FLAGS" + export ADDITIONAL_LDFLAGS + + SANITIZER_ARG='' ;; esac