1#!/usr/bin/env bash 2# This file is used by build.sh to setup fuzzing. 3 4set +e 5 6# Default to clang if CC is not set. 7if [ -z "$CC" ]; then 8 if ! command -v clang &> /dev/null 2>&1; then 9 echo "Fuzzing requires clang!" 10 exit 1 11 fi 12 export CC=clang 13 export CCC=clang++ 14 export CXX=clang++ 15fi 16 17gyp_params+=(-Dstatic_libs=1 -Dfuzz=1 -Dsign_libs=0) 18 19# Add debug symbols even for opt builds. 20nspr_params+=(--enable-debug-symbols) 21 22if [ "$fuzz_oss" = 1 ]; then 23 gyp_params+=(-Dno_zdefs=1 -Dfuzz_oss=1) 24else 25 enable_sanitizer asan 26 # Ubsan only builds on x64 for the moment. 27 if [ "$target_arch" = "x64" ]; then 28 enable_ubsan 29 fi 30 enable_sancov 31fi 32 33if [ "$fuzz_tls" = 1 ]; then 34 gyp_params+=(-Dfuzz_tls=1) 35fi 36 37if [ ! -f "/usr/lib/libFuzzingEngine.a" ]; then 38 echo "Cloning libFuzzer files ..." 39 run_verbose "$cwd"/fuzz/config/clone_libfuzzer.sh 40fi 41