From 83033e2d0a68340c4330550a658b7d1bcf935681 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 17 Mar 2026 14:02:12 -0300 Subject: [PATCH] fix: move cdylib to separate float-wasm crate The `cdylib` crate-type on `rain-math-float` causes Cargo to produce output artifacts with colliding filenames (rlib and cdylib both generate `librain_math_float.*`). On Linux, this results in `alloy_primitives` being compiled as two separate crate instances, causing type mismatches for any downstream crate that imports both `alloy_primitives` and `rain_math_float`: expected `FixedBytes<32>`, found a different `FixedBytes<32>` note: two different versions of crate `alloy_primitives` are being used See: https://github.com/rust-lang/cargo/issues/6313 The fix moves `cdylib` to a dedicated `rain-math-float-wasm` wrapper crate (`crates/float-wasm`), keeping the core library as `rlib`-only. WASM consumers should depend on `rain-math-float-wasm` instead. Native consumers are unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/float-wasm/Cargo.toml | 12 ++++++++++++ crates/float-wasm/src/lib.rs | 8 ++++++++ crates/float/Cargo.toml | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 crates/float-wasm/Cargo.toml create mode 100644 crates/float-wasm/src/lib.rs diff --git a/crates/float-wasm/Cargo.toml b/crates/float-wasm/Cargo.toml new file mode 100644 index 0000000..0cd5dec --- /dev/null +++ b/crates/float-wasm/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "rain-math-float-wasm" +version = "0.1.0" +edition = "2021" +license = "LicenseRef-DCL-1.0" +homepage = "https://github.com/rainlanguage/rain.math.float" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +rain-math-float = { path = "../float" } diff --git a/crates/float-wasm/src/lib.rs b/crates/float-wasm/src/lib.rs new file mode 100644 index 0000000..0b62700 --- /dev/null +++ b/crates/float-wasm/src/lib.rs @@ -0,0 +1,8 @@ +//! WASM cdylib wrapper for `rain-math-float`. +//! +//! This crate exists solely to produce the cdylib artifact for WASM targets. +//! The core library (`rain-math-float`) is rlib-only to avoid output filename +//! collisions that cause duplicate dependency compilation in downstream +//! consumers. + +pub use rain_math_float::*; diff --git a/crates/float/Cargo.toml b/crates/float/Cargo.toml index 8294076..02c178a 100644 --- a/crates/float/Cargo.toml +++ b/crates/float/Cargo.toml @@ -6,7 +6,7 @@ license = "LicenseRef-DCL-1.0" homepage = "https://github.com/rainlanguage/rain.math.float" [lib] -crate-type = ["rlib", "cdylib"] +crate-type = ["rlib"] [dependencies] alloy = { version = "1.0.9", features = ["sol-types", "json-rpc"] }