-
Notifications
You must be signed in to change notification settings - Fork 313
Open
Description
When trying to use wasm-tools component new, I noticed the realloc-via-memory-grow option.
My intuition was that this provides a default cabi_realloc implementation if the module doesn't contain one. However, I notice that it basically errors out if no cabi_realloc export is provided? (and if one is provided, it just uses that). Am I correct on the purpose of this flag? Not sure exactly what it's supposed to do.
Reproducing the Setup
Here is a simple test for what I'm trying:
A component string.wat
(module
(type (;0;) (func (param i32 i32 i32)))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32 i64) (result i64)))
(import "component:test-package/env" "reverse-string" (func $reverse_import (type 0)))
(global $bump (mut i32) (i32.const 4096))
(func $main (export "main") (param i32 i32) (result i32)
(local $str_ptr i32)
i32.const 100
local.set $str_ptr
local.get 0
local.get 1
local.get $str_ptr
call $reverse_import
local.get $str_ptr
)
(memory (export "memory") 1)
)
A WIT file string.wit
package root:component;
world root {
import component:test-package/env;
export main: func(x: string) -> string;
}
package component:test-package {
interface env {
reverse-string: func(s: string) -> string;
}
}
Running the following commands:
wasm-tools component embed -t -o string-cc.wat string.wat string.wit
wasm-tools component new --realloc-via-memory-grow -t -o string-component.wat string-cc.wat
produces this:
error: failed to encode a component from module
Caused by:
0: module does not export a function named `cabi_realloc`Metadata
Metadata
Assignees
Labels
No labels