Add CFLAGS, CXXFLAGS, LDFLAGS to build-fuzz.sh

This commit is contained in:
Nigel Tao committed 2021-10-07 14:12:16 +11:00
1 parent f9c029c788
commit feb050b418
1 file changed
+10 -2
+10 -2
View File
@@ -24,6 +24,12 @@ fi
CC=${CC:-gcc}
CXX=${CXX:-g++}
LDFLAGS=${LDFLAGS:-}
# The "-fdata-sections -ffunction-sections -Wl,--gc-sections" produces smaller
# binaries. See commit 41fce8a8 "Strip examples of unused data and functions".
CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
mkdir -p gen/bin
@@ -43,9 +49,11 @@ for f in $sources; do
if [ -e fuzz/c/std/${f}_fuzzer.c ]; then
echo "Building (C) gen/bin/fuzz-$f"
$CC -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.c -o gen/bin/fuzz-$f
$CC $CFLAGS -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.c \
$LDFLAGS -o gen/bin/fuzz-$f
elif [ -e fuzz/c/std/${f}_fuzzer.cc ]; then
echo "Building (C++) gen/bin/fuzz-$f"
$CXX -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.cc -o gen/bin/fuzz-$f
$CXX $CXXFLAGS -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.cc \
$LDFLAGS -o gen/bin/fuzz-$f
fi
done