blob: dcdbe7cdc7ed4bb74cdda7b014b14def6665f994 [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//zircon/public/gn/toolchain/environment.gni")
# Fuzzer environments: These add libFuzzer instrumentation and hooks. These
# hooks will be undefined in shared libraries, and provided by the compiler
# runtime, which itself has an implicit dependency on libzircon.
standard_environments(".fuzzer") {
# Everything is compiled with the fuzzer instrumentation.
# Each variant can add additional bug-detection instrumentation.
configs = [
"//zircon/public/gn/config/instrumentation:fuzzer",
{
# libFuzzer can only be statically linked into each executable.
# Instrumented shared library code has dangling references to runtime
# symbols that will only be defined in the executable.
shlib = true
remove = [ "//build/config/zircon:no_undefined_symbols" ]
},
{
# We care more about accurate stack traces than binary size when fuzzing.
remove = [ "//build/config/zircon:default_icf" ]
},
]
implicit_deps = [
{
types = [ "executable" ]
add = [ "//zircon/public/gn/config/instrumentation:fuzzer_deps" ]
},
]
# Required by the above. See //zircon/public/gn/config/instrumentation:fuzzer.
tags = [ "sancov" ]
toolchain_vars = {
# Trailing dot will get "$variant/" appended to locate shared libraries.
libprefix = "fuzzer."
}
variant_libprefix = true
# Support all the sanitizers plus the baseline variant (i.e. a fuzzer
# that only detects explicit failure reports in the code, or crashes).
variant_selectors = standard_sanitizer_variants + standard_base_variants
# GCC doesn't support the fuzzer config always added here, so prune
# it from the baseline list.
exclude_variant_tags = [ "gcc" ]
# Set sanitizer options that we only want to apply for fuzzers.
toolchain_args = {
# Unless otherwise noted, these options are the defaults from ClusterFuzz.
asan_default_options = string_join(":",
[
"alloc_dealloc_mismatch=0",
"allocator_may_return_null=1",
"check_malloc_usable_size=0",
"detect_leaks=0",
"detect_odr_violation=0",
"detect_stack_use_after_return=1",
"malloc_context_size=128",
"max_uar_stack_size_log=16",
"print_scariness=1",
"print_summary=1",
"print_suppressions=0",
"strict_memcmp=0",
"symbolize=0",
])
}
}