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 <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Austin Eng 2020-01-25 02:14:39 +00:00 committed by Commit Bot service account
parent 1d036f7766
commit eb1ca45df7
2 changed files with 13 additions and 10 deletions

View File

@ -18,6 +18,16 @@ if (build_with_chromium) {
import("//build/config/sanitizers/sanitizers.gni") 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() { declare_args() {
# Enable Dawn's ASSERTs even in release builds # Enable Dawn's ASSERTs even in release builds
dawn_always_assert = false dawn_always_assert = false
@ -42,7 +52,8 @@ declare_args() {
dawn_enable_opengl = is_linux && !is_chromeos dawn_enable_opengl = is_linux && !is_chromeos
# Enables the compilation of Dawn's Vulkan backend # 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 # Enable use of reflection compiler in spirv-cross. This is needed
# if performing reflection on systems that the platform language # 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 # Put them in two separate declare_args() when setting the value of one
# argument based on another. # argument based on another.
declare_args() { 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 # Uses our built version of Vulkan validation layers
dawn_enable_vulkan_validation_layers = dawn_enable_vulkan_validation_layers =
dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win) dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win)

View File

@ -15,6 +15,7 @@
#include "DawnWireServerFuzzer.h" #include "DawnWireServerFuzzer.h"
#include "dawn_native/DawnNative.h" #include "dawn_native/DawnNative.h"
#include "testing/libfuzzer/libfuzzer_exports.h"
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
return DawnWireServerFuzzer::Initialize(argc, argv); return DawnWireServerFuzzer::Initialize(argc, argv);