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 <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Brandon Jones 2023-01-20 00:11:00 +00:00 committed by Dawn LUCI CQ
parent 61d2cf297a
commit 13d14525c4
3 changed files with 5 additions and 8 deletions

View File

@ -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()) {

View File

@ -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"

View File

@ -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"