Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlastair Donaldson <afdx@google.com>2021-07-13 21:45:01 +0300
committerGitHub <noreply@github.com>2021-07-13 21:45:01 +0300
commit2299b710de6cac0e883b5e4d5ef231ba8c01a9d9 (patch)
treebaea41993f709d464d1bd3ff08564afb504ee773 /tools
parentd432bebb113d3b804cbee769817906175e0b7544 (diff)
spirv-fuzz: support building using gn (#4365)
Adds support for building spirv-fuzz using gn. Updates the protobuf dependency to the version used by Chromium. Fixes #4372.
Diffstat (limited to 'tools')
-rw-r--r--tools/fuzz/fuzz.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/fuzz/fuzz.cpp b/tools/fuzz/fuzz.cpp
index 422bea53b..de72b2cd4 100644
--- a/tools/fuzz/fuzz.cpp
+++ b/tools/fuzz/fuzz.cpp
@@ -673,6 +673,19 @@ void DumpTransformationsBinary(
transformations_file.close();
}
+// The Chromium project applies the following patch to the protobuf library:
+//
+// source.chromium.org/chromium/chromium/src/+/main:third_party/protobuf/patches/0003-remove-static-initializers.patch
+//
+// This affects how Status objects must be constructed. This method provides a
+// convenient way to get the OK status that works both with and without the
+// patch. With the patch OK is a StatusPod, from which a Status can be
+// constructed. Without the patch, OK is already a Status, and we harmlessly
+// copy-construct the result from it.
+google::protobuf::util::Status GetProtobufOkStatus() {
+ return google::protobuf::util::Status(google::protobuf::util::Status::OK);
+}
+
// Dumps |transformations| to file |filename| in JSON format. Useful for
// interactive debugging.
void DumpTransformationsJson(
@@ -683,7 +696,7 @@ void DumpTransformationsJson(
json_options.add_whitespace = true;
auto json_generation_status = google::protobuf::util::MessageToJsonString(
transformations, &json_string, json_options);
- if (json_generation_status == google::protobuf::util::Status::OK) {
+ if (json_generation_status == GetProtobufOkStatus()) {
std::ofstream transformations_json_file(filename);
transformations_json_file << json_string;
transformations_json_file.close();
@@ -734,9 +747,8 @@ int main(int argc, const char** argv) {
std::string facts_json_string((std::istreambuf_iterator<char>(facts_input)),
std::istreambuf_iterator<char>());
facts_input.close();
- if (google::protobuf::util::Status::OK !=
- google::protobuf::util::JsonStringToMessage(facts_json_string,
- &initial_facts)) {
+ if (GetProtobufOkStatus() != google::protobuf::util::JsonStringToMessage(
+ facts_json_string, &initial_facts)) {
spvtools::Error(FuzzDiagnostic, nullptr, {}, "Error reading facts data");
return 1;
}
@@ -816,7 +828,7 @@ int main(int argc, const char** argv) {
json_options.add_whitespace = true;
auto json_generation_status = google::protobuf::util::MessageToJsonString(
transformations_applied, &json_string, json_options);
- if (json_generation_status != google::protobuf::util::Status::OK) {
+ if (json_generation_status != GetProtobufOkStatus()) {
spvtools::Error(FuzzDiagnostic, nullptr, {},
"Error writing out transformations in JSON format");
return 1;