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?
Wasm-ld is designed to link llvm wasm object files, which are not the same thing as wasm modules
I’m not aware of a tool that does what you are describing
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
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: Dec 23 2024 at 13:07 UTC