Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1329837 - Refactor build.sh further, r=ttaubert
--HG-- extra : rebase_source : cdffc4362cfc8c5df0f1f5e559c56073c0b238c5
- Loading branch information
1 parent
24735e0
commit eb3782e
Showing
4 changed files
with
152 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# This file is used by build.sh to setup fuzzing. | ||
|
||
gyp_params+=(-Dtest_build=1 -Dfuzz=1) | ||
enable_sanitizer asan | ||
enable_ubsan | ||
enable_sancov | ||
|
||
# Add debug symbols even for opt builds. | ||
nspr_params+=(--enable-debug-symbols) | ||
|
||
echo "fuzz [1/2] Cloning libFuzzer files ..." | ||
run_verbose "$cwd"/fuzz/clone_libfuzzer.sh | ||
|
||
echo "fuzz [2/2] Cloning fuzzing corpus ..." | ||
run_verbose "$cwd"/fuzz/clone_corpus.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
# This file is used by build.sh to setup sanitizers. | ||
|
||
# This tracks what sanitizers are enabled, and their options. | ||
declare -A sanitizers | ||
enable_sanitizer() | ||
{ | ||
local san="$1" | ||
[ -n "${sanitizers[$san]}" ] && return | ||
sanitizers[$san]="${2:-1}" | ||
gyp_params+=(-Duse_"$san"="${2:-1}") | ||
nspr_sanitizer "$san" "$2" | ||
} | ||
|
||
enable_sancov() | ||
{ | ||
local clang_version=$($CC --version | grep -oE 'clang version (3\.9\.|4\.)') | ||
if [ -z "$clang_version" ]; then | ||
echo "Need at least clang-3.9 (better 4.0) for sancov." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
local sancov | ||
if [ -n "$1" ]; then | ||
sancov="$1" | ||
elif [ "$clang_version" = "clang version 3.9." ]; then | ||
sancov=edge,indirect-calls,8bit-counters | ||
else | ||
sancov=trace-pc-guard | ||
fi | ||
enable_sanitizer sancov "$sancov" | ||
} | ||
|
||
enable_ubsan() | ||
{ | ||
local ubsan | ||
if [ -n "$1" ]; then | ||
ubsan="$1" | ||
else | ||
ubsan=bool,signed-integer-overflow,shift,vptr | ||
fi | ||
enable_sanitizer ubsan "$ubsan" | ||
} | ||
|
||
# Not strictly a sanitizer, but the pattern fits | ||
scanbuild=() | ||
enable_scanbuild() | ||
{ | ||
[ "${#scanbuild[@]}" -gt 0 ] && return | ||
|
||
scanbuild=(scan-build) | ||
if [ -n "$1" ]; then | ||
scanbuild+=(-o "$1") | ||
fi | ||
# pass on CC and CCC to scanbuild | ||
if [ -n "$CC" ]; then | ||
scanbuild+=(--use-cc="$CC") | ||
fi | ||
if [ -n "$CCC" ]; then | ||
scanbuild+=(--use-c++="$CCC") | ||
fi | ||
} | ||
|
||
run_scanbuild() | ||
{ | ||
"${scanbuild[@]}" "$@" | ||
} |