Skip to content

Commit e80363c

Browse files
committed
Add WASM support via libm crate fallback
- m_sys.rs: Keep only FFI declarations for unix/windows - m.rs: Add fallback to libm crate for WASM and other non-native targets - Cargo.toml: Add libm dependency for non-unix/windows targets The fallback uses pure Rust libm crate when native libm is unavailable (e.g., WASM builds), avoiding 'env' import errors.
1 parent 1434545 commit e80363c

File tree

3 files changed

+311
-87
lines changed

3 files changed

+311
-87
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ _bigint = ["dep:num-traits", "dep:num-integer"] # Internal feature. User must u
2222
# See also: https://github.com/python/cpython/issues/132763
2323
mul_add = []
2424

25+
# For WASM and other targets without native libm
26+
[target.'cfg(not(any(unix, windows)))'.dependencies]
27+
libm = "0.2"
28+
2529
[dependencies]
2630
libc = "0.2"
2731
num-complex = { version = "0.4", optional = true }

0 commit comments

Comments
 (0)