Debian Codegraph @

fuzzer/build-fuzzer.sh

raw
1 #!/usr/bin/env bash
2 set -e
3
4 NPROC=1
5
6 # OS detection
7 if [ "$(uname)" = "Linux" ]; then
8 NPROC=$(nproc)
9 CC=clang-12
10 elif [ "$(uname)" = "Darwin" ]; then
11 NPROC=$(sysctl -n hw.ncpu)
12 CC=clang
13 elif [ "$(uname)" = "FreeBSD" ]; then
14 NPROC=$(sysctl -n hw.ncpu)
15 CC=cc
16 else
17 echo "Error: $(uname) not supported, sorry!"
18 exit 1
19 fi
20
21 # Check if we have a compiler
22 if ! [ -x "$(command -v $CC)" ]; then
23 echo "Error: $CC is not installed!" >&2
24 exit 1
25 fi
26
27 echo "OS :" $(uname)
28 echo "CC :" $CC
29 echo "NP :" $NPROC
30
31 # Go to script directory
32 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
33 cd "$SCRIPT_DIR"
34 cd ".."
35
36 pwd
37
38 # Find and then delete all files under current directory (.) that:
39 # 1. contains "cmake" (case-&insensitive) in its path (wholename)
40 # 2. name is not CMakeLists.txt
41 find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
42
43 # Build with ASAN / MSAN
44 cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
45 #cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
46
47 make -j"$NPROC"