Skip to content

Commit

Permalink
Use hard-coded values in build script
Browse files Browse the repository at this point in the history
  • Loading branch information
paholg committed Dec 25, 2021
1 parent 500ef75 commit 056761e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit 056761e

Please sign in to comment.