From eb1ca45df7676fff92f5b13627ab9c0ccc29c292 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Sat, 25 Jan 2020 02:14:39 +0000 Subject: [PATCH] Fix Vulkan fuzzer on mac_libfuzzer_chrome_asan This commit fixes two problems: 1) It includes testing/libfuzzer/libfuzzer_exports.h which exports the LLVMFuzzerInitialize symbol. On Mac, not doing so causes it to be removed by the linker. 2) It makes it so that dawn_use_swiftshader is enabled by default when fuzzing, and enabling swiftshader also enables the Vulkan backend. Bug: chromium:1042426 Change-Id: Ic0ae0d59c91476b0079148f33a4b1ebd1cc6743c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15462 Reviewed-by: Kai Ninomiya Commit-Queue: Kai Ninomiya --- scripts/dawn_features.gni | 22 ++++++++++--------- .../DawnWireServerAndVulkanBackendFuzzer.cpp | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni index 2ef8e15190..37a32a05c0 100644 --- a/scripts/dawn_features.gni +++ b/scripts/dawn_features.gni @@ -18,6 +18,16 @@ if (build_with_chromium) { import("//build/config/sanitizers/sanitizers.gni") } +declare_args() { + # Enables usage of swiftshader on the Vulkan backend. + # Note that this will only work in standalone and in projects that set the + # dawn_swiftshader_dir variable in build_overrides/dawn.gni + # Because of how the Vulkan loader works, setting this makes Dawn only able + # to find the Swiftshader ICD and not the others. + # Enabled by default when fuzzing. + dawn_use_swiftshader = build_with_chromium && use_fuzzing_engine +} + declare_args() { # Enable Dawn's ASSERTs even in release builds dawn_always_assert = false @@ -42,7 +52,8 @@ declare_args() { dawn_enable_opengl = is_linux && !is_chromeos # Enables the compilation of Dawn's Vulkan backend - dawn_enable_vulkan = is_linux || is_win || is_fuchsia || is_android + dawn_enable_vulkan = + is_linux || is_win || is_fuchsia || is_android || dawn_use_swiftshader # Enable use of reflection compiler in spirv-cross. This is needed # if performing reflection on systems that the platform language @@ -63,15 +74,6 @@ declare_args() { # Put them in two separate declare_args() when setting the value of one # argument based on another. declare_args() { - # Enables usage of swiftshader on the Vulkan backend. - # Note that this will only work in standalone and in projects that set the - # dawn_swiftshader_dir variable in build_overrides/dawn.gni - # Because of how the Vulkan loader works, setting this make Dawn only able - # to find the Swiftshader ICD and not the others. - # Enabled by default when fuzzing. - dawn_use_swiftshader = - dawn_enable_vulkan && build_with_chromium && use_fuzzing_engine - # Uses our built version of Vulkan validation layers dawn_enable_vulkan_validation_layers = dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win) diff --git a/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp b/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp index 54fc8cd5f6..b23b132e8c 100644 --- a/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp +++ b/src/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp @@ -15,6 +15,7 @@ #include "DawnWireServerFuzzer.h" #include "dawn_native/DawnNative.h" +#include "testing/libfuzzer/libfuzzer_exports.h" extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { return DawnWireServerFuzzer::Initialize(argc, argv);