Skip to content

Conversation

@josephlr
Copy link
Contributor

Right now, src/lib.rs defines ring to be a no_std crate conditionally based on the features and CPU architecture. This is sub-optimal, as it requires a lot of cfg attributes to be kept in sync. Both rand and rdrand have dealt with this kind of problem, and they use the following solution.

  • The create is unconditionally #![no_std]
  • If std is needed, it can be brought in with extern crate std
  • There are no bare use std or use core statements (as they are never necessary)

This is what I did in this PR. Some advantages to this PR:

  • It is now very easy to see what ring is depending on from std. This helps with:
  • After extern crate alloc lands in the next stable Rust release, most of the use std:: statements can be turned into use alloc::.
  • It will make it easier to eventually split the use_heap feature into two features
    • std: Enables getting randomness from files and std::error::Error implementations
    • alloc: Enables operations that need dynamic memory allocation (RSA signing, etc...)
  • Helps with the porting work in Add support for x86_64-unknown-uefi #787 and Port to SGX #775

@briansmith briansmith merged commit 7b0f9ad into briansmith:master Jun 13, 2019
@briansmith
Copy link
Owner

Thanks!

@josephlr josephlr deleted the std branch June 13, 2019 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants