cbcl-wasm: fix unresolved allocator imports for cdylib host loading #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/6/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
WasmAllocshim (which declared__rust_alloc/__rust_deallocas externs that the cdylib compiler never generates) withdlmalloc::GlobalDlmalloc. The previous code produced a wasm binary with two unresolvedenv::__rust_*imports, so any non-JS host (wasmtime, etc.) refused to instantiate it. wasm-bindgen builds masked the issue for browsers; the C-ABI path was effectively unreachable.alloc::string::ToStringincbcl-parser/src/protocol_parser.rs. Without it,--no-default-featuresbuilds fail withto_stringnot found on&strand the wasm32 build never completes.Test plan
cargo build --target wasm32-unknown-unknown --no-default-features -p cbcl-wasm --releasesucceeds (warnings only).cbcl_wasm.wasmlistscbcl_alloc / cbcl_free / cbcl_parse_message / cbcl_run_pipeline / cbcl_verify_dialect / cbcl_verify_message_shape / cbcl_verify_protocolas exports and has no unresolved imports.cbcl_parse_message,cbcl_verify_message_shape,cbcl_verify_protocolall return correct results on the lib.rs unit-test fixtures (SHAPE_DIALECT,PROTOCOL_DIALECT).cargo test --workspaceshould be re-run on CI; the fix is gated towasm32-unknown-unknowncdylib so std-feature unit tests are unaffected, but worth confirming.🤖 Generated with Claude Code
Addressed in
21ca834: widened the Cargo target dep cfg to alltarget_arch = "wasm32"so it is a strict superset of where the source's#[global_allocator]activates. Cargo target cfgs can't reference features, so this is the closest expressible match.Verified
cargo build --target wasm32-wasip1 --no-default-features -p cbcl-wasm --releasenow builds (it was the failure mode you flagged).wasm32-unknown-unknownstill builds andcargo test -p cbcl-wasmis still 62/62 on native.Cargo.lockis unchanged.