Skip to content

Commit a9cfc25

Browse files
committed
fix: allow usage of Go WASI policies built by go 1.26
These changes are required to run policies built by the official go compiler, starting from release 1.26.0 Signed-off-by: Flavio Castelli <fcastelli@suse.com>
1 parent e9aee77 commit a9cfc25

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

crates/policy-evaluator/Cargo.toml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,29 @@ wasmtime = { workspace = true, default-features = true }
6666
# Workaround for https://github.com/bytecodealliance/wasmtime/issues/12217
6767
[target.'cfg(all(target_os = "macos", target_arch = "x86_64"))'.dependencies]
6868
wasmtime = { workspace = true, features = [
69-
"addr2line",
70-
"async",
71-
"cache",
72-
"compile-time-builtins",
73-
"component-model",
74-
"component-model-async",
75-
"coredump",
76-
"cranelift",
77-
"debug",
78-
"debug-builtins",
79-
"demangle",
80-
"gc",
81-
"gc-drc",
82-
"gc-null",
83-
"once_cell",
84-
"parallel-compilation",
85-
"pooling-allocator",
86-
"profiling",
87-
"runtime",
88-
"std",
89-
"threads",
90-
"wasmtime-jit-debug",
91-
"wasmtime-jit-icache-coherence",
92-
"wat",
69+
'addr2line',
70+
'anyhow',
71+
'async',
72+
'backtrace',
73+
'cache',
74+
'compile-time-builtins',
75+
'component-model',
76+
'component-model-async',
77+
'coredump',
78+
'cranelift',
79+
'debug',
80+
'debug-builtins',
81+
'demangle',
82+
'gc',
83+
'gc-drc',
84+
'gc-null',
85+
'parallel-compilation',
86+
'pooling-allocator',
87+
'profiling',
88+
'runtime',
89+
'std',
90+
'threads',
91+
'wat',
9392
] }
9493

9594

crates/policy-evaluator/src/policy_evaluator/policy_evaluator_builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ impl PolicyEvaluatorBuilder {
205205
if self.epoch_deadlines.is_some() {
206206
wasmtime_config.epoch_interruption(true);
207207
}
208+
// required by policies built by the official go compiler >= 1.26.0
209+
wasmtime_config.wasm_function_references(true);
208210

209211
wasmtime::Engine::new(&wasmtime_config)
210212
},

crates/policy-server/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ impl PolicyServer {
145145
)
146146
.await;
147147

148-
let mut wasmtime_config = wasmtime::Config::new();
148+
let mut wasmtime_config = wasmtime::Config::default();
149+
// required by policies built by the official go compiler >= 1.26.0
150+
wasmtime_config.wasm_function_references(true);
149151

150152
let any_policy_has_timeout = config.policies.values().any(|policy| match policy {
151153
config::PolicyOrPolicyGroup::Policy {

0 commit comments

Comments
 (0)