From 056761e53d4d1d81ca2340bd285bd6e38a0be601 Mon Sep 17 00:00:00 2001 From: Paho Lurie-Gregg Date: Sat, 25 Dec 2021 09:55:02 -0800 Subject: [PATCH] Use hard-coded values in build script --- CHANGELOG.md | 1 + build/main.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a560ad0..924dc4b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The MSRV (Minimum Supported Rust Version) is 1.37.0, and typenum is tested against this Rust version. ### Unreleased +- [fixed] Cross-compilation issue due to doing math in build script. ### 1.14.0 (2021-09-01) - [changed] Sealed all marker traits. Documentation already stated that these diff --git a/build/main.rs b/build/main.rs index a886ac3da..03c4697d4 100644 --- a/build/main.rs +++ b/build/main.rs @@ -80,8 +80,10 @@ pub fn no_std() {} fn main() { let highest: u64 = 1024; - let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1; - let first10: u32 = (highest as f64).log(10.0) as u32 + 1; + // Use hardcoded values to avoid issues with cross-compilation. + // See https://github.com/paholg/typenum/issues/162 + let first2: u32 = 11; // (highest as f64).log(2.0).round() as u32 + 1; + let first10: u32 = 4; // (highest as f64).log(10.0) as u32 + 1; let uints = (0..(highest + 1)) .chain((first2..64).map(|i| 2u64.pow(i))) .chain((first10..20).map(|i| 10u64.pow(i)));