Skip to content

Commit 759b45c

Browse files
Generate stubs for WASI functions. They are still needed
1 parent b81af35 commit 759b45c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/tools/wasm-ctor-eval.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class EvallingModuleRunner : public ModuleRunnerBase<EvallingModuleRunner> {
120120
// imports, and fills the rest with fake values since those are dangerous to
121121
// use. Imported globals can't be read anyway; see
122122
// `EvallingModuleRunner::visitGlobalGet`.
123+
// Note: wasi_ modules have stubs generated but won't be called due to the
124+
// special handling in `CtorEvalExternalInterface::getImportedFunction`. We
125+
// still generate the stubs to ensure the link-time validation passes.
123126
std::vector<std::unique_ptr<Module>> buildStubModules(Module& wasm) {
124127
std::map<Name, std::unique_ptr<Module>> modules;
125128

@@ -129,13 +132,6 @@ std::vector<std::unique_ptr<Module>> buildStubModules(Module& wasm) {
129132
Importable* importable =
130133
std::visit([](auto* i) -> Importable* { return i; }, import);
131134

132-
// Ignore WASI functions. They are handled separately in
133-
// `getImportedFunction`.
134-
if (std::holds_alternative<Function*>(import) &&
135-
importable->module.startsWith("wasi_")) {
136-
return;
137-
}
138-
139135
auto [it, inserted] = modules.try_emplace(importable->module, nullptr);
140136
if (inserted) {
141137
it->second = std::make_unique<Module>();

0 commit comments

Comments
 (0)