1 # This file introduces a templates for defining fuzzers.
3 # All parameters valid for executable() targets are valid (cflags, defines,
4 # deps, include_dirs, sources, ...). In addition to that:
6 # dummy_main (required)
7 # Path to a cpp file containing main(), used when neither
8 # llvm_use_sanitize_coverage nor llvm_use_sanitize_coverage are set.
12 # fuzzer("llvm-opt-fuzzer") {
14 # dummy_main = "DummyOptFuzzer.cpp"
15 # sources = [ "llvm-opt-fuzzer.cpp" ]
19 # Set to the path of a static library containing a fuzzing engine, e.g.
20 # oss-fuzz's $LIB_FUZZING_ENGINE.
21 llvm_lib_fuzzing_engine = ""
23 # If true, pass -fsanitize=fuzzer to the compiler for fuzzer() targets.
24 # Likely only makes sense to set if you know that the host compiler is clang.
25 llvm_use_sanitize_coverage = false
29 assert(defined(invoker.dummy_main), "must set 'dummy_main' in $target_name")
30 assert(defined(invoker.sources), "must set 'sources' for $target_name")
31 executable(target_name) {
32 forward_variables_from(invoker, "*", [ "dummy_main" ])
33 if (llvm_lib_fuzzing_engine != "") {
37 libs += [ llvm_lib_fuzzing_engine ]
38 not_needed(invoker, [ "dummy_main" ])
39 } else if (llvm_use_sanitize_coverage) {
40 if (!defined(cflags)) {
43 cflags += [ "-fsanitize=fuzzer" ]
44 not_needed(invoker, [ "dummy_main" ])
46 sources += [ invoker.dummy_main ]