Cross-compiling to WASM fails: build script gets wrong `zip` compression feature
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust, wasm
- Domain
- build-system
Research direction
Start in Cargo.toml, focusing on the conditional build-dependencies, then read build.rs to understand how CARGO_CFG_TARGET_FAMILY selects compression. Reproduce with cargo check --target wasm32-wasip1 --features include-zip. Done means the cross-compilation check no longer panics and the existing target-specific behavior remains intact.
Written by the indexing model from the issue text.
Description
Hi there!
Thank you for the project!!
I was trying the WASM target and was hitting some problems.
After discussing with AI, it seems there is a fix to do in the Cargo.toml.
Problem
Cross-compiling MathCAT to a WASM target (e.g. wasm32-wasip1) with --features include-zip panics in build.rs:
Error: unsupported Zip archive: Unsupported compression
Cause
The zip build-dependency is conditionally gated on target_family:
[target.'cfg(target_family = "wasm")'.build-dependencies]
zip = { version = "7.0", default-features = false, features = ["deflate"] }
[target.'cfg(not(target_family = "wasm"))'.build-dependencies]
zip = { version = "7.0", default-features = false, features = ["bzip2"] }
However, Cargo evaluates cfg() conditions on build-dependencies against the host platform, not the cross-compilation target ([Cargo docs](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies): "the dependency will only be built when the host platform matches the specified target"). So when cross-compiling to WASM from a non-WASM host (the only realistic scenario), the build script is compiled with only bzip2 support. At runtime, build.rs correctly detects the target via CARGO_CFG_TARGET_FAMILY and selects DEFLATE, which isn't available.
The same pattern applied to [target.*.dependencies] works correctly because those are compiled for the target. The issue is specific to build-dependencies.
Fix
Replace the two conditional build-dependencies blocks with a single unconditional one:
[build-dependencies]
bitflags = "2.6"
zip = { version = "7.0", default-features = false, features = ["bzip2", "deflate"] }
This ensures the build script has access to both compression methods regardless of host, and the runtime logic in build.rs continues to select the appropriate one for the target.
Steps to reproduce
git clone https://github.com/daisy/MathCAT
cd MathCAT
cargo clean
rustup target add wasm32-wasip1
cargo check --target wasm32-wasip1 --features include-zip
- Dominant language
- Rust
- Stars
- 119
- Forks
- 88
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 53
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from daisy/MathCAT
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
daisy/MathCAT#839 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Speak !! as double factorial in MathMLPossibly taken @AdamMagued claimed this 12 days ago. Openbug rules
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
discussion
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
discussion translation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
daisy/MathCAT#675 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
[Bug] Completion info popup (.cm-completionInfo) ignores the configured editor fontPossibly taken A pull request linked to this issue is open or already merged. Openbug user-priority/P2
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rescript-lang/rescript#8765 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nautechsystems/nautilus_trader#5287 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
farion1231/cc-switch#8072 ·
Maintainers usually reply within 1 day
-
Python 3.15 supportPossibly taken @amnesiaof claimed this today. OpenL: python L: python:uv
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16524 · 1 comment ·
Maintainers usually reply within 1 day