Skip to content

Commit 5614eb1

Browse files
velzieclaude
andcommitted
ci: apply Tint ICE-recovery patch in build_tint.sh
The wasm compile failed: webgpu_shader.cc references tint::internal_compiler_error_recovery, which is a LOCAL patch to Dawn/Tint's ICE handler (longjmp to a host-armed recovery point instead of trapping the whole module on an unsupported shader). The patch lived only as uncommitted edits in the local deps/src/dawn tree; build_tint.sh cloned Dawn fresh and never applied it, so CI's Tint lacked the symbol. Vendor the patch (scripts/patches/tint-ice-recovery.patch) and apply it after the Dawn clone (idempotent). Verified it applies cleanly to a pristine tree. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0147K8KgRMZv4veKN7eANfgw
1 parent 8bb1354 commit 5614eb1

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎scripts/build_tint.sh‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ if [ ! -d "$SRC/dawn" ]; then
1616
fi
1717
cd "$SRC/dawn"
1818

19+
# Patch Tint's ICE handler to longjmp to a host-armed recovery point instead of
20+
# trapping the whole wasm module on an unsupported shader (Blender's WebGPU
21+
# backend arms this around Tint calls — see webgpu_shader.cc's use of
22+
# tint::internal_compiler_error_recovery). Idempotent: only applied when the
23+
# declaration isn't already present.
24+
if ! grep -q "internal_compiler_error_recovery" src/tint/utils/ice/ice.h; then
25+
log "applying tint ICE-recovery patch"
26+
git apply "$ROOT/scripts/patches/tint-ice-recovery.patch"
27+
fi
28+
1929
# Fetch only the deps Tint needs (no gclient): abseil, SPIRV-Tools, SPIRV-Headers.
2030
# NOTE: guard on a real file (abseil's CMakeLists) not just the dir — an
2131
# interrupted first fetch leaves empty dirs that would skip a needed re-fetch.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff --git a/src/tint/utils/ice/ice.cc b/src/tint/utils/ice/ice.cc
2+
index 6649ca3bc2..5f708d0d5f 100644
3+
--- a/src/tint/utils/ice/ice.cc
4+
+++ b/src/tint/utils/ice/ice.cc
5+
@@ -36,6 +36,9 @@
6+
7+
namespace tint {
8+
9+
+// Host-armed recovery point for ICEs (see ice.h). Default: trap as before.
10+
+std::jmp_buf* internal_compiler_error_recovery = nullptr;
11+
+
12+
InternalCompilerError::InternalCompilerError(const char* file,
13+
size_t line,
14+
InternalCompilerErrorCallback callback)
15+
@@ -63,6 +66,14 @@ InternalCompilerError::~InternalCompilerError() {
16+
std::cerr << err.str();
17+
}
18+
19+
+ // If the host armed a recovery point, longjmp out instead of trapping so a
20+
+ // single unsupported shader fails gracefully rather than killing the module.
21+
+ if (internal_compiler_error_recovery) {
22+
+ std::jmp_buf* target = internal_compiler_error_recovery;
23+
+ internal_compiler_error_recovery = nullptr;
24+
+ std::longjmp(*target, 1);
25+
+ }
26+
+
27+
debugger::Break();
28+
29+
#if defined(_MSC_VER) && !defined(__clang__)
30+
diff --git a/src/tint/utils/ice/ice.h b/src/tint/utils/ice/ice.h
31+
index a6fb44df19..c0649cb1a2 100644
32+
--- a/src/tint/utils/ice/ice.h
33+
+++ b/src/tint/utils/ice/ice.h
34+
@@ -28,6 +28,7 @@
35+
#ifndef SRC_TINT_UTILS_ICE_ICE_H_
36+
#define SRC_TINT_UTILS_ICE_ICE_H_
37+
38+
+#include <csetjmp>
39+
#include <optional>
40+
#include <sstream>
41+
#include <string>
42+
@@ -37,6 +38,13 @@
43+
44+
namespace tint {
45+
46+
+/// Host-armed recovery point for Tint internal compiler errors. Tint is built
47+
+/// -fno-exceptions and its ICE handler normally traps the whole (wasm) module.
48+
+/// When this points at a setjmp buffer, the ICE destructor longjmps there
49+
+/// instead, so a single bad shader fails gracefully rather than aborting the
50+
+/// render. Set/cleared by the host around a Tint call; nullptr = default trap.
51+
+extern std::jmp_buf* internal_compiler_error_recovery;
52+
+
53+
/// An instance of InternalCompilerErrorCallbackInfo can be used to set up a callback so that the
54+
/// user of Tint can capture an ICE message before crashing.
55+
struct InternalCompilerErrorCallbackInfo {

0 commit comments

Comments
 (0)