@@ -10,6 +10,8 @@ set -eu
1010
1111unset CXX CC CFLAGS CXXFLAGS LDFLAGS
1212
13+ me=$( basename $0 )
14+
1315# A reproduce build, without avx but otherwise as plain
1416# as it gets. No sanitizers or optimization.
1517variant=plain-noavx
7678
7779# a fuzzer with sanitizers, built with avx disabled.
7880variant=ossfuzz-noavx8
79- if [ ! -d build-$variant ] ; then
80-
81- export CC=clang-8
82- export CXX=" clang++-8"
83- export CFLAGS=" -fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx "
84- export CXXFLAGS=" -fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx"
85- export LIB_FUZZING_ENGINE=" -fsanitize=fuzzer"
86-
87- mkdir build-$variant
88- cd build-$variant
89-
90- cmake .. \
91- -GNinja \
92- -DCMAKE_BUILD_TYPE=Debug \
93- -DSIMDJSON_BUILD_STATIC=On \
94- -DENABLE_FUZZING=On \
95- -DSIMDJSON_FUZZ_LINKMAIN=Off \
96- -DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
97- -DSIMDJSON_DISABLE_AVX=On
98-
99- ninja
100- cd ..
81+ if which clang++-8 > /dev/null 2>&1 ; then
82+ if [ ! -d build-$variant ] ; then
83+
84+ export CC=clang-8
85+ export CXX=" clang++-8"
86+ export CFLAGS=" -fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx "
87+ export CXXFLAGS=" -fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined -mno-avx2 -mno-avx"
88+ export LIB_FUZZING_ENGINE=" -fsanitize=fuzzer"
89+
90+ mkdir build-$variant
91+ cd build-$variant
92+
93+ cmake .. \
94+ -GNinja \
95+ -DCMAKE_BUILD_TYPE=Debug \
96+ -DSIMDJSON_BUILD_STATIC=On \
97+ -DENABLE_FUZZING=On \
98+ -DSIMDJSON_FUZZ_LINKMAIN=Off \
99+ -DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE \
100+ -DSIMDJSON_DISABLE_AVX=On
101+
102+ ninja
103+ cd ..
104+ fi
105+ else
106+ echo " $me : WARNING clang++-8 not found, please install it to build $variant "
101107fi
102108
103109# a fuzzer with sanitizers, default built
127133
128134# a fast fuzzer, for fast exploration
129135variant=ossfuzz-fast8
130- if [ ! -d build-$variant ] ; then
131- export CC=clang-8
132- export CXX=" clang++-8"
133- export CFLAGS=" -fsanitize=fuzzer-no-link -O3 -g"
134- export CXXFLAGS=" -fsanitize=fuzzer-no-link -O3 -g"
135- export LIB_FUZZING_ENGINE=" -fsanitize=fuzzer"
136-
137- mkdir build-$variant
138- cd build-$variant
139-
140- cmake .. \
141- -GNinja \
142- -DCMAKE_BUILD_TYPE= \
143- -DSIMDJSON_BUILD_STATIC=On \
144- -DENABLE_FUZZING=On \
145- -DSIMDJSON_FUZZ_LINKMAIN=Off \
146- -DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
147-
148- ninja
149-
150- cd ..
136+ if which clang++-8 > /dev/null 2>&1 ; then
137+ if [ ! -d build-$variant ] ; then
138+ export CC=clang-8
139+ export CXX=" clang++-8"
140+ export CFLAGS=" -fsanitize=fuzzer-no-link -O3 -g"
141+ export CXXFLAGS=" -fsanitize=fuzzer-no-link -O3 -g"
142+ export LIB_FUZZING_ENGINE=" -fsanitize=fuzzer"
143+
144+ mkdir build-$variant
145+ cd build-$variant
146+
147+ cmake .. \
148+ -GNinja \
149+ -DCMAKE_BUILD_TYPE= \
150+ -DSIMDJSON_BUILD_STATIC=On \
151+ -DENABLE_FUZZING=On \
152+ -DSIMDJSON_FUZZ_LINKMAIN=Off \
153+ -DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
154+
155+ ninja
156+
157+ cd ..
158+ fi
159+ else
160+ echo " $me : WARNING clang++-8 not found, please install it to build $variant "
151161fi
162+
0 commit comments