2019-11-12 05:17:32 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This file builds multiple variants of the fuzzers
|
|
|
|
# - different sanitizers
|
|
|
|
# - different build options
|
|
|
|
# - reproduce build, for running through valgrind
|
|
|
|
|
|
|
|
# fail on error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
unset CXX CC CFLAGS CXXFLAGS LDFLAGS
|
|
|
|
|
2019-12-28 02:42:44 +08:00
|
|
|
me=$(basename $0)
|
|
|
|
|
2019-11-12 05:17:32 +08:00
|
|
|
# A reproduce build, without avx but otherwise as plain
|
|
|
|
# as it gets. No sanitizers or optimization.
|
|
|
|
variant=plain-noavx
|
|
|
|
if [ ! -d build-$variant ] ; then
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=On \
|
2020-03-17 04:51:30 +08:00
|
|
|
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
2019-11-12 05:17:32 +08:00
|
|
|
|
|
|
|
ninja
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
# A reproduce build as plain as it gets. Everythings tunable is
|
|
|
|
# using the defaults.
|
|
|
|
variant=plain-normal
|
|
|
|
if [ ! -d build-$variant ] ; then
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=On
|
|
|
|
|
|
|
|
ninja
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
# a fuzzer with sanitizers, built with avx disabled.
|
|
|
|
variant=ossfuzz-noavx
|
|
|
|
if [ ! -d build-$variant ] ; then
|
|
|
|
|
|
|
|
export CC=clang
|
|
|
|
export CXX="clang++"
|
|
|
|
export CFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx "
|
|
|
|
export CXXFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx"
|
|
|
|
export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
|
|
|
|
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
|
|
|
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
|
2020-03-17 04:51:30 +08:00
|
|
|
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
2019-11-12 05:17:32 +08:00
|
|
|
|
|
|
|
ninja
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# a fuzzer with sanitizers, built with avx disabled.
|
2020-04-13 02:02:45 +08:00
|
|
|
variant=ossfuzz-noavx9
|
|
|
|
if which clang++-9 >/dev/null 2>&1 ; then
|
2019-12-28 02:42:44 +08:00
|
|
|
if [ ! -d build-$variant ] ; then
|
|
|
|
|
2020-04-13 02:02:45 +08:00
|
|
|
export CC=clang-9
|
|
|
|
export CXX="clang++-9"
|
2019-12-28 02:42:44 +08:00
|
|
|
export CFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx "
|
|
|
|
export CXXFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx"
|
|
|
|
export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
|
|
|
|
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
|
|
|
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
|
2020-03-17 04:51:30 +08:00
|
|
|
-DSIMDJSON_IMPLEMENTATION_HASWELL=0
|
2019-12-28 02:42:44 +08:00
|
|
|
|
|
|
|
ninja
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
else
|
2020-04-13 02:02:45 +08:00
|
|
|
echo "$me: WARNING clang++-9 not found, please install it to build $variant"
|
2019-11-12 05:17:32 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# a fuzzer with sanitizers, default built
|
|
|
|
variant=ossfuzz-withavx
|
|
|
|
if [ ! -d build-$variant ] ; then
|
|
|
|
|
|
|
|
export CC=clang
|
|
|
|
export CXX="clang++"
|
|
|
|
export CFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined"
|
|
|
|
export CXXFLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined"
|
|
|
|
export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
|
|
|
|
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
|
|
|
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
|
|
|
|
|
|
|
|
ninja
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
# a fast fuzzer, for fast exploration
|
2020-04-13 02:02:45 +08:00
|
|
|
variant=ossfuzz-fast9
|
|
|
|
if which clang++-9 >/dev/null 2>&1 ; then
|
2019-12-28 02:42:44 +08:00
|
|
|
if [ ! -d build-$variant ] ; then
|
2020-04-13 02:02:45 +08:00
|
|
|
export CC=clang-9
|
|
|
|
export CXX="clang++-9"
|
2019-12-28 02:42:44 +08:00
|
|
|
export CFLAGS="-fsanitize=fuzzer-no-link -O3 -g"
|
|
|
|
export CXXFLAGS="-fsanitize=fuzzer-no-link -O3 -g"
|
|
|
|
export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
|
|
|
|
|
|
|
|
mkdir build-$variant
|
|
|
|
cd build-$variant
|
|
|
|
|
|
|
|
cmake .. \
|
|
|
|
-GNinja \
|
|
|
|
-DCMAKE_BUILD_TYPE= \
|
|
|
|
-DSIMDJSON_BUILD_STATIC=On \
|
|
|
|
-DENABLE_FUZZING=On \
|
|
|
|
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
|
|
|
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
|
|
|
|
|
|
|
|
ninja
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
else
|
2020-04-13 02:02:45 +08:00
|
|
|
echo "$me: WARNING clang++-9 not found, please install it to build $variant"
|
2019-11-12 05:17:32 +08:00
|
|
|
fi
|
2019-12-28 02:42:44 +08:00
|
|
|
|