[infra] Fix dataflow engine compilation for a speed up (#1632). (#3219)

This commit is contained in:
Max Moroz 2020-01-12 11:43:03 -08:00 committed by GitHub
parent 6c5632a1a5
commit cbdc65515e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View File

@ -15,13 +15,18 @@
#
################################################################################
export LIB_FUZZING_ENGINE="/usr/lib/DataFlow*.o"
echo -n "Compiling DataFlow to $LIB_FUZZING_ENGINE... "
mkdir -p $WORK/libfuzzer
pushd $WORK/libfuzzer > /dev/null
$CXX $CXXFLAGS $SANITIZER_FLAGS -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/*.cpp
ar r $LIB_FUZZING_ENGINE $WORK/libfuzzer/*.o
$CXX $CXXFLAGS -fno-sanitize=all $SANITIZER_FLAGS -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/DataFlow.cpp
$CXX $CXXFLAGS -fno-sanitize=all -fPIC -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/DataFlowCallbacks.cpp
cp $WORK/libfuzzer/DataFlow*.o /usr/lib/
popd > /dev/null
rm -rf $WORK/libfuzzer
echo " done."

View File

@ -23,6 +23,10 @@ MIN_NUMBER_OF_RUNS=4
# Mercurial's bdiff_fuzzer has 116 PCs when built with ASan.
THRESHOLD_FOR_NUMBER_OF_EDGES=100
# A fuzz target is supposed to have at least two functions, such as
# LLVMFuzzerTestOneInput and an API that is being called from there.
THRESHOLD_FOR_NUMBER_OF_FUNCTIONS=2
# Threshold values for different sanitizers used by instrumentation checks.
ASAN_CALLS_THRESHOLD_FOR_ASAN_BUILD=1000
ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD=0
@ -95,8 +99,14 @@ function check_engine {
return 1
fi
elif [[ "$FUZZING_ENGINE" == dataflow ]]; then
# TODO(https://github.com/google/oss-fuzz/issues/1632): add check for
# binaries compiled with dataflow engine when the interface becomes stable.
$FUZZER &> $FUZZER_OUTPUT
local NUMBER_OF_FUNCTIONS=$(grep -Po "INFO:\s+\K[[:digit:]]+(?=\s+instrumented function.*)" $FUZZER_OUTPUT)
[[ -z "$NUMBER_OF_FUNCTIONS" ]] && NUMBER_OF_FUNCTIONS=0
if (( $NUMBER_OF_FUNCTIONS < $THRESHOLD_FOR_NUMBER_OF_FUNCTIONS )); then
echo "BAD BUILD: $FUZZER does not seem to be properly built in 'dataflow' config."
cat $FUZZER_OUTPUT
return 1
fi
return 0
fi