fix: move cdylib to separate float-wasm crate#171
fix: move cdylib to separate float-wasm crate#171JuaniRios wants to merge 1 commit intorainlanguage:base/npm-v0.0.0-alpha.42from
Conversation
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>
WalkthroughA new WASM wrapper crate is introduced that re-exports all public items from the core rain_math_float library. The core library's crate-type is modified to remove cdylib support, delegating WASM artifact generation solely to the wrapper crate to prevent filename collisions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
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-wasm/Cargo.toml`:
- Around line 1-12: The crate's package name rain-math-float-wasm produces an
artifact rain_math_float_wasm.wasm but the build script scripts/build.js expects
rain_math_float.wasm; to fix, add a name override under [lib] (e.g., name =
"rain_math_float") in this Cargo.toml so the generated WASM artifact matches the
wasm-bindgen invocations, or alternatively update the wasm-bindgen calls in
scripts/build.js to reference rain_math_float_wasm.wasm; modify the Cargo.toml
[lib] block (or the wasm-bindgen lines in scripts/build.js) accordingly to make
the artifact name consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ed05a43b-ac24-442e-8612-6e1fa26e6a77
📒 Files selected for processing (3)
crates/float-wasm/Cargo.tomlcrates/float-wasm/src/lib.rscrates/float/Cargo.toml
| [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" } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the hardcoded artifact paths in build.js
echo "=== Checking build.js for hardcoded artifact paths ==="
rg -n "rain_math_float" scripts/build.jsRepository: rainlanguage/rain.math.float
Length of output: 394
Build script incompatibility: artifact name mismatch.
The package name rain-math-float-wasm will produce a WASM artifact named rain_math_float_wasm.wasm, but the build script (scripts/build.js) hardcodes the artifact name as rain_math_float.wasm:
wasm-bindgen --target nodejs ./target/wasm32-unknown-unknown/release/rain_math_float.wasm ...
wasm-bindgen --target web ./target/wasm32-unknown-unknown/release/rain_math_float.wasm ...This mismatch will cause the WASM build to fail.
Fix options:
- Add
name = "rain_math_float"under[lib]to preserve the original artifact name:
[lib]
crate-type = ["cdylib"]
+name = "rain_math_float"- Or update
scripts/build.jsto referencerain_math_float_wasm.wasm.
Option 1 is recommended.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/float-wasm/Cargo.toml` around lines 1 - 12, The crate's package name
rain-math-float-wasm produces an artifact rain_math_float_wasm.wasm but the
build script scripts/build.js expects rain_math_float.wasm; to fix, add a name
override under [lib] (e.g., name = "rain_math_float") in this Cargo.toml so the
generated WASM artifact matches the wasm-bindgen invocations, or alternatively
update the wasm-bindgen calls in scripts/build.js to reference
rain_math_float_wasm.wasm; modify the Cargo.toml [lib] block (or the
wasm-bindgen lines in scripts/build.js) accordingly to make the artifact name
consistent.
Summary
cdylibfromrain-math-float'scrate-type, making itrlib-onlyrain-math-float-wasmcrate (crates/float-wasm) that re-exportsrain-math-floatas acdylibTest plan
cargo buildsucceeds for the workspacerain-math-float-wasmrain-math-float🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes