aboutsummaryrefslogtreecommitdiff
path: root/third_party/libprotobuf-mutator/BUILD.gn
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-16 08:06:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-16 08:06:05 +0000
commit6c65c1479a08e3754bdb98e1b31ffb7cb7e7e3da (patch)
tree4f552c06b6d628ad0c33313ac0c59356d2fee81e /third_party/libprotobuf-mutator/BUILD.gn
parenta1f37d7e15e391e1973053f8d58f07e4d240f1b4 (diff)
parentd768fc0756bd942df7d4cbe72c8cec3c8bb3b67e (diff)
downloadopenscreen-6c65c1479a08e3754bdb98e1b31ffb7cb7e7e3da.tar.gz
Snap for 8189365 from d768fc0756bd942df7d4cbe72c8cec3c8bb3b67e to tm-frc-neuralnetworks-release
Change-Id: I621de762d84ec0aafe9f3c0ff3e0370bf1e830a9
Diffstat (limited to 'third_party/libprotobuf-mutator/BUILD.gn')
-rw-r--r--third_party/libprotobuf-mutator/BUILD.gn53
1 files changed, 35 insertions, 18 deletions
diff --git a/third_party/libprotobuf-mutator/BUILD.gn b/third_party/libprotobuf-mutator/BUILD.gn
index cc8c6a01..cc3eeaeb 100644
--- a/third_party/libprotobuf-mutator/BUILD.gn
+++ b/third_party/libprotobuf-mutator/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
+# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,17 +7,14 @@ import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
config("include_config") {
- include_dirs = [
- "src/",
- "//",
- ]
- cflags_cc = [ "-Wno-exit-time-destructors" ]
+ include_dirs = [ "src/" ]
}
source_set("libprotobuf-mutator") {
testonly = true
configs += [ ":include_config" ]
+
public_configs = [ ":include_config" ]
sources = [
"src/src/binary_format.cc",
@@ -33,28 +30,49 @@ source_set("libprotobuf-mutator") {
public_deps = [ "//third_party/protobuf:protobuf_full" ]
}
+# This protoc plugin, like the compiler, should only be built for the host
+# architecture.
+if (current_toolchain == host_toolchain) {
+ # This plugin will be needed to fuzz most protobuf code in Chromium. That's
+ # because production protobuf code must contain the line:
+ # "option optimize_for = LITE_RUNTIME", which instructs the proto compiler not
+ # to compile the proto using the full protobuf runtime. This allows Chromium
+ # not to depend on the full protobuf library, but prevents
+ # libprotobuf-mutator from fuzzing because the lite runtime lacks needed
+ # features (such as reflection). The plugin simply compiles a proto library
+ # as normal but ensures that is compiled with the full protobuf runtime.
+ executable("override_lite_runtime_plugin") {
+ sources = [ "protoc_plugin/protoc_plugin.cc" ]
+ deps = [ "//third_party/protobuf:protoc_lib" ]
+ public_configs = [ "//third_party/protobuf:protobuf_config" ]
+ }
+ # To use the plugin in a proto_library you want to fuzz, change the build
+ # target to fuzzable_proto_library (defined in
+ # //third_party/libprotobuf-mutator/fuzzable_proto_library.gni)
+}
+
# The CQ will try building this target without "use_libfuzzer" if it is defined.
# That will cause the build to fail, so don't define it when "use_libfuzzer" is
# is false.
if (use_libfuzzer) {
- # Test that fuzzable_proto_library works. This target contains files that are
- # optimized for LITE_RUNTIME and which import other files that are also
- # optimized for LITE_RUNTIME.
- openscreen_fuzzer_test("lpm_test_fuzzer") {
- sources = [ "test_fuzzer/test_fuzzer.cc" ]
+ # Test that override_lite_runtime_plugin is working when built. This target
+ # contains files that are optimized for LITE_RUNTIME and which import other
+ # files that are also optimized for LITE_RUNTIME.
+ openscreen_fuzzer_test("override_lite_runtime_plugin_test_fuzzer") {
+ sources = [ "protoc_plugin/test_fuzzer.cc" ]
deps = [
":libprotobuf-mutator",
- ":lpm_test_fuzzer_proto",
+ ":override_lite_runtime_plugin_test_fuzzer_proto",
]
}
}
-# Proto library for lpm_test_fuzzer
-fuzzable_proto_library("lpm_test_fuzzer_proto") {
+# Proto library for override_lite_runtime_plugin_test_fuzzer
+fuzzable_proto_library("override_lite_runtime_plugin_test_fuzzer_proto") {
sources = [
- "test_fuzzer/imported.proto",
- "test_fuzzer/imported_publicly.proto",
- "test_fuzzer/test_fuzzer_input.proto",
+ "protoc_plugin/imported.proto",
+ "protoc_plugin/imported_publicly.proto",
+ "protoc_plugin/test_fuzzer_input.proto",
]
}
@@ -65,6 +83,5 @@ if (use_libfuzzer) {
# Component that can provide protobuf_full to non-testonly targets
static_library("protobuf_full") {
public_deps = [ "//third_party/protobuf:protobuf_full" ]
- sources = [ "dummy.cc" ]
}
}