Attempting to provide no-op functionality in the fuzzing instrumentation transition.
diff --git a/fuzzing/BUILD b/fuzzing/BUILD
index 9053349..2dbd87d 100644
--- a/fuzzing/BUILD
+++ b/fuzzing/BUILD
@@ -20,6 +20,18 @@
visibility = ["//visibility:public"],
)
+# If set, enable the fuzzing build mode of fuzz test binaries, including fuzzing
+# engine and sanitizer instrumentation.
+#
+# The fuzzing build mode defines the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+# macro during compilation (see
+# https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode).
+bool_flag(
+ name = "cc_fuzzing_build_mode",
+ build_setting_default = False,
+ visibility = ["//visibility:public"],
+)
+
string_flag(
name = "cc_engine_instrumentation",
build_setting_default = "none",
@@ -51,16 +63,6 @@
visibility = ["//visibility:public"],
)
-# If set, define the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION macro
-# during compilation.
-#
-# See https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode
-bool_flag(
- name = "cc_fuzzing_build_mode",
- build_setting_default = True,
- visibility = ["//visibility:public"],
-)
-
exports_files([
"cc_deps.bzl",
"instrum_opts.bzl",
diff --git a/fuzzing/private/binary.bzl b/fuzzing/private/binary.bzl
index ab5ddab..b705644 100644
--- a/fuzzing/private/binary.bzl
+++ b/fuzzing/private/binary.bzl
@@ -40,16 +40,22 @@
)
def _fuzzing_binary_transition_impl(settings, attr):
+ is_fuzzing_build_mode = settings["@rules_fuzzing//fuzzing:cc_fuzzing_build_mode"]
+ if not is_fuzzing_build_mode:
+ return {
+ "//command_line_option:copt": settings["//command_line_option:copt"],
+ "//command_line_option:linkopt": settings["//command_line_option:linkopt"],
+ "//command_line_option:conlyopt": settings["//command_line_option:conlyopt"],
+ "//command_line_option:cxxopt": settings["//command_line_option:cxxopt"],
+ }
+
opts = instrum_opts.make(
copts = settings["//command_line_option:copt"],
conlyopts = settings["//command_line_option:conlyopt"],
cxxopts = settings["//command_line_option:cxxopt"],
linkopts = settings["//command_line_option:linkopt"],
)
-
- is_fuzzing_build_mode = settings["@rules_fuzzing//fuzzing:cc_fuzzing_build_mode"]
- if is_fuzzing_build_mode:
- opts = instrum_opts.merge(opts, instrum_defaults.fuzzing_build)
+ opts = instrum_opts.merge(opts, instrum_defaults.fuzzing_build)
instrum_config = settings["@rules_fuzzing//fuzzing:cc_engine_instrumentation"]
if instrum_config in instrum_configs:
@@ -68,9 +74,6 @@
"//command_line_option:linkopt": opts.linkopts,
"//command_line_option:conlyopt": opts.conlyopts,
"//command_line_option:cxxopt": opts.cxxopts,
- # Make sure binaries are built statically, to maximize the scope of the
- # instrumentation.
- "//command_line_option:dynamic_mode": "off",
}
fuzzing_binary_transition = transition(
@@ -89,7 +92,6 @@
"//command_line_option:conlyopt",
"//command_line_option:cxxopt",
"//command_line_option:linkopt",
- "//command_line_option:dynamic_mode",
],
)