Skip to content

Commit cfcb699

Browse files
committed
it's alive! a walk of the ast alerts in the browser. amaze.
This... finally breaks down and requires rust nightly. I've been going to considerable lengths to try to avoid this, but... I earnestly don't think shipping C+Rust to wasm is possible without it. The main new thing here is the "-Zwasm-c-abi=spec" flag. As described in the README diff, it's essential for rust to call into C correctly when both are wasm'd. (It's beyond me why any other mode exists, but I'll... attempt to bite my tongue.) This critical flag was introduced in rust-lang/rust#117919 . Which describes it as "perma-unstable". And gosh I hope that's not actually going to be true... because again, this seems to be flat out *required* for Rust and C to play together in wasm. And also because "perma-unstable" is just a deeply silly concept, period, context-free. I do not understand any possible reason to want to push people *permanently* towards using "unstable" "nightly" compilers. I don't understand how this needs to be said, but creating a situation where the words "permanently unstable" go together is a Bad Idea. Anyway. The "target-feature=+bulk-memory" flag also comes along because without that, we get a "Uncaught RangeError: Maximum call stack size exceeded" error at runtime. It's attributed to "core::intrinsics::copy::precondition_check" called from "memmove". (That doesn't make a ton of sense to me, looking at the code, but... a lot of things don't make sense to me, looking at any of this; add it to the pile.) Whatever the reason, this flag makes it go. And now it's alive. It's taken days. But hello world has landed. Hooray.
1 parent f0a97cb commit cfcb699

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,43 @@ Expect development to prioritize things that are on the path to protocol design
3131
(Codecs are a SMOP. An important one, but a relatively well-known space. We can do those later without a serious risk of problematic unanticipated design feedback cycle.)
3232

3333

34+
Building
35+
--------
36+
37+
This project uses a LOT of tooling from various sources.
38+
The setup may be nontrivial.
39+
40+
### for tree-sitter
41+
42+
There's a tree-sitter CLI tool; you'll need that to compile the grammar
43+
and generate the parser (which comes out as a C file).
44+
45+
And to use that parser, you'll probably need `clang` on your path,
46+
since it's a C file we're talking about.
47+
48+
### for the wasm and web stuff
49+
50+
For this, you'll need a **rust nightly**.
51+
(This is because we need the `-Zwasm-c-abi=spec` flag;
52+
without it, wasm'ify'd rust can't call wasm'ify'd C correctly.
53+
To the best of my knowledge, there's simply no way to address this
54+
aside from going to a nightly rust.)
55+
56+
And you'll need the wasm-pack tool. That's fairly easy to get:
57+
58+
```
59+
cargo install wasm-pack
60+
```
61+
62+
And you'll need your rust install to have the materials for wasm targets.
63+
The `wasm-pack` tool will either get that for you automatically (if you used `rustup`),
64+
or offer you instructions to follow if you need to do it manually.
65+
66+
And you'll also still need clang.
67+
And probably a fairly recent version: it needs to have wasm32 support,
68+
and needs to be in reasonable alignment to what rust's wasm stuff is expecting.
69+
70+
3471
License
3572
-------
3673

web/.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.wasm32-unknown-unknown]
2+
rustflags = ["-C", "target-feature=+bulk-memory", "-Zwasm-c-abi=spec"]

0 commit comments

Comments
 (0)