Skip to content

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

Merged
thedavidmeister merged 2 commits intomainfrom
fix/remove-cdylib-main
Mar 23, 2026
Merged

fix: move cdylib to separate float-wasm crate#174
thedavidmeister merged 2 commits intomainfrom
fix/remove-cdylib-main

Conversation

@JuaniRios
Copy link
Contributor

@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
@thedavidmeister thedavidmeister merged commit 76ec779 into main Mar 23, 2026
10 checks passed
@github-actions
Copy link

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Tip

For best results, initiate chat on the files or code changes.

SIZE=S

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.

2 participants