Debian Codegraph @

fuzz/build.sh

raw
1 #!/bin/sh
2 # Build libFuzzer harnesses for hyphen.
3 #
4 # Produces two binaries in fuzz/:
5 # fuzz_hyphen - libFuzzer + ASan + UBSan, the actual fuzz target.
6 # fuzz_hyphen_cov - coverage-instrumented (no sanitizers), for post-run
7 # coverage reporting via llvm-profdata + llvm-cov.
8
9 set -eu
10
11 cd "$(dirname "$0")/.."
12
13 CC=${CC:-clang}
14 CFLAGS_COMMON="-O1 -g -fno-omit-frame-pointer -I."
15 SOURCES="hyphen.c hnjalloc.c fuzz/fuzz_hyphen.c"
16
17 echo "[fuzz] building fuzz_hyphen (fuzzer + ASan + UBSan)"
18 $CC $CFLAGS_COMMON \
19 -fsanitize=fuzzer,address,undefined \
20 -fno-sanitize-recover=undefined \
21 $SOURCES \
22 -o fuzz/fuzz_hyphen
23
24 echo "[fuzz] building fuzz_hyphen_cov (coverage-instrumented)"
25 $CC $CFLAGS_COMMON \
26 -fsanitize=fuzzer \
27 -fprofile-instr-generate -fcoverage-mapping \
28 $SOURCES \
29 -o fuzz/fuzz_hyphen_cov
30
31 echo "[fuzz] done:"
32 ls -lh fuzz/fuzz_hyphen fuzz/fuzz_hyphen_cov