summaryrefslogtreecommitdiffstats
path: root/security/nss/coreconf/fuzz.sh
blob: 67cb7f59490c85911ab0dad9f207bda28ff43586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# This file is used by build.sh to setup fuzzing.

set +e

# Default to clang if CC is not set.
if [ -z "$CC" ]; then
    command -v clang &> /dev/null 2>&1
    if [ $? != 0 ]; then
        echo "Fuzzing requires clang!"
        exit 1
    fi
    export CC=clang
    export CCC=clang++
    export CXX=clang++
fi

gyp_params+=(-Dtest_build=1 -Dfuzz=1 -Dsign_libs=0)

# Add debug symbols even for opt builds.
nspr_params+=(--enable-debug-symbols)

if [ "$fuzz_oss" = 1 ]; then
  gyp_params+=(-Dno_zdefs=1 -Dfuzz_oss=1)
else
  enable_sanitizer asan
  # Ubsan doesn't build on 32-bit at the moment. Disable it.
  if [ "$build_64" = 1 ]; then
    enable_ubsan
  fi
  enable_sancov
fi

if [ "$fuzz_tls" = 1 ]; then
  gyp_params+=(-Dfuzz_tls=1)
fi

if [ ! -f "/usr/lib/libFuzzingEngine.a" ]; then
  echo "Cloning libFuzzer files ..."
  run_verbose "$cwd"/fuzz/config/clone_libfuzzer.sh
fi