From c6ccd539e857263b96a05bcb8baac069e90e9f5c Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 4 Feb 2022 18:48:05 +0000 Subject: [PATCH] tint->dawn: Move src/fuzzers/dawn -> src/dawn/fuzzers This has already been moved once, but with more consideration, there's far less fuzzer-related stuff to put in the same root directory here. Bug: dawn:1275 Change-Id: Ic4bb556d9a9f104293cca3316cae84b66a6362b6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79104 Reviewed-by: Corentin Wallez Commit-Queue: Ben Clayton --- BUILD.gn | 1 + docs/dawn/overview.md | 4 +- src/dawn/fuzzers/BUILD.gn | 124 ++++++++++++++++++ .../DawnWireServerAndD3D12BackendFuzzer.cpp | 0 .../DawnWireServerAndFrontendFuzzer.cpp | 0 .../DawnWireServerAndVulkanBackendFuzzer.cpp | 0 .../fuzzers}/DawnWireServerFuzzer.cpp | 0 .../fuzzers}/DawnWireServerFuzzer.h | 0 .../fuzzers}/StandaloneFuzzerMain.cpp | 0 src/fuzzers/dawn/BUILD.gn | 114 +--------------- 10 files changed, 133 insertions(+), 110 deletions(-) create mode 100644 src/dawn/fuzzers/BUILD.gn rename src/{fuzzers/dawn => dawn/fuzzers}/DawnWireServerAndD3D12BackendFuzzer.cpp (100%) rename src/{fuzzers/dawn => dawn/fuzzers}/DawnWireServerAndFrontendFuzzer.cpp (100%) rename src/{fuzzers/dawn => dawn/fuzzers}/DawnWireServerAndVulkanBackendFuzzer.cpp (100%) rename src/{fuzzers/dawn => dawn/fuzzers}/DawnWireServerFuzzer.cpp (100%) rename src/{fuzzers/dawn => dawn/fuzzers}/DawnWireServerFuzzer.h (100%) rename src/{fuzzers/dawn => dawn/fuzzers}/StandaloneFuzzerMain.cpp (100%) diff --git a/BUILD.gn b/BUILD.gn index 68a853a91a..7f9a6a9b53 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("scripts/dawn_overrides_with_defaults.gni") group("all") { testonly = true deps = [ + "src/dawn/fuzzers", "src/dawn/native:webgpu_dawn", "src/fuzzers/dawn:dawn_fuzzers", "src/tests:dawn_tests", diff --git a/docs/dawn/overview.md b/docs/dawn/overview.md index 1f934fd6d4..c15ef1c619 100644 --- a/docs/dawn/overview.md +++ b/docs/dawn/overview.md @@ -15,12 +15,12 @@ This repository contains the implementation of Dawn, which is itself composed of - [`src`](../src): - [`dawn`](../src/dawn): root directory for Dawn code - [`common`](../src/dawn/common): helper code that is allowed to be used by Dawn's core libraries, `dawn_native` and `dawn_wire`. Also allowed for use in all other Dawn targets. + - [`fuzzers`](../src/dawn/fuzzers): various fuzzers for Dawn that are running in [Clusterfuzz](https://google.github.io/clusterfuzz/). - [`native`](../src/dawn/native): code for the implementation of WebGPU on top of graphics APIs. Files in this folder are the "frontend" while subdirectories are "backends". + - ``: code for the implementation of the backend on a specific graphics API, for example `d3d12`, `metal` or `vulkan`. - [`wire`](../src/dawn/wire): code for an implementation of WebGPU as a client-server architecture. - [`utils`](../src/dawn/utils): helper code to use Dawn used by tests and samples but disallowed for `dawn_native` and `dawn_wire`. - [`platform`](../src/dawn/platform): definition of interfaces for dependency injection in `dawn_native` or `dawn_wire`. - - ``: code for the implementation of the backend on a specific graphics API, for example `d3d12`, `metal` or `vulkan`. - - [`fuzzers`](../src/dawn/fuzzers): various fuzzers for Dawn that are running in [Clusterfuzz](https://google.github.io/clusterfuzz/). - [`include`](../src/include): public headers with subdirectories for each library. Note that some headers are auto-generated and not present directly in the directory. - [`tests`](../src/tests): - [`end2end`](../src/tests/end2end): tests for the execution of the WebGPU API and require a GPU to run. diff --git a/src/dawn/fuzzers/BUILD.gn b/src/dawn/fuzzers/BUILD.gn new file mode 100644 index 0000000000..f7ea2a044d --- /dev/null +++ b/src/dawn/fuzzers/BUILD.gn @@ -0,0 +1,124 @@ +# Copyright 2018 The Dawn Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("../../../scripts/dawn_overrides_with_defaults.gni") + +# We only have libfuzzer in Chromium builds but if we build fuzzer targets only +# there, we would risk breaking fuzzer targets all the time when making changes +# to Dawn. To avoid that, we make fuzzer targets compile in standalone builds +# as well with a dawn_fuzzer_test target that acts like Chromium's fuzzer_test. +# +# The standalone fuzzer targets are able to run a single fuzzer input which +# could help reproduce fuzzer crashes more easily because you don't need a +# whole Chromium checkout. + +if (build_with_chromium) { + import("//testing/libfuzzer/fuzzer_test.gni") + + # In Chromium build we just proxy everything to the real fuzzer_test + template("dawn_fuzzer_test") { + fuzzer_test(target_name) { + forward_variables_from(invoker, "*") + } + } +} else { + import("//testing/test.gni") + + # In standalone build we do something similar to fuzzer_test. + template("dawn_fuzzer_test") { + test(target_name) { + forward_variables_from(invoker, + [ + "asan_options", + "cflags", + "cflags_cc", + "check_includes", + "defines", + "deps", + "include_dirs", + "sources", + ]) + + if (defined(asan_options)) { + not_needed([ "asan_options" ]) + } + + if (!defined(configs)) { + configs = [] + } + + # Weirdly fuzzer_test uses a special variable for additional configs. + if (defined(invoker.additional_configs)) { + configs += invoker.additional_configs + } + + sources += [ "StandaloneFuzzerMain.cpp" ] + } + } +} + +static_library("dawn_wire_server_fuzzer_common") { + sources = [ + "DawnWireServerFuzzer.cpp", + "DawnWireServerFuzzer.h", + ] + public_deps = [ + "${dawn_root}/src/dawn:cpp", + "${dawn_root}/src/dawn:proc", + "${dawn_root}/src/dawn/common", + "${dawn_root}/src/dawn/native:static", + "${dawn_root}/src/dawn/utils", + "${dawn_root}/src/dawn/wire:static", + ] +} + +dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") { + sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ] + + deps = [ ":dawn_wire_server_fuzzer_common" ] + + additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] +} + +if (is_win) { + dawn_fuzzer_test("dawn_wire_server_and_d3d12_backend_fuzzer") { + sources = [ "DawnWireServerAndD3D12BackendFuzzer.cpp" ] + + deps = [ ":dawn_wire_server_fuzzer_common" ] + + additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] + } +} + +dawn_fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") { + sources = [ "DawnWireServerAndVulkanBackendFuzzer.cpp" ] + + deps = [ ":dawn_wire_server_fuzzer_common" ] + + additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] +} + +# A group target to build all the fuzzers +group("fuzzers") { + testonly = true + deps = [ + ":dawn_wire_server_and_frontend_fuzzer", + ":dawn_wire_server_and_vulkan_backend_fuzzer", + ] + + if (is_win) { + deps += [ ":dawn_wire_server_and_d3d12_backend_fuzzer" ] + } +} diff --git a/src/fuzzers/dawn/DawnWireServerAndD3D12BackendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp similarity index 100% rename from src/fuzzers/dawn/DawnWireServerAndD3D12BackendFuzzer.cpp rename to src/dawn/fuzzers/DawnWireServerAndD3D12BackendFuzzer.cpp diff --git a/src/fuzzers/dawn/DawnWireServerAndFrontendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp similarity index 100% rename from src/fuzzers/dawn/DawnWireServerAndFrontendFuzzer.cpp rename to src/dawn/fuzzers/DawnWireServerAndFrontendFuzzer.cpp diff --git a/src/fuzzers/dawn/DawnWireServerAndVulkanBackendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp similarity index 100% rename from src/fuzzers/dawn/DawnWireServerAndVulkanBackendFuzzer.cpp rename to src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp diff --git a/src/fuzzers/dawn/DawnWireServerFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp similarity index 100% rename from src/fuzzers/dawn/DawnWireServerFuzzer.cpp rename to src/dawn/fuzzers/DawnWireServerFuzzer.cpp diff --git a/src/fuzzers/dawn/DawnWireServerFuzzer.h b/src/dawn/fuzzers/DawnWireServerFuzzer.h similarity index 100% rename from src/fuzzers/dawn/DawnWireServerFuzzer.h rename to src/dawn/fuzzers/DawnWireServerFuzzer.h diff --git a/src/fuzzers/dawn/StandaloneFuzzerMain.cpp b/src/dawn/fuzzers/StandaloneFuzzerMain.cpp similarity index 100% rename from src/fuzzers/dawn/StandaloneFuzzerMain.cpp rename to src/dawn/fuzzers/StandaloneFuzzerMain.cpp diff --git a/src/fuzzers/dawn/BUILD.gn b/src/fuzzers/dawn/BUILD.gn index 1dca9c37d3..a2756c70c4 100644 --- a/src/fuzzers/dawn/BUILD.gn +++ b/src/fuzzers/dawn/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright 2018 The Dawn Authors +# Copyright 2022 The Dawn Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,113 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/build.gni") -import("../../../scripts/dawn_overrides_with_defaults.gni") - -# We only have libfuzzer in Chromium builds but if we build fuzzer targets only -# there, we would risk breaking fuzzer targets all the time when making changes -# to Dawn. To avoid that, we make fuzzer targets compile in standalone builds -# as well with a dawn_fuzzer_test target that acts like Chromium's fuzzer_test. -# -# The standalone fuzzer targets are able to run a single fuzzer input which -# could help reproduce fuzzer crashes more easily because you don't need a -# whole Chromium checkout. - -if (build_with_chromium) { - import("//testing/libfuzzer/fuzzer_test.gni") - - # In Chromium build we just proxy everything to the real fuzzer_test - template("dawn_fuzzer_test") { - fuzzer_test(target_name) { - forward_variables_from(invoker, "*") - } - } -} else { - import("//testing/test.gni") - - # In standalone build we do something similar to fuzzer_test. - template("dawn_fuzzer_test") { - test(target_name) { - forward_variables_from(invoker, - [ - "asan_options", - "cflags", - "cflags_cc", - "check_includes", - "defines", - "deps", - "include_dirs", - "sources", - ]) - - if (defined(asan_options)) { - not_needed([ "asan_options" ]) - } - - if (!defined(configs)) { - configs = [] - } - - # Weirdly fuzzer_test uses a special variable for additional configs. - if (defined(invoker.additional_configs)) { - configs += invoker.additional_configs - } - - sources += [ "StandaloneFuzzerMain.cpp" ] - } - } -} - -static_library("dawn_wire_server_fuzzer_common") { - sources = [ - "DawnWireServerFuzzer.cpp", - "DawnWireServerFuzzer.h", - ] - public_deps = [ - "${dawn_root}/src/dawn:cpp", - "${dawn_root}/src/dawn:proc", - "${dawn_root}/src/dawn/common", - "${dawn_root}/src/dawn/native:static", - "${dawn_root}/src/dawn/utils", - "${dawn_root}/src/dawn/wire:static", - ] -} - -dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") { - sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ] - - deps = [ ":dawn_wire_server_fuzzer_common" ] - - additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] -} - -if (is_win) { - dawn_fuzzer_test("dawn_wire_server_and_d3d12_backend_fuzzer") { - sources = [ "DawnWireServerAndD3D12BackendFuzzer.cpp" ] - - deps = [ ":dawn_wire_server_fuzzer_common" ] - - additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] - } -} - -dawn_fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") { - sources = [ "DawnWireServerAndVulkanBackendFuzzer.cpp" ] - - deps = [ ":dawn_wire_server_fuzzer_common" ] - - additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] -} - -# A group target to build all the fuzzers +################################################################################ +# Build target aliases +# TODO(crbug.com/dawn/1275) - remove these +################################################################################ group("dawn_fuzzers") { + public_deps = [ "../../dawn/fuzzers" ] testonly = true - deps = [ - ":dawn_wire_server_and_frontend_fuzzer", - ":dawn_wire_server_and_vulkan_backend_fuzzer", - ] - - if (is_win) { - deps += [ ":dawn_wire_server_and_d3d12_backend_fuzzer" ] - } }