Skip to content

Commit f5bbb19

Browse files
committed
fix(stm): do not compile 'rug' when targetting 'musl' env
1 parent d671644 commit f5bbb19

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

mithril-stm/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ rayon = { workspace = true }
3030
serde = { workspace = true }
3131
thiserror = { workspace = true }
3232

33-
[target.'cfg(any(target_family = "wasm", windows))'.dependencies]
33+
[target.'cfg(any(target_family = "wasm", target_env = "musl", windows))'.dependencies]
3434
# WASM and Windows don't support rug backend, fallback to num-integer only
3535
num-bigint = { version = "0.4.6" }
3636
num-rational = { version = "0.4.2" }
3737
num-traits = { version = "0.2.19" }
3838

39-
[target.'cfg(not(any(target_family = "wasm", windows)))'.dependencies]
39+
[target.'cfg(not(any(target_family = "wasm", target_env = "musl", windows)))'.dependencies]
4040
num-bigint = { version = "0.4.6", optional = true }
4141
num-rational = { version = "0.4.2", optional = true }
4242
num-traits = { version = "0.2.19", optional = true }

mithril-stm/src/eligibility_check.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ use {
77
std::ops::Neg,
88
};
99

10-
#[cfg(any(feature = "num-integer-backend", target_family = "wasm", windows))]
10+
#[cfg(any(
11+
feature = "num-integer-backend",
12+
target_family = "wasm",
13+
target_env = "musl",
14+
windows
15+
))]
1116
/// Checks that ev is successful in the lottery. In particular, it compares the output of `phi`
1217
/// (a real) to the output of `ev` (a hash). It uses the same technique used in the
1318
/// [Cardano ledger](https://github.com/input-output-hk/cardano-ledger/). In particular,
@@ -49,7 +54,12 @@ pub(crate) fn is_lottery_won(phi_f: f64, ev: [u8; 64], stake: Stake, total_stake
4954
taylor_comparison(1000, q, x)
5055
}
5156

52-
#[cfg(any(feature = "num-integer-backend", target_family = "wasm", windows))]
57+
#[cfg(any(
58+
feature = "num-integer-backend",
59+
target_family = "wasm",
60+
target_env = "musl",
61+
windows
62+
))]
5363
/// Checks if cmp < exp(x). Uses error approximation for an early stop. Whenever the value being
5464
/// compared, `cmp`, is smaller (or greater) than the current approximation minus an `error_term`
5565
/// (plus an `error_term` respectively), then we stop approximating. The choice of the `error_term`
@@ -82,7 +92,12 @@ fn taylor_comparison(bound: usize, cmp: Ratio<BigInt>, x: Ratio<BigInt>) -> bool
8292
false
8393
}
8494

85-
#[cfg(not(any(feature = "num-integer-backend", target_family = "wasm", windows)))]
95+
#[cfg(not(any(
96+
feature = "num-integer-backend",
97+
target_family = "wasm",
98+
target_env = "musl",
99+
windows
100+
)))]
86101
/// The crate `rug` has sufficient optimizations to not require a taylor approximation with early
87102
/// stop. The difference between the current implementation and the one using the optimization
88103
/// above is around 10% faster. We perform the computations with 117 significant bits of

0 commit comments

Comments
 (0)