Stream: general

Topic: port of Clang running on Wasm and targeting Wasm


view this post on Zulip Catherine (whitequark) (Jul 13 2024 at 22:39):

There's been a few demos of this over the years, but nothing went upstream or became widely used. I decided to upstream this, so I wrote an LLVM RFC, sent a pull request currently undergoing review, and set up a build harness with continuous integration under the YoWASP project umbrella to make sure LLVM doesn't regress on Wasm support. (I'll enable daily builds once the PR is merged.)

The build harness produces Clang and LLD built for Wasm with only the Wasm target enabled, and includes a build of compiler-rt, wasi-libc, and libcxxabi/libcxx. (Targeting wasm32-wasip1 only because I still find components incredibly confusing to work with on toolchain level, and because I'm still not quite sure if I want to have the with/without threads variants or if I want to build just the former.) Unfortunately I couldn't reuse the build scripts from wasi-sdk, at least for the moment.

The next steps for me would be to add an npm package wrapping clang.wasm/lld.wasm into a pure function that can be used from other applications, like the YoWASP toolchain VS Code plugin. In the end, the Wasm build of Clang will be used to compile C++ simulation models that can be produced by Yosys or other language frontends like Spade, in order to run high(er) performance digital design simulations.

All of this is making EDA both accessible and reliable like never before.

FWIW GitHub - olimpiadi-informatica/wasm-compilers: Tools to run LLVM in a WASI environment builds a wasi-threads version of llvm (plus a couple of other useful things) - it鈥檚 not based on @whitequark鈥檚 patches (yet), but it will be soon 馃檪
See also the RFC. This patch makes it possible to build LLVM, Clang, and LLD for WASI/WebAssembly. This patch introduces conditionals of the form defined(__wasi__) or defined(__wasm__) wherever ne...
Unofficial clang WebAssembly packages. Contribute to YoWASP/clang development by creating an account on GitHub.
Common runtime for YoWASP packages deployed to NPM, interfacing with Node.js and the browser - YoWASP/runtime-js
YoWASP toolchain for Visual Studio Code. Contribute to YoWASP/vscode development by creating an account on GitHub.

Last updated: Dec 23 2024 at 13:07 UTC