Stream: general

Topic: minimal wasm-ld example?


view this post on Zulip BC (May 10 2020 at 04:08):

Hello. Does anyone have a minimal example of static linking of two wasm files (outputs of wat2wasm) using wasm-ld? I have two wat files. One exports a function "f" that the other imports. Using wat2wasm with --relocatable followed by wasm-ld-11 gives the error wasm-ld-11: error: a.wasm: Out of order section type: 0 This gist https://gist.github.com/bcdroid/57c5cf048c585d60894b2e91c5b7119a contains the wat files and commands I used. Is this kind of static linking intended? Do I need to create a custom section in the wasm files to control static linking?

GitHub Gist: instantly share code, notes, and snippets.

view this post on Zulip Pat Hickey (May 12 2020 at 18:21):

Wasm-ld is designed to link llvm wasm object files, which are not the same thing as wasm modules

view this post on Zulip Pat Hickey (May 12 2020 at 18:22):

I’m not aware of a tool that does what you are describing

view this post on Zulip Pat Hickey (May 12 2020 at 18:25):

Connecting imports to exports is functionality typically provided by the runtime. The apis for specifying how this works are specific to runtimes (js api works one way, Wasmtime another). There is currently some work going on to describe this sort of cross-module linking in a standard way, called the Linking proposal, which is closely related to the Interface Types proposal

view this post on Zulip BC (May 12 2020 at 19:12):

Pat Hickey said:

Wasm-ld is designed to link llvm wasm object files, which are not the same thing as wasm modules

Thank you very much for that! I will try linking in the runtime instead (and read through the Linking proposal).

In case it is of interest to anyone, the context is that I am teaching a class on wasm to students with a little Python but no systems programming experience.


Last updated: Nov 22 2024 at 16:03 UTC