Skip to content

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

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

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

Conversation

@JuaniRios
Copy link

@JuaniRios JuaniRios commented Mar 17, 2026

Problem

Having crate-type = ["rlib", "cdylib"] causes Cargo to produce output artifacts with colliding filenames. On Linux, this results in alloy_primitives being compiled as two separate crate instances, causing type mismatches for any downstream crate:

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

  • Remove cdylib from crate-type in crates/float/Cargo.toml, keeping only rlib
  • Add a new crates/float-wasm/ crate with crate-type = ["cdylib"] that simply re-exports rain-math-float

WASM consumers should depend on rain-math-float-wasm instead of rain-math-float directly.

Summary by CodeRabbit

  • New Features

    • Added WebAssembly (WASM) support for the math library, enabling use in web and Node.js environments.
  • Refactor

    • Split the build into a dedicated WASM wrapper and a core library to avoid duplicate compilation and streamline distribution.

@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: e8138039-31c2-44e4-98b2-b5d160de7298

📥 Commits

Reviewing files that changed from the base of the PR and between b26bc6f and f9f9d96.

📒 Files selected for processing (4)
  • crates/float-wasm/Cargo.toml
  • crates/float-wasm/src/lib.rs
  • crates/float/Cargo.toml
  • scripts/build.js

Walkthrough

Creates a new WASM wrapper crate (rain-math-float-wasm) that builds as a cdylib and re-exports the core rain-math-float API; the core crate's Cargo.toml is changed to produce only rlib artifacts. The build script reference to the emitted wasm filename was updated.

Changes

Cohort / File(s) Summary
New WASM wrapper crate
crates/float-wasm/Cargo.toml, crates/float-wasm/src/lib.rs
Adds a new package rain-math-float-wasm configured as a cdylib and depending on the local core crate; lib.rs re-exports the core crate (pub use rain_math_float::*;).
Core library build configuration
crates/float/Cargo.toml
Removes cdylib from [lib].crate-type, leaving only rlib, so the core crate no longer emits a cdylib WASM artifact.
Build script
scripts/build.js
Updated wasm-bindgen input filenames: references changed to the new wasm artifact name (rain_math_float_wasm.wasm vs rain_math_float.wasm).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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 accurately summarizes the main change: moving the cdylib crate type from the main float crate to a separate float-wasm crate, which is the core objective of this pull request.
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-main
📝 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 self-assigned this Mar 17, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/float/Cargo.toml`:
- Around line 8-9: Update the build script to point to the new WASM artifact
name produced by the changed crate-type: in scripts/build.js locate the
references to "rain_math_float.wasm" and replace them with
"rain_math_float_wasm.wasm" so the paths passed to wasm-bindgen (e.g.,
"./target/wasm32-unknown-unknown/release/...") match the actual output from the
rain-math-float-wasm crate; ensure both occurrences currently referencing
"rain_math_float.wasm" are updated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1eae2097-af05-4d4b-a063-e7ecc180fc62

📥 Commits

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

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

@JuaniRios JuaniRios force-pushed the fix/remove-cdylib-main branch from b26bc6f to f9f9d96 Compare March 17, 2026 20:34
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