You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR creates a new cargo feature std, on by default, that can be disabled if the user wants to target an environment with no support for std library.
Motivation
Crate is now supported in a larger number of targets, and is a step into fixing this issue: bluealloy/revm#493.
Solution
This crate doesn't really use any std feature (e.g., threads, IO, file, network). It is a pure computation library, and theoretically it could be pure #![no_std] with no need for a feature to enable "std". But unfortunately I hit into two issues:
Some floating point functions are only available in std (like log2, abs, pow, etc), this is an issue of LLVM relying on the system libraries implementation for these functions. This also happens with memcpy and integer division functions, which LLVM assumes to exist, and is solved by including these functions in compiler_builtins library that can be used by no_std projects. For some reason, the corresponding floating point functions are not in compiler_builtins yet (Tracking issue for f32 and f64 methods in libcore rust-lang/rust#50145). Thus, when std is disabled, this PR disables modules log, pow and root, along with From<f64> and From<f32> implementations, all which relies on the missing floating point functions.
The fact that thiserror is currently std-only (dtolnay/thiserror#211), and the solution to make thiserror no_std depends on a unstable rust feature (rust-lang/rust#103765).
Yes, you can't use thiserror, you have to implement core::fmt::Display manually, and then std::error::Error behind a cfg flag. It's a bit of a pain but not so bad.
The fact that thiserror is currently std-only (dtolnay/thiserror#211), and the solution to make thiserror no_std depends on a unstable rust feature (rust-lang/rust#103765).
Yes, you can't use thiserror, you have to implement core::fmt::Display manually, and then std::error::Error behind a cfg flag. It's a bit of a pain but not so bad.
@lvella@prestwich mind if I finish this up since we need it urgently on our end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR creates a new cargo feature
std, on by default, that can be disabled if the user wants to target an environment with no support forstdlibrary.Motivation
Crate is now supported in a larger number of targets, and is a step into fixing this issue: bluealloy/revm#493.
Solution
This crate doesn't really use any std feature (e.g., threads, IO, file, network). It is a pure computation library, and theoretically it could be pure
#![no_std]with no need for a feature to enable "std". But unfortunately I hit into two issues:thiserroris currently std-only (no_std support on nightly dtolnay/thiserror#211), and the solution to makethiserrorno_std depends on a unstable rust feature (Tracking Issue forErrorincorerust-lang/rust#103765).std(likelog2,abs,pow, etc), this is an issue of LLVM relying on the system libraries implementation for these functions. This also happens withmemcpyand integer division functions, which LLVM assumes to exist, and is solved by including these functions incompiler_builtinslibrary that can be used by no_std projects. For some reason, the corresponding floating point functions are not incompiler_builtinsyet (Tracking issue for f32 and f64 methods in libcore rust-lang/rust#50145). Thus, whenstdis disabled, this PR disables moduleslog,powandroot, along withFrom<f64>andFrom<f32>implementations, all which relies on the missing floating point functions.PR Checklist