[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

Joel Dice via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 09:11:33 PDT 2023

dicej created this revision.
Herald added subscribers: pmatos, asb, delcypher, sunfish, hiraditya, jgravelle-google, sbc100, dschuff.
Herald added a project: All.
dicej requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, aheejin.
Herald added projects: clang, LLVM.

This adds support for Emscripten-style shared libraries [1] to the `wasm32-wasi`
target.  Previously, only static linking was supported, and the `-shared` and
`-fPIC` flags were simply ignored.  Now both flags are honored.

Since WASI runtimes do not necessarily include JavaScript support, we cannot
rely on the JS-based Emscripten linker to link shared libraries.  Instead, we
link them using the Component Model proposal [2].

We have prototyped shared library support in `wasi-sdk` [3] and put together a
demo [4] which uses a patched version of `wit-component` [5] to link libraries
using the Component Model.  We plan to submit the required changes upstream to
the respective repositories in the next week or two.

[1] https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
[2] https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md
[3] https://github.com/dicej/wasi-sdk/tree/dynamic-linking
[4] https://github.com/dicej/component-linking-demo
[5] https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component

Signed-off-by: Joel Dice <joel.dice at fermyon.com>

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153293.532688.patch
Type: text/x-patch
Size: 4281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230619/b69d91fd/attachment.bin>

More information about the llvm-commits mailing list