Commit 91445a3f authored by Jonathan Metzman's avatar Jonathan Metzman Committed by Commit Bot

[libFuzzer][Windows] Make fuzzable_proto_library work

Get fuzzable_proto_library working on Windows (and probably Mac) by including
a dummy source in our protobuf_full wrapper.
This causes the library to actually get built.

Bug: 884560, 889889
Change-Id: I4c6a1f8b284448dfdf2845cf3fd9adfd6a4fcb78
Reviewed-on: https://chromium-review.googlesource.com/c/1343243Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Commit-Queue: Jonathan Metzman <metzman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609466}
parent d6456ac6
...@@ -46,9 +46,6 @@ libprotobuf-mutator fuzzer that is even more trivial than ...@@ -46,9 +46,6 @@ libprotobuf-mutator fuzzer that is even more trivial than
url_parse_proto_fuzzer. url_parse_proto_fuzzer.
## Write a fuzz target for code that accepts protobufs ## Write a fuzz target for code that accepts protobufs
*** note
**Note:** Right now this only works on Linux.
***
This is almost as easy as writing a standard libFuzzer-based fuzzer. You can This is almost as easy as writing a standard libFuzzer-based fuzzer. You can
look at [override_lite_runtime_plugin_test_fuzzer] for an example of a working example of look at [override_lite_runtime_plugin_test_fuzzer] for an example of a working example of
......
...@@ -106,5 +106,8 @@ if (use_libfuzzer) { ...@@ -106,5 +106,8 @@ if (use_libfuzzer) {
public_deps = [ public_deps = [
"//third_party/protobuf:protobuf_full", "//third_party/protobuf:protobuf_full",
] ]
sources = [
"dummy.cc",
]
} }
} }
// Copyright 2018 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.
//
// Dummy file used to ensure that wrapper libraries get built on non-Linux
// platforms.
...@@ -15,9 +15,9 @@ import("//testing/libfuzzer/fuzzer_test.gni") ...@@ -15,9 +15,9 @@ import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
template("fuzzable_proto_library") { template("fuzzable_proto_library") {
forward_variables_from(invoker, "*")
if (use_libfuzzer) { if (use_libfuzzer) {
proto_library("proto_library_" + target_name) { proto_library("proto_library_" + target_name) {
forward_variables_from(invoker, "*")
assert(current_toolchain == host_toolchain) assert(current_toolchain == host_toolchain)
if (!defined(deps)) { if (!defined(deps)) {
deps = [] deps = []
...@@ -42,27 +42,22 @@ template("fuzzable_proto_library") { ...@@ -42,27 +42,22 @@ template("fuzzable_proto_library") {
link_target_type = "static_library" link_target_type = "static_library"
} }
# Use a static_library for the build target with target_name or # By making target a static_library or source_set, we can add protobuf_full
# source_set. That way we can also force dependencies to build using # to public_deps.
# protobuf_full.
target(link_target_type, target_name) { target(link_target_type, target_name) {
sources = [
"//third_party/libprotobuf-mutator/dummy.cc",
]
public_deps = [ public_deps = [
":proto_library_" + target_name, ":proto_library_" + target_name,
"//third_party/libprotobuf-mutator:protobuf_full", "//third_party/libprotobuf-mutator:protobuf_full",
] ]
# Don't bother doing builds for CF if we aren't on Linux because of build
# breakages on Mac.
# TODO(crbug.com/869035): Figure out what is causing this issue and fix
# instead of working around it.
if (!is_linux) {
all_dependent_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
} }
} else { } else {
# fuzzable_proto_library should behave like a proto_library when # fuzzable_proto_library should behave like a proto_library when
# !use_libfuzzer. # !use_libfuzzer.
proto_library(target_name) { proto_library(target_name) {
forward_variables_from(invoker, "*")
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment