Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hard-coded values in build script #177

Merged
merged 1 commit into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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