Skip to content

Commit

Permalink
chore(compiler): update rust and wasi toolchain (#4458)
Browse files Browse the repository at this point in the history
This was a difficult update. A newer version of rust exposed/caused an issue with our UnsafeRefs in some cases, causing memory corruption. I tried to highlight semi-functional changes

~Looks like the wasm size has increased by almost 2x. Not ideal, but not sure why or what to do. Based on benchmarks it looks like the perf is unchanged at least.~ Ok it turns out the new version of rust also somehow broke cargo-wasi and it no longer ran wasm-opt anymore. So now this PR also removes cargo-wasi and instead runs wasm-opt directly from the binaryen toolchain.
On the bright side, the install for this is much faster. The only other useful special thing that cargo-wasi did was run https://github.com/rustwasm/walrus to demangle names. Since we always do release builds, I'm not sure how valuable that is.

Updates:
- wasi-sdk: 19 -> 20
- rust: 1.67.1 -> 1.73.0
- cargo-wasi: Removed. Now using the `wasm32-wasi` target and wasm-opt directly
- tree-sitter: 0.20.7 -> 0.20.8
- All crates were updated
- All crates were set to use similar pinning as `^`, where patches are automatically installed

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
MarkMcCulloh authored Oct 11, 2023
1 parent 8c8124f commit 7cf9c67
Show file tree
Hide file tree
Showing 34 changed files with 266 additions and 197 deletions.
1 change: 1 addition & 0 deletions .cargo/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/wasi-sdk-*/
/binaryen-*/
7 changes: 4 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[env]
WASI_SDK = { value = ".cargo/wasi-sdk-19.0", relative = true }
CC_wasm32_wasi = { value = ".cargo/wasi-sdk-19.0/bin/clang", relative = true }
AR_wasm32_wasi = { value = ".cargo/wasi-sdk-19.0/bin/ar", relative = true }
WASI_SDK = { value = ".cargo/wasi-sdk-20.0", relative = true }
# tree-sitter build fails with newer version of clang unless implicit-function-declaration is ignored
CC_wasm32_wasi = { value = ".cargo/wasi-sdk-20.0/bin/clang -Wno-error=implicit-function-declaration", relative = true }
AR_wasm32_wasi = { value = ".cargo/wasi-sdk-20.0/bin/ar", relative = true }
19 changes: 6 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ concurrency:
cancel-in-progress: true

env:
RUST_VERSION: "1.67.1"
NODE_VERSION: "18.16.0"
PNPM_VERSION: "8.6.3"
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -58,13 +57,10 @@ jobs:
node-version: ${{ env.NODE_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
uses: moonrepo/setup-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}
targets: |
x86_64-unknown-linux-gnu
wasm32-wasi
components: rustfmt,clippy,rust-std
inherit-toolchain: true
cache: false

- name: Setup Cargo Cache
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -120,13 +116,10 @@ jobs:
node-version: ${{ env.NODE_VERSION }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
uses: moonrepo/setup-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}
targets: |
x86_64-unknown-linux-gnu
wasm32-wasi
components: rustfmt,clippy,rust-std
inherit-toolchain: true
cache: false

- name: Setup Cargo Cache
uses: Swatinem/rust-cache@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules/

.pnpm-store/
Expand Down
77 changes: 30 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"libs/wingc",
"libs/wingii",
]
resolver = "2"

# For use with `cargo flamegraph --profile flamegraph`
[profile.flamegraph]
Expand Down
14 changes: 7 additions & 7 deletions libs/tree-sitter-wing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "tree-sitter-wing"
description = "winglang grammar for the tree-sitter parsing library"
version = "0.0.1"
version = "0.0.0"
keywords = ["incremental", "parsing", "wing"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/winglang/wing/tree/main/libs/tree-sitter-wing"
edition = "2018"
edition = "2021"
license = "MIT"

build = "bindings/rust/build.rs"
Expand All @@ -20,12 +20,12 @@ include = [
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.20.7"
tree-sitter = "0.20.10"

[dev-dependencies]
tree-sitter-cli = "0.20.7"
tree-sitter-cli = "0.20.8"

[build-dependencies]
cc = "1.0.79"
tree-sitter-cli = "0.20.7"
tree-sitter = "0.20.7"
cc = "1.0"
tree-sitter-cli = "0.20.8"
tree-sitter = "0.20.10"
1 change: 1 addition & 0 deletions libs/wingc/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target/
wingc.wasm
38 changes: 19 additions & 19 deletions libs/wingc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
[package]
name = "wingc"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[dependencies]
tree-sitter = "0.20.9"
tree-sitter-traversal = "0.1.2"
derivative = "2.2.0"
tree-sitter = "0.20.10"
tree-sitter-traversal = "0.1"
derivative = "2.2"
tree-sitter-wing = { path = "../tree-sitter-wing" }
wingii = { path = "../wingii" }
serde = "1.0"
serde_json = "1.0"
colored = "2.0"
lazy_static = "1.4.0"
globset = "0.4.9"
itertools = "0.10"
lazy_static = "1.4"
globset = "0.4"
itertools = "0.11"
phf = { version = "0.11", features = ["macros"] }
indexmap = "1.9.1"
aho-corasick = "0.7.20"
lsp-types = "0.94.0"
indoc = "2.0.0"
const_format = "0.2.30"
duplicate = "1.0.0"
strum = { version = "0.24", features = ["derive"] }
petgraph = "0.6.3"
camino = "1.1.6"
indexmap = "2.0"
aho-corasick = "1.1"
lsp-types = "0.94"
indoc = "2.0"
const_format = "0.2"
duplicate = "1.0"
strum = { version = "0.25", features = ["derive"] }
petgraph = "0.6"
camino = "1.1"

[lib]
crate-type = ["rlib", "cdylib"]

[dev-dependencies]
insta = { version = "1.29.0", features = ["yaml", "redactions"] }
uuid = { version = "1.3.2", features = ["fast-rng", "v4"] }
tempfile = "3.6.0"
insta = { version = "1.33", features = ["yaml", "redactions"] }
uuid = { version = "1.4", features = ["fast-rng", "v4"] }
tempfile = "3.8"
2 changes: 1 addition & 1 deletion libs/wingc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@winglang/wingc",
"private": true,
"scripts": {
"compile": "cargo wasi build --release",
"compile": "cargo build --target wasm32-wasi --release && ../../.cargo/binaryen-version_116/bin/wasm-opt --enable-bulk-memory --strip-debug --strip-producers -O3 -o wingc.wasm ../../target/wasm32-wasi/release/wingc.wasm",
"dev": "cargo run --example compile --release",
"test": "cargo test",
"lint": "cargo fmt && cargo clippy --fix --no-deps --allow-dirty --target wasm32-wasi --release"
Expand Down
Loading

0 comments on commit 7cf9c67

Please sign in to comment.