A question about (wasm link)

Hello,
I am currently writing a script for templating WAT code using hoot and ~a week before that was wondering how to link wasm files together. The main examples for WTF8 in guile-ffi-hoot-demo seem to rely on the reflector/js, whereas while (wasm link) has a link procedure, it seems to be unexported.
I am mainly saying this because I intend to be able to run wasm/scheme outside of the browser and as such on runtimes that do not use javascript.

Also: I wonder if linking scheme-wasm files together was a problem for macros without a resident compiler/interpreter|fexprs with the introduction of library-group.

2 Likes

Hi @zardoz! I think maybe there’s some confusion about what (wasm link) is for. The public interface for this module is just the add-stdlib procedure, whose job is to take an incomplete wasm module and add in a standard library, but only the parts that are referenced by the first module. The result is a new module that is fully formed without undefined references. This linker is unrelated to your stated use-case of running Hoot binaries outside of web browsers. It is true that our demos rely on runtimes with a JavaScript host, such as V8 and Spidermonkey, since our primary goal is to run things in web browsers. Hoot is not strictly limited to running in web browsers (or nodejs/deno/etc.), but we’re not aware of any other production wasm runtimes that support both GC and tail calls currently. Is there a specific runtime you were hoping to use? Of course, if you are using Hoot for the wasm toolchain and not Scheme then you can just build things that only use features that are supported by your runtime.

The (hoot stdlib) module defines all of the imports that need to be provided by the host in order to support Scheme: module/hoot/stdlib.scm · main · spritely / Guile Hoot · GitLab

Here’s what the host side of that looks like for JS-based runtimes: js-runtime/reflect.js · main · spritely / Guile Hoot · GitLab

And here’s what the host side looks like from native Guile where we use our wasm interpreter: module/hoot/reflect.scm · main · spritely / Guile Hoot · GitLab

I’m not sure I understand the bit about macros, but maybe this helps: Macros are all evaluated at compile time and the program is then lowered to a form that contains no macros. Hoot is a whole program compiler, and library-group assists with deriving a single program from a collection of modules. The resulting wasm binary does not load modules at runtime.

Hope this helps!

1 Like