Skip to content

Commit 3b7c727

Browse files
authored
Merge pull request #152 from AdaWorldAPI/claude/blake3-pin-to-std-feature
deps: pin blake3 to `std` feature instead of `hpc-extras`
2 parents a90a0ab + 1b45979 commit 3b7c727

3 files changed

Lines changed: 68 additions & 10 deletions

File tree

Cargo.toml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,38 @@ libc = { version = "0.2.82", optional = true }
5252

5353
matrixmultiply = { version = "0.3.2", default-features = false, features=["cgemm"] }
5454

55-
# blake3 — gated behind `hpc-extras` (integrity hashing in
56-
# plane/seal/merkle_tree/vsa/spo_bundle/crystal_encoder/compression_curves/
57-
# deepnsm). Optional + opt-in because the transitive dep `constant_time_eq`
58-
# does not declare `#![no_std]`, so unconditionally including blake3 breaks
59-
# the `thumbv6m-none-eabi --no-default-features` nostd build with
60-
# `error[E0463]: can't find crate for std`.
55+
# =====================================================================
56+
# blake3 — DEPENDENCY OF `std` FEATURE (NOT `hpc-extras`). READ BEFORE
57+
# TOUCHING.
58+
# =====================================================================
59+
#
60+
# blake3 is required by the cognitive substrate modules — plane, seal,
61+
# merkle_tree, vsa, spo_bundle, crystal_encoder, compression_curves,
62+
# deepnsm — which all live under `pub mod hpc;` (itself gated on
63+
# `feature = "std"` in lib.rs). Those modules `use blake3;` directly
64+
# and unconditionally; there is no #[cfg] dance inside them.
65+
#
66+
# Pinning blake3 to the `std` feature (rather than `hpc-extras`) means:
67+
# * ANY consumer that enables `std` automatically gets blake3, with
68+
# ZERO additional feature wiring. This is the default. Cargo's
69+
# transitive feature resolution does the rest.
70+
# * Consumers selecting `default-features = false, features = ["std"]`
71+
# (e.g. burn-ndarray, which disables hpc-extras to shed p64/fractal)
72+
# STILL get blake3 — no more "missing blake3" build errors that
73+
# used to require chasing down hpc-extras.
74+
# * Consumers selecting `default-features = false` (no std at all,
75+
# e.g. the `thumbv6m-none-eabi` CI matrix entry) do NOT pull blake3
76+
# and therefore do not pull `constant_time_eq`, whose lack of
77+
# `#![no_std]` declaration would otherwise fail the nostd link with
78+
# `error[E0463]: can't find crate for std`.
79+
#
80+
# If you find yourself wanting to make blake3 unconditional (drop the
81+
# `optional = true`), check first: does it still pass
82+
# `cargo rustc -p ndarray --target=thumbv6m-none-eabi
83+
# --no-default-features --features portable-atomic-critical-section`?
84+
# If not, leave the `optional = true` + `std`-feature pinning in place.
85+
#
86+
# =====================================================================
6187
blake3 = { version = "1", optional = true }
6288

6389
# p64 + fractal — specialized convergence / manifold math. Gated behind
@@ -144,7 +170,7 @@ blas = ["dep:cblas-sys", "dep:libc"]
144170

145171
serde = ["dep:serde"]
146172

147-
std = ["num-traits/std", "matrixmultiply/std"]
173+
std = ["num-traits/std", "matrixmultiply/std", "dep:blake3"]
148174
rayon = ["dep:rayon", "std"]
149175

150176
# Portable-SIMD backend (NIGHTLY ONLY). Routes `crate::simd::*` types
@@ -161,11 +187,15 @@ rayon = ["dep:rayon", "std"]
161187
# cfg-dispatch in `simd.rs` remains the production path.
162188
nightly-simd = ["std"]
163189

164-
# HPC extras: blake3 hashing, p64 palette/NARS bridge, fractal manifold.
190+
# HPC extras: p64 palette/NARS bridge + fractal manifold.
191+
# (blake3 was previously listed here; it is now part of `std` directly
192+
# because the cognitive substrate modules under hpc/ that import blake3
193+
# are themselves `std`-gated. See the blake3 comment in [dependencies].)
165194
# These pull in a non-trivial dependency tree; downstream crates such as
166195
# burn-ndarray that only need the core array layer can disable this with
167-
# `default-features = false` (and re-enable `std` explicitly if needed).
168-
hpc-extras = ["std", "dep:p64", "dep:fractal", "fractal/std", "dep:blake3"]
196+
# `default-features = false` (and re-enable `std` explicitly if needed —
197+
# blake3 will come along with `std`).
198+
hpc-extras = ["std", "dep:p64", "dep:fractal", "fractal/std"]
169199

170200
matrixmultiply-threading = ["matrixmultiply/threading"]
171201

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@ cargo test
208208
- Optional: gcc-aarch64-linux-gnu for Pi cross-compilation
209209
- Optional: Intel MKL or OpenBLAS (feature-gated)
210210

211+
### Transitive dependencies of the `std` feature
212+
213+
Enabling the `std` feature (the default) pulls in **`blake3`** as a hard
214+
transitive dependency. The cognitive substrate modules under `hpc/`
215+
`plane`, `seal`, `merkle_tree`, `vsa`, `spo_bundle`, `crystal_encoder`,
216+
`compression_curves`, `deepnsm` — import `blake3` directly for integrity
217+
hashing and XOF expansion, and there is no separate feature to enable it.
218+
This was previously gated behind `hpc-extras`, which caused recurring
219+
"missing blake3" build errors for consumers (e.g. `burn-ndarray`) that
220+
selected `default-features = false, features = ["std"]` to shed the
221+
`p64` / `fractal` dependency tree. Pinning blake3 to `std` removes that
222+
footgun: any `std`-enabled build automatically gets blake3.
223+
224+
Consumers building `default-features = false` (no `std`, e.g. the
225+
`thumbv6m-none-eabi` nostd target) skip both the `hpc` module and the
226+
blake3 dep, so the nostd link is unaffected.
227+
211228
## Ecosystem
212229

213230
This fork is the hardware foundation for a larger architecture:

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ pub mod backend;
297297
/// cam_pq, reductions, blas_level*, amx_matmul, vnni_gemm) compile without
298298
/// extra deps. Cognitive/research modules (p64_bridge, crystal_encoder,
299299
/// deepnsm, etc.) are gated behind `hpc-extras` inside `hpc/mod.rs`.
300+
///
301+
/// ## blake3 transitive dep
302+
///
303+
/// Enabling `std` (the default) automatically pulls `blake3`, which the
304+
/// cognitive substrate modules (`plane`, `seal`, `merkle_tree`, `vsa`,
305+
/// `spo_bundle`, `crystal_encoder`, `compression_curves`, `deepnsm`)
306+
/// import directly and unconditionally. There is no separate feature
307+
/// to enable; `std` is enough. Consumers building `default-features = false`
308+
/// without `std` (e.g. the `thumbv6m-none-eabi` nostd target) skip both
309+
/// the `hpc` module and the blake3 dep. See the `blake3` comment block
310+
/// in `Cargo.toml` for the rationale.
300311
#[cfg(feature = "std")]
301312
#[allow(clippy::all, unused_imports, unused_variables, unused_mut, dead_code)]
302313
pub mod hpc;

0 commit comments

Comments
 (0)