Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#519 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
rust, wasm
Ambito
build-system

Direzione di ricerca

Inizia da Cargo.toml, concentrandoti sulle build-dependencies condizionali, poi leggi build.rs per capire come CARGO_CFG_TARGET_FAMILY seleziona la compressione. Riproduci il problema con cargo check --target wasm32-wasip1 --features include-zip. Il lavoro è completato quando il controllo di cross-compilazione non va più in panic e il comportamento esistente specifico della destinazione rimane intatto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Rust
Stelle
119
Fork
88
Merge medio
1g 14h
PR unite (30g)
53

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di daisy/MathCAT

Tutte le issue di daisy/MathCAT

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.