[tint] Add build guard for IR dumping This is enabled by default when building Dawn standalone, but off by default when building in Chromium. Bug: 498327991 Change-Id: I3204d79ea6b4e92d0639f03548029a3a79e2fb59 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/300795 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: James Price <jrprice@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index 549f5b6..fd0ef46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -259,6 +259,7 @@ option(TINT_BUILD_TINTD "Build the WGSL language server" OFF) +option(TINT_ENABLE_IR_DUMPING "Enable runtime control for dumping IR" ON) option(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF) option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF) option(TINT_RANDOMIZE_HASHES "Randomize the hash seed value to detect non-deterministic output" OFF) @@ -333,6 +334,7 @@ message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}") message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}") message(STATUS "Tint build tintd: ${TINT_BUILD_TINTD}") +message(STATUS "Tint enable IR dumping: ${TINT_ENABLE_IR_DUMPING}") message(STATUS "Tint enable break in debugger: ${TINT_ENABLE_BREAK_IN_DEBUGGER}") message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}") message(STATUS "Tint randomize hashes: ${TINT_RANDOMIZE_HASHES}")
diff --git a/scripts/tint_overrides_with_defaults.gni b/scripts/tint_overrides_with_defaults.gni index c512b3a..48cdc07 100644 --- a/scripts/tint_overrides_with_defaults.gni +++ b/scripts/tint_overrides_with_defaults.gni
@@ -84,6 +84,10 @@ tint_build_cmds = tint_standalone } + if (!defined(tint_enable_ir_dumping)) { + tint_enable_ir_dumping = tint_standalone + } + # Build the SPIR-V input reader if (!defined(tint_build_spv_reader)) { tint_build_spv_reader = true
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index e343e8a..95b214c 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn
@@ -146,6 +146,12 @@ defines += [ "TINT_BUILD_FUZZER_VULKAN_SUPPORT=0" ] } + if (tint_enable_ir_dumping) { + defines += [ "TINT_ENABLE_IR_DUMPING=1" ] + } else { + defines += [ "TINT_ENABLE_IR_DUMPING=0" ] + } + include_dirs = [ "${tint_root_dir}/", "${tint_root_dir}/include/",
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 23a1aab..22aa5d4 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt
@@ -75,6 +75,7 @@ target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>) target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_NULL_WRITER=$<BOOL:${TINT_BUILD_NULL_WRITER}>) target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_TINTD=$<BOOL:${TINT_BUILD_TINTD}>) + target_compile_definitions(${TARGET} PUBLIC -DTINT_ENABLE_IR_DUMPING=$<BOOL:${TINT_ENABLE_IR_DUMPING}>) if(TINT_BUILD_FUZZERS) target_compile_options(${TARGET} PRIVATE "-fsanitize=fuzzer")
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc index 0f9687e..1330079 100644 --- a/src/tint/lang/core/ir/validator.cc +++ b/src/tint/lang/core/ir/validator.cc
@@ -129,7 +129,9 @@ namespace { /// Prints out the current IR state, iff ir.dump_ir_when_validating is set. -void DumpIRIfEnabled(const Module& ir, std::string_view msg) { +void DumpIRIfEnabled([[maybe_unused]] const Module& ir, + [[maybe_unused]] const std::string_view msg) { +#if TINT_ENABLE_IR_DUMPING if (ir.dump_ir_when_validating) { auto printer = StyledTextPrinter::Create(stdout); std::cout << "=========================================================\n"; @@ -137,6 +139,7 @@ std::cout << "=========================================================\n"; printer->Print(Disassembler(ir).Text()); } +#endif } using SupportedStages = tint::EnumSet<Function::PipelineStage>;