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

no_std support #528

Closed
wants to merge 5 commits into from
Closed

no_std support #528

wants to merge 5 commits into from

Commits on Dec 1, 2020

  1. no_std support

    We use the [`alloc`](https://doc.rust-lang.org/alloc/) create, which requires the user define a global allocator.
    
    * Import from `core` and `alloc` instead of `std`
    * Create `std` feature
    * Create `use-bare-io` feature which adds a
      [bare-io](https://github.com/bbqsrc/bare-io) dependency to polyfill
      `std::io` features. This is an experimental feature and should be
      used with extreme caution.
    * Created an `io` module to polyfill `std::io` with `bare-io` in
      `no_std`.
    * Replace `HashMap` and `HashSet` with `BTreeMap` and `BTreeSet` just to
      get something working. This needs to be fixed.
    * CI runs tests `no_std` code
    justinmoon committed Dec 1, 2020
    Configuration menu
    Copy the full SHA
    15cb1c5 View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2020

  1. Configuration menu
    Copy the full SHA
    cab8669 View commit details
    Browse the repository at this point in the history

Commits on Dec 12, 2020

  1. Improve std::collections handling

    `std::collections::HashMap` and `std::collections::HashSet` don't have
    any analogue in `alloc` because they require a OS RNG.
    
    [Recently no_std-compatible implementations have been
    merged](rust-lang/rust#58623) but I think we'd
    need to massively increase our MSRV.
    
    So I opted to move any `HasMap` or `HasSet` usage in tests to `BTreeMap` or `BTreeSet`, and to gate the only non-test usage of `HashMap` or `HashSet` (in the merkle block code which won't be helpful on MCUs) behind a "std" feature flag. Public API doesn't change.
    justinmoon committed Dec 12, 2020
    Configuration menu
    Copy the full SHA
    018fd06 View commit details
    Browse the repository at this point in the history
  2. Compiles for stable 1.36.0

    Upgraded bare-io to a branch which adds a feature to disable the
    `#[non_exhaustive]` attribute, which wasn't stabilized until 1.40.0.
    justinmoon committed Dec 12, 2020
    Configuration menu
    Copy the full SHA
    1e1f29a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    be0d332 View commit details
    Browse the repository at this point in the history