Skip to content

Commit bf370a0

Browse files
Rebase onto main: align with wasm-shim-merge architecture, pin CI toolchain
This branch predates the 2026-04-20 wasm-shim-merge work and the bd-at72 toolchain pin; rebasing onto current main needed alignment beyond conflict resolution: - wasm-c-shim: the rebase carried main's evolved c_shim.rs content into shim.rs via rename detection; declare the wasm-printf-fmt dependency it uses for snprintf/vsnprintf. - Root Cargo.toml: patch tree-sitter-language to the local wasm-shim fork (same patch wasm-quarto-hub-client uses) so tree-sitter core does not compile upstream's wasm32 stdio/stdlib/string stubs, which collide with wasm-c-shim at link time. The fork has byte-identical Rust source and a no-op build.rs on native targets. - wasm-tests CI: run on the pinned toolchain from rust-toolchain.toml (now a nightly with rust-src and the wasm32 target) instead of RUSTUP_TOOLCHAIN=nightly — bd-at72 pinned the toolchain because later nightlies SIGSEGV in LLVM ThinLTO on wasm32 builds of this workspace. The E0152 duplicate-lang-item conflict the override worked around no longer reproduces on the pinned toolchain. - wasm_lua.rs: SourceInfo::for_test() (SourceInfo::default() is deprecated under -D deprecated), and pass the new attribution argument (None) to apply_lua_filters. - Regenerate Cargo.lock and crates/wasm-quarto-hub-client/Cargo.lock. Verified: cargo build + nextest workspace green (9862 passed); all 6 wasm tests pass under wasm-bindgen-test-runner (macOS, Homebrew LLVM clang, pinned nightly); production build-wasm.js succeeds.
1 parent e00fc79 commit bf370a0

8 files changed

Lines changed: 128 additions & 29 deletions

File tree

.github/workflows/test-suite.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,18 @@ jobs:
183183
wasm-tests:
184184
name: WASM Tests
185185
runs-on: ubuntu-latest
186-
# Override rust-toolchain.toml so the rustup proxy doesn't auto-install the
187-
# prebuilt wasm32-unknown-unknown target. We need -Zbuild-std to rebuild
188-
# core from source, and the prebuilt sysroot causes E0152 (duplicate lang
189-
# item). The production WASM build avoids this because wasm-quarto-hub-client
190-
# is excluded from the workspace and gets an isolated target/ directory.
191-
env:
192-
RUSTUP_TOOLCHAIN: nightly
186+
# Uses the pinned toolchain from rust-toolchain.toml, which is already a
187+
# nightly with rust-src (required by -Zbuild-std) and the wasm32 target.
188+
# Do NOT override with latest nightly: bd-at72 pinned the toolchain because
189+
# newer nightlies SIGSEGV in LLVM ThinLTO when building this workspace for
190+
# wasm32-unknown-unknown. (The E0152 duplicate-lang-item conflict between
191+
# the prebuilt wasm32 sysroot and -Zbuild-std that this job originally
192+
# worked around no longer reproduces on the pinned toolchain.)
193193
steps:
194194
- uses: actions/checkout@v4
195195
with:
196196
fetch-depth: 1
197197

198-
- name: Install Rust nightly with rust-src
199-
run: rustup toolchain install nightly --component rust-src --profile minimal
200-
201198
- name: Set up Clang
202199
uses: egor-tensin/setup-clang@v1
203200
with:

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ verbose_file_reads = "warn"
274274

275275
[patch.crates-io]
276276
lua-src = { path = "crates/lua-src-wasm" }
277+
# Neutralize tree-sitter-language's upstream wasm32 stdio/stdlib/string C
278+
# stubs so wasm-c-shim is the single source of truth for C stdlib symbols
279+
# in workspace wasm32 builds (the pampa wasm_lua tests). Same patch as
280+
# wasm-quarto-hub-client's; identical Rust source on native targets, and
281+
# its build.rs is a no-op off-wasm32. See
282+
# claude-notes/plans/2026-04-20-wasm-shim-merge.md.
283+
tree-sitter-language = { path = "crates/tree-sitter-language-wasm-shim" }
277284
# Fork of runtimelib that adds venv-aware kernelspec discovery
278285
# (`data_dirs_with_jupyter_paths`, `find_kernelspec_with_jupyter_paths`)
279286
# and threads `searched_paths` through `RuntimeError::KernelNotFound`.

crates/pampa/tests/wasm_lua.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ end
8787
blocks: vec![Block::Paragraph(Paragraph {
8888
content: vec![Inline::Str(Str {
8989
text: "hello".to_string(),
90-
source_info: quarto_source_map::SourceInfo::default(),
90+
source_info: quarto_source_map::SourceInfo::for_test(),
9191
})],
92-
source_info: quarto_source_map::SourceInfo::default(),
92+
source_info: quarto_source_map::SourceInfo::for_test(),
9393
})],
9494
};
9595
let context = ASTContext::new();
@@ -100,6 +100,7 @@ end
100100
&[PathBuf::from("/project/uppercase.lua")],
101101
"html",
102102
runtime,
103+
None,
103104
)
104105
.await
105106
.expect("filter execution failed");
@@ -198,9 +199,9 @@ end
198199
blocks: vec![Block::Paragraph(Paragraph {
199200
content: vec![Inline::Str(Str {
200201
text: "test".to_string(),
201-
source_info: quarto_source_map::SourceInfo::default(),
202+
source_info: quarto_source_map::SourceInfo::for_test(),
202203
})],
203-
source_info: quarto_source_map::SourceInfo::default(),
204+
source_info: quarto_source_map::SourceInfo::for_test(),
204205
})],
205206
};
206207

@@ -210,6 +211,7 @@ end
210211
&[PathBuf::from("/project/check_io.lua")],
211212
"html",
212213
runtime,
214+
None,
213215
)
214216
.await
215217
.expect("filter with io checks failed — synthetic io may not be registered");
@@ -257,9 +259,9 @@ end
257259
blocks: vec![Block::Paragraph(Paragraph {
258260
content: vec![Inline::Str(Str {
259261
text: "test".to_string(),
260-
source_info: quarto_source_map::SourceInfo::default(),
262+
source_info: quarto_source_map::SourceInfo::for_test(),
261263
})],
262-
source_info: quarto_source_map::SourceInfo::default(),
264+
source_info: quarto_source_map::SourceInfo::for_test(),
263265
})],
264266
};
265267

@@ -269,6 +271,7 @@ end
269271
&[PathBuf::from("/project/check_os.lua")],
270272
"html",
271273
runtime,
274+
None,
272275
)
273276
.await
274277
.expect("filter with os checks failed — synthetic os may not be registered");

crates/wasm-c-shim/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ edition = "2021"
99
license.workspace = true
1010
description = "C stdlib shims for wasm32-unknown-unknown (no libc)"
1111

12+
[target.'cfg(target_arch = "wasm32")'.dependencies]
13+
# snprintf/vsnprintf formatting engine used by the shim's printf-family
14+
# symbols (see the wasm-shim-merge plan, 2026-04-20).
15+
wasm-printf-fmt = { path = "../wasm-printf-fmt" }
16+
1217
[lints]
1318
workspace = true

crates/wasm-c-shim/src/shim.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,20 @@ pub unsafe extern "C" fn isxdigit(c: c_int) -> c_int {
655655

656656
#[no_mangle]
657657
pub unsafe extern "C" fn toupper(c: c_int) -> c_int {
658-
if islower(c) != 0 { c - 32 } else { c }
658+
if islower(c) != 0 {
659+
c - 32
660+
} else {
661+
c
662+
}
659663
}
660664

661665
#[no_mangle]
662666
pub unsafe extern "C" fn tolower(c: c_int) -> c_int {
663-
if isupper(c) != 0 { c + 32 } else { c }
667+
if isupper(c) != 0 {
668+
c + 32
669+
} else {
670+
c
671+
}
664672
}
665673

666674
/* ====================================================================== */
@@ -669,7 +677,11 @@ pub unsafe extern "C" fn tolower(c: c_int) -> c_int {
669677

670678
#[no_mangle]
671679
pub unsafe extern "C" fn abs(x: c_int) -> c_int {
672-
if x < 0 { -x } else { x }
680+
if x < 0 {
681+
-x
682+
} else {
683+
x
684+
}
673685
}
674686

675687
#[no_mangle]

crates/wasm-quarto-hub-client/Cargo.lock

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

dev-docs/wasm.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,13 @@ instead: `CC_wasm32_unknown_unknown=/opt/homebrew/opt/llvm/bin/clang`.
150150
- You must use `--test wasm_lua` to select only the WASM test file.
151151
Running `cargo test -p pampa --target wasm32` without `--test` will fail because
152152
native tests can't compile for wasm32.
153-
- The prebuilt `wasm32-unknown-unknown` target (installed by `rust-toolchain.toml`)
154-
conflicts with `-Zbuild-std` when building within the workspace — both produce a
155-
`core` crate, causing E0152 (duplicate lang item). The production build avoids this
156-
because `wasm-quarto-hub-client` is excluded from the workspace. The CI job sets
157-
`RUSTUP_TOOLCHAIN=nightly` to bypass `rust-toolchain.toml`, so the prebuilt target
158-
is never installed. Locally, you can either set `RUSTUP_TOOLCHAIN=nightly` or
159-
remove the target before testing (`rustup target remove wasm32-unknown-unknown`)
160-
and re-add it afterward for the production build.
153+
- The pinned toolchain in `rust-toolchain.toml` (a nightly with `rust-src` and the
154+
wasm32 target) is what both CI and local runs should use — no `RUSTUP_TOOLCHAIN`
155+
override. Do not substitute a newer nightly: bd-at72 pinned the toolchain because
156+
later nightlies SIGSEGV in LLVM ThinLTO when building this workspace for wasm32.
157+
(An earlier iteration of this setup hit E0152 duplicate-lang-item conflicts
158+
between the prebuilt wasm32 sysroot and `-Zbuild-std`; that no longer reproduces
159+
on the pinned toolchain with the prebuilt target installed.)
161160
- The pampa `[[bin]]` targets (`pampa`, `ast-reconcile`) use `required-features` to
162161
prevent compilation when running WASM tests. Cargo builds bin targets alongside
163162
integration tests by default (rust-lang/cargo#12980); the `required-features` gate

0 commit comments

Comments
 (0)