From 13d14525c4f69c457a6f32b22c93057e45c4852d Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Fri, 20 Jan 2023 00:11:00 +0000 Subject: [PATCH] Fix builds that disable tint_build_spv_reader If tint_build_spv_reader = false is set in a Chrome's build_overrides then the tint_unittests_spv_reader_src begins failing with a bunch of missing spvtools identifiers. Most uses of spv_reader_src include it as a conditional dependency only when tint_build_spv_reader is true, Chrome's `all` target always builds it. This causes problems when critical includes are excluded due to the tint_build_spv_reader setting. The solution is to not make use of the TINT_BUILD_SPV_READER define at all in this subdirectory and instead assume that the entire directory will be included or excluded as needed at a higher level. Additionally, one switch statement in tint_common_fuzzer needed to have the scope of it's TINT_BUILD_SPV_READER exclusion reduced so that it wouldn't trigger warnings that not all enum values were covered. Bug: dawn:286 Change-Id: I53518e2fda497fe976721b5f087e2e21a170f5dd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117244 Reviewed-by: dan sinclair Kokoro: Kokoro Commit-Queue: Brandon Jones Reviewed-by: Ben Clayton --- src/tint/fuzzers/tint_common_fuzzer.cc | 9 +++++---- src/tint/reader/spirv/parser_impl.h | 2 -- src/tint/reader/spirv/parser_impl_test_helper.h | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/tint/fuzzers/tint_common_fuzzer.cc b/src/tint/fuzzers/tint_common_fuzzer.cc index 15ab7d8b69..11cdf76e6c 100644 --- a/src/tint/fuzzers/tint_common_fuzzer.cc +++ b/src/tint/fuzzers/tint_common_fuzzer.cc @@ -149,8 +149,8 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { #endif switch (input_) { -#if TINT_BUILD_WGSL_READER case InputFormat::kWGSL: { +#if TINT_BUILD_WGSL_READER // Clear any existing diagnostics, as these will hold pointers to file_, // which we are about to release. diagnostics_ = {}; @@ -160,11 +160,12 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { dump_input_data(str, ".wgsl"); } program = reader::wgsl::Parse(file_.get()); +#endif // TINT_BUILD_WGSL_READER break; } -#endif // TINT_BUILD_WGSL_READER -#if TINT_BUILD_SPV_READER + case InputFormat::kSpv: { +#if TINT_BUILD_SPV_READER // `spirv_input` has been initialized with the capacity to store `size / // sizeof(uint32_t)` uint32_t values. If `size` is not a multiple of // sizeof(uint32_t) then not all of `data` can be copied into @@ -177,9 +178,9 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { dump_input_data(spirv_input, ".spv"); } program = reader::spirv::Parse(spirv_input); +#endif // TINT_BUILD_SPV_READER break; } -#endif // TINT_BUILD_SPV_READER } if (!program.IsValid()) { diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h index 9ff9033b28..7713734faf 100644 --- a/src/tint/reader/spirv/parser_impl.h +++ b/src/tint/reader/spirv/parser_impl.h @@ -25,7 +25,6 @@ #include "src/tint/utils/compiler_macros.h" #include "src/tint/utils/hashmap.h" -#if TINT_BUILD_SPV_READER TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF); TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST); TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION); @@ -35,7 +34,6 @@ TINT_END_DISABLE_WARNING(WEAK_VTABLES); TINT_END_DISABLE_WARNING(SIGN_CONVERSION); TINT_END_DISABLE_WARNING(OLD_STYLE_CAST); TINT_END_DISABLE_WARNING(NEWLINE_EOF); -#endif #include "src/tint/program_builder.h" #include "src/tint/reader/reader.h" diff --git a/src/tint/reader/spirv/parser_impl_test_helper.h b/src/tint/reader/spirv/parser_impl_test_helper.h index d1b0e35f84..ea0e37e483 100644 --- a/src/tint/reader/spirv/parser_impl_test_helper.h +++ b/src/tint/reader/spirv/parser_impl_test_helper.h @@ -23,7 +23,6 @@ #include "src/tint/utils/compiler_macros.h" -#if TINT_BUILD_SPV_READER TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF); TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST); TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION); @@ -33,7 +32,6 @@ TINT_END_DISABLE_WARNING(WEAK_VTABLES); TINT_END_DISABLE_WARNING(SIGN_CONVERSION); TINT_END_DISABLE_WARNING(OLD_STYLE_CAST); TINT_END_DISABLE_WARNING(NEWLINE_EOF); -#endif #include "gtest/gtest.h" #include "src/tint/demangler.h"