Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Cross-compiling to WASM fails: build script gets wrong `zip` compression feature

Open Beginner friendly
#519 1 comment 0 reactions 0 assignees View on GitHub

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

bug needs check rust

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from daisy/MathCAT

All issues in daisy/MathCAT

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.