From dd566173531b475ff256958662a4875844040190 Mon Sep 17 00:00:00 2001 From: Mossa Date: Sun, 24 May 2026 02:04:50 +0200 Subject: [PATCH 1/2] feat: make rayon an optional feature Both diffsol and diffsol-c now expose a `rayon` cargo feature (in default) that controls whether `faer/rayon` and, for diffsol, `diffsl?/rayon` are enabled. Behavior with default features is unchanged. This also removes the previously target-gated faer dep declarations that silently dropped the rayon feature on wasm32; users now turn rayon off explicitly via `default-features = false`. In the workspace `diffsl` dep, drop the always-on `rayon` feature so the per-crate `rayon` feature is authoritative. --- Cargo.toml | 2 +- diffsol-c/Cargo.toml | 8 ++++---- diffsol/Cargo.toml | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4e7a8900..a3c5741c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ faer = { version = "0.24", default-features = false, features = [ ] } faer-traits = "0.24" cudarc = { version = "0.19", default-features = false } -diffsl = { version = "0.11.9", features = ["rayon"] } +diffsl = { version = "0.11.9" } plotly = { version = "0.14" } argmin = { version = "0.11.0" } diff --git a/diffsol-c/Cargo.toml b/diffsol-c/Cargo.toml index d0c77414..a1626108 100644 --- a/diffsol-c/Cargo.toml +++ b/diffsol-c/Cargo.toml @@ -12,8 +12,9 @@ readme = "../README.md" crate-type = ["cdylib", "rlib"] [features] -default = ["diffsl-external-dynamic"] +default = ["diffsl-external-dynamic", "rayon"] wasm = ["getrandom/js"] +rayon = ["diffsol/rayon", "faer/rayon"] external = [] external-dynamic = [] diffsl-external-f64 = [ @@ -43,7 +44,7 @@ suitesparse = ["diffsol/suitesparse"] [dependencies] diffsl = { workspace = true } -diffsol = { path = "../diffsol", version = "0.14.0", features = ["diffsl"] } +diffsol = { path = "../diffsol", version = "0.14.0", default-features = false, features = ["nalgebra", "faer", "diffsl"] } dlmalloc = { version = "0.2", features = ["global"] } nalgebra = { workspace = true, features = ["std"] } ndarray = { version = "0.17.2" } @@ -52,12 +53,11 @@ schemars = "1.1.0" serde = { workspace = true } serde_json = { workspace = true } paste = { workspace = true } +faer = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } -faer = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] getrandom = { version = "0.2", optional = true } -faer = { workspace = true, features = ["rayon"] } diff --git a/diffsol/Cargo.toml b/diffsol/Cargo.toml index 7d9a8de7..a97c3b8a 100644 --- a/diffsol/Cargo.toml +++ b/diffsol/Cargo.toml @@ -12,9 +12,10 @@ readme = "../README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["nalgebra", "faer"] +default = ["nalgebra", "faer", "rayon"] faer = [] nalgebra = [] +rayon = ["faer/rayon", "diffsl?/rayon"] cuda = ["dep:cudarc"] sundials = ["suitesparse_sys", "bindgen", "cc"] suitesparse = ["suitesparse_sys"] @@ -57,11 +58,6 @@ cudarc = { workspace = true, optional = true, default-features = false, features ] } log = "0.4.29" serde_json = { workspace = true } - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -faer = { workspace = true, features = ["rayon"] } - -[target.'cfg(target_arch = "wasm32")'.dependencies] faer = { workspace = true } [dev-dependencies] From 80370c278c393e9e8439ec9c1c8a42d7b85fed16 Mon Sep 17 00:00:00 2001 From: Mossa Date: Sun, 24 May 2026 02:16:21 +0200 Subject: [PATCH 2/2] fix: make rayon opt-in rather than default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wasm example pulls diffsol with default features. When `rayon` was in `default`, the cascade `faer/rayon` → rayon → atomic-wait broke the wasm32 build because atomic-wait has no `platform` module for that target. Drop `rayon` from default in both diffsol and diffsol-c so it must be enabled explicitly. Matches the original target-gated behavior on wasm (no rayon) and lets non-wasm consumers also turn it off without needing `default-features = false`. --- diffsol-c/Cargo.toml | 2 +- diffsol/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/diffsol-c/Cargo.toml b/diffsol-c/Cargo.toml index a1626108..6cee3e9a 100644 --- a/diffsol-c/Cargo.toml +++ b/diffsol-c/Cargo.toml @@ -12,7 +12,7 @@ readme = "../README.md" crate-type = ["cdylib", "rlib"] [features] -default = ["diffsl-external-dynamic", "rayon"] +default = ["diffsl-external-dynamic"] wasm = ["getrandom/js"] rayon = ["diffsol/rayon", "faer/rayon"] external = [] diff --git a/diffsol/Cargo.toml b/diffsol/Cargo.toml index a97c3b8a..7567c265 100644 --- a/diffsol/Cargo.toml +++ b/diffsol/Cargo.toml @@ -12,7 +12,7 @@ readme = "../README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["nalgebra", "faer", "rayon"] +default = ["nalgebra", "faer"] faer = [] nalgebra = [] rayon = ["faer/rayon", "diffsl?/rayon"]