Replies: 6 comments 16 replies
-
The ABI incompatibility between Clang and Rust for wasm-unknown-unknown causes issues for this. The easiest way around that currently is to use the Rust port of tree sitter here: https://github.com/shadaj/tree-sitter-c2rust/tree/c2rust-master |
Beta Was this translation helpful? Give feedback.
-
I've tried to compile |
Beta Was this translation helpful? Give feedback.
-
@liamrosenfeld I was hoping you could tell me a bit more about what you meant in the comment above. I too want to compile treesiter into a wasm file that can be loaded on the web. I'm confused about what you meant by using tree-sitter from rust for wasm32-unknown-unknown. Sorry for bugging you! |
Beta Was this translation helpful? Give feedback.
-
Would this also work for |
Beta Was this translation helpful? Give feedback.
-
It's a bit different, but I was able to compile treesitter and its parsers as part of my markdown to html compiler crate femark to wasm via the wasi target, and deploy in the browser. I wrote about that process here: https://benw.is/posts/compiling-rust-to-wasi
…On Mon, Apr 22, 2024, at 8:03 AM, Sven wrote:
> Yeah now that rust-lang/rust#117919 <rust-lang/rust#117919> has merged, you can build it on nightly. However, there is a small import issue in tree sitter that my PR here fixes #3304 <#3304>. When using that fix, the only thing that is needed is a shim C standard library (like an extended version of cacticouncil/lilypad@`main`/wasm-sysroot <https://github.com/cacticouncil/lilypad/tree/main/wasm-sysroot>)
>
Would this also work for `tree-sitter-lang` packages? I tried patching them with a custom `patch.crates-io` entry, but that didn't work. Maybe the shim was missing. It couldn't find `stdlib.h`.
—
Reply to this email directly, view it on GitHub <#1550 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABVBTCNX7GXA5T7R3BNJ6CLY6URFXAVCNFSM5KQKWJUKU5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TSMJZGAZDCNY>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I had luck with using this version of |
Beta Was this translation helpful? Give feedback.
-
Assume I have a library that is written in Rust and that uses tree-sitter via its rust bindings. Next, I want to compile that library to WASM and expose its features via
wasm_bindgen
.As a sample I have the snippet below and I try to compile it via
cargo b --target wasm32-unknown-unknown
(without success). Did anyone try this? Should this be asked in some Rust forum or somewhere else?Published a simple sample here: https://github.com/jrieken/rust-wasm (run cargo b --target wasm32-unknown-unknown, easiest with dev containers)
/cc @dcreager
Beta Was this translation helpful? Give feedback.
All reactions