Skip to content

Commit 70927ba

Browse files
committed
patches: 0024 MSVC __builtin_expect no-op shim (fixes upstream PR CI)
Upstream PR bytecodealliance/wasm-micro-runtime#4949 failed every `build_iwasm` matrix entry on Windows MSVC with `LNK2019: unresolved external symbol __builtin_expect referenced in function wasm_interp_call_func_bytecode`. The cold-path hints we added in patch 0011 use the GCC/Clang `__builtin_expect` intrinsic; MSVC has no equivalent. Drop-in no-op shim gated on `!defined(__GNUC__) && !defined(__clang__)`. The hints are branch-predictor optimization, not correctness, so dropping them on MSVC is fine. Same change is on the upstream PR branch as commit `0411662d` (separate fixup commit; lands in the PR sequence right after patch 0011's equivalent). Stack-position rationale: patch 0024 (after linmem 0023) inserts 9 lines near the top of `wasm_interp_fast.c` between the SIMDe include guards and `typedef int32 CellType_I32`. Putting it last in the apply-stack avoids shifting line-number anchors for any of the earlier patches.
1 parent c59f4e2 commit 70927ba

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 9999999999999999999999999999999999999999 Mon Sep 17 00:00:00 2026
2+
From: Matt Hargett <plaztiksyke@gmail.com>
3+
Date: Wed, 21 May 2026 13:30:00 -0700
4+
Subject: [PATCH] fast-interp: MSVC `__builtin_expect` no-op shim
5+
6+
Windows MSVC builds (`build_iwasm` matrix on bytecodealliance/wasm-
7+
micro-runtime CI) fail to link `wasm_interp_call_func_bytecode`
8+
because `__builtin_expect` is a GCC/Clang builtin with no MSVC
9+
equivalent. The branch-predictor hints are an optimization, not
10+
correctness, so dropping them on MSVC is fine.
11+
12+
Applied last in our local stack so the line-number anchor lands
13+
in the patch-applied vicinity (the relaxed-SIMD include guard
14+
above + the EH-stack helpers below). On the upstream PR side
15+
the shim lives in the same `wasm_interp_fast.c` commit chain.
16+
---
17+
core/iwasm/interpreter/wasm_interp_fast.c | 9 +++++++++
18+
1 file changed, 9 insertions(+)
19+
20+
diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c
21+
--- a/core/iwasm/interpreter/wasm_interp_fast.c
22+
+++ b/core/iwasm/interpreter/wasm_interp_fast.c
23+
@@ -33,6 +33,15 @@
24+
#include "simde/wasm/relaxed-simd.h"
25+
#endif
26+
#endif
27+
+
28+
+/* MSVC has no `__builtin_expect`; the cold-path hints below are
29+
+ * GCC/Clang only. Provide a no-op fallback so the loop still
30+
+ * compiles on the Windows MSVC build. Branch-predictor hints are
31+
+ * an optimization, not correctness, so dropping them on MSVC is
32+
+ * fine. */
33+
+#if !defined(__GNUC__) && !defined(__clang__)
34+
+#define __builtin_expect(expr, expected) (expr)
35+
+#endif
36+
37+
typedef int32 CellType_I32;
38+
typedef int64 CellType_I64;

0 commit comments

Comments
 (0)