Skip to content

Commit ab7720f

Browse files
Merge branch 'bytecodealliance:main' into dlang
2 parents 7faaf1b + b119e28 commit ab7720f

39 files changed

Lines changed: 971 additions & 225 deletions

File tree

.github/workflows/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ jobs:
169169
- run: rustup target add wasm32-wasip2
170170

171171
- uses: ./.github/actions/install-wasi-sdk
172+
173+
# The threading builtins are encoded with a canonical-function opcode
174+
# newer than any released wasmtime understands (46.0.1 and 47.0.2 both
175+
# reject it with "invalid leading byte (0x2d) for canonical function"),
176+
# so this job runs wasmtime's `dev` build instead of the pinned release.
177+
# This can go back to the shared pin once a release parses the encoding.
178+
- name: Install wasmtime dev build
179+
run: |
180+
curl --retry 5 --retry-all-errors -L -o wasmtime-dev.tar.xz https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasmtime-dev-x86_64-linux.tar.xz
181+
tar xJf wasmtime-dev.tar.xz
182+
echo "`pwd`/wasmtime-dev-x86_64-linux" >> $GITHUB_PATH
183+
working-directory: ${{ runner.temp }}
184+
172185
- run: |
173186
cargo run test --languages rust,c,go tests/threading \
174187
--artifacts target/artifacts \
@@ -189,6 +202,7 @@ jobs:
189202
- run: cargo test -p wit-bindgen
190203
- run: cargo test -p wit-bindgen --all-features
191204
- run: cargo test -p wit-bindgen-rust
205+
- run: cargo test -p wit-bindgen-markdown
192206
- run: cargo test --workspace --exclude 'wit-bindgen*'
193207
- run: rustup update nightly-2025-11-10 --no-self-update
194208
- run: rustup default nightly-2025-11-10

Cargo.lock

Lines changed: 39 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ bitflags = "2.11.1"
4040
heck = { version = "0.5" }
4141
pulldown-cmark = { version = "0.13.3", default-features = false }
4242
serde = { version = "1.0.228", features = ["derive"] }
43+
serde_json = { version = "1" }
4344
clap = { version = "4.6.1", features = ["derive"] }
4445
indexmap = "2.0.0"
4546
prettyplease = "0.2.20"
4647
syn = { version = "2.0.89", features = ["printing"] }
4748
futures = "0.3.31"
4849
macro-string = "0.2.0"
4950

50-
wat = "1.254.0"
51-
wasmparser = "0.254.0"
52-
wasm-encoder = "0.254.0"
53-
wasm-metadata = { version = "0.254.0", default-features = false }
54-
wit-parser = "0.254.0"
55-
wit-component = "0.254.0"
56-
wasm-compose = "0.254.0"
51+
wat = "1.257.0"
52+
wasmparser = "0.257.0"
53+
wasm-encoder = "0.257.0"
54+
wasm-metadata = { version = "0.257.0", default-features = false }
55+
wit-parser = "0.257.0"
56+
wit-component = "0.257.0"
57+
wasm-compose = "0.257.0"
5758

5859
wit-bindgen-core = { path = 'crates/core', version = '0.60.0' }
5960
wit-bindgen-c = { path = 'crates/c', version = '0.60.0' }

ci/rebuild-libwit-bindgen-cabi.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ set -ex
4242
version=$(./ci/print-current-version.sh | sed 's/\./_/g')
4343

4444
realloc=cabi_realloc_wit_bindgen_$version
45+
wasip3_get=wit_bindgen_${version}_get_task_context
46+
wasip3_set=wit_bindgen_${version}_set_task_context
4547

4648
rm -f crates/guest-rust/src/rt/wit_bindgen_*.{rs,o,c}
4749
rm -f crates/guest-rust/src/rt/libwit_bindgen_cabi.a
@@ -60,6 +62,17 @@ pub unsafe extern "C" fn $realloc(
6062
}
6163
EOF
6264

65+
cat >./crates/guest-rust/src/rt/async_support/wasip3_context.rs <<-EOF
66+
// This file is generated by $0
67+
68+
unsafe extern "C" {
69+
#[link_name = "$wasip3_get"]
70+
pub fn get() -> *mut u8;
71+
#[link_name = "$wasip3_set"]
72+
pub fn set(ptr: *mut u8);
73+
}
74+
EOF
75+
6376
cat >./crates/guest-rust/src/rt/wit_bindgen_cabi_realloc.c <<-EOF
6477
// This file is generated by $0
6578
@@ -86,6 +99,16 @@ void *wasip3_task_set(void *ptr) {
8699
WASIP3_TASK = ptr;
87100
return ret;
88101
}
102+
103+
static _Thread_local void *task_context = NULL;
104+
105+
void *$wasip3_get(void) {
106+
return task_context;
107+
}
108+
109+
void $wasip3_set(void *ptr) {
110+
task_context = ptr;
111+
}
89112
EOF
90113

91114
build() {

crates/core/src/source.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ impl Source {
4949
}
5050

5151
pub fn push_str(&mut self, src: &str) {
52+
self.push_str_impl(src, true);
53+
}
54+
55+
/// Appends literal text with the current indentation without interpreting
56+
/// braces or line comments as source syntax.
57+
pub fn push_str_literal(&mut self, src: &str) {
58+
self.push_str_impl(src, false);
59+
}
60+
61+
fn push_str_impl(&mut self, src: &str, interpret_syntax: bool) {
5262
let lines = src.lines().collect::<Vec<_>>();
5363
for (i, line) in lines.iter().enumerate() {
5464
if !self.continuing_line {
@@ -61,11 +71,11 @@ impl Source {
6171
}
6272

6373
let trimmed = line.trim();
64-
if trimmed.starts_with("//") {
74+
if interpret_syntax && trimmed.starts_with("//") {
6575
self.in_line_comment = true;
6676
}
6777

68-
if !self.in_line_comment {
78+
if interpret_syntax && !self.in_line_comment {
6979
if trimmed.starts_with('}') && self.s.ends_with(" ") {
7080
self.s.pop();
7181
self.s.pop();
@@ -76,7 +86,7 @@ impl Source {
7686
} else {
7787
line.trim_start()
7888
});
79-
if !self.in_line_comment {
89+
if interpret_syntax && !self.in_line_comment {
8090
if trimmed.ends_with('{') {
8191
self.indent += 1;
8292
}
@@ -219,4 +229,13 @@ mod tests {
219229
);
220230
assert_eq!(s.s, "function() {\n x\n}");
221231
}
232+
233+
#[test]
234+
fn literal_text_does_not_change_indentation() {
235+
let mut s = Source::default();
236+
s.indent(1);
237+
s.push_str_literal("}\n{");
238+
s.deindent(1);
239+
assert_eq!(s.s, " }\n {");
240+
}
222241
}

0 commit comments

Comments
 (0)