Skip to content

fix: move cdylib to separate float-wasm crate#172

Closed
JuaniRios wants to merge 1 commit intomainfrom
fix/remove-cdylib
Closed

fix: move cdylib to separate float-wasm crate#172
JuaniRios wants to merge 1 commit intomainfrom
fix/remove-cdylib

Conversation

@JuaniRios
Copy link

@JuaniRios JuaniRios commented Mar 17, 2026

Summary

  • Remove cdylib from crate-type in crates/float/Cargo.toml, keeping only rlib
  • Add a separate float-wasm crate (crates/float-wasm/) as the WASM build target

Problem

Having crate-type = ["rlib", "cdylib"] causes Cargo to compile alloy_primitives as two separate crate instances, causing type mismatches for downstream crates:

expected `FixedBytes<32>`, found a different `FixedBytes<32>`
note: two different versions of crate `alloy_primitives` are being used

See: rust-lang/cargo#6313

Fix

The cdylib target is moved to a separate float-wasm wrapper crate (crates/float-wasm/).

Summary by CodeRabbit

  • New Features

    • Added WebAssembly (WASM) build target for the float library, enabling use in browser environments and JavaScript applications.
  • Chores

    • Reorganized library build configuration to better support multiple deployment targets by separating the core library from the WASM wrapper build.

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: rust-lang/cargo#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) <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 32fcce9e-aa53-4b52-accd-b1b16b6bcbc4

📥 Commits

Reviewing files that changed from the base of the PR and between 50aa96e and 83033e2.

📒 Files selected for processing (3)
  • crates/float-wasm/Cargo.toml
  • crates/float-wasm/src/lib.rs
  • crates/float/Cargo.toml

Walkthrough

A new WASM wrapper crate (rain-math-float-wasm) is introduced with separate crate manifest and module exports. The existing float crate's crate-type is modified from ["rlib", "cdylib"] to ["rlib"], delegating CDYLIB compilation to the new wrapper crate.

Changes

Cohort / File(s) Summary
WASM Wrapper Crate
crates/float-wasm/Cargo.toml, crates/float-wasm/src/lib.rs
New WASM/CDYLIB crate manifest defining package metadata with rlib dependency on the core float library. The lib.rs file re-exports all public items from rain_math_float via pub use rain_math_float::*;.
Core Float Library Configuration
crates/float/Cargo.toml
Removes "cdylib" from the lib crate-type declaration, leaving only "rlib" for the core library build.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving cdylib compilation from the core float crate to a separate float-wasm crate, which directly addresses the root cause of the type mismatch issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-cdylib
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JuaniRios JuaniRios closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant