Skip to content

[parity-bytes] add no-std support #154

Merged
dvdplm merged 13 commits into
paritytech:masterfrom
bradyjoestar:master
May 16, 2019
Merged

[parity-bytes] add no-std support #154
dvdplm merged 13 commits into
paritytech:masterfrom
bradyjoestar:master

Conversation

@bradyjoestar
Copy link
Copy Markdown
Contributor

@bradyjoestar bradyjoestar commented May 15, 2019

Fixes #153

@parity-cla-bot
Copy link
Copy Markdown

It looks like @bradyjoestar hasn't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io

Once you've signed, please reply to this thread with [clabot:check] to prove it.

Many thanks,

Parity Technologies CLA Bot

@bradyjoestar
Copy link
Copy Markdown
Contributor Author

: [clabot:check]

@parity-cla-bot
Copy link
Copy Markdown

It looks like @bradyjoestar signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

Comment thread parity-bytes/Cargo.toml Outdated
Comment thread parity-bytes/src/lib.rs
Comment thread parity-bytes/src/lib.rs Outdated
extern crate alloc;

// Re-export libcore using an alias so that the macros can work without
// requiring `extern crate core` downstream.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand what you mean by "the macros" – are there macros exported from this crate?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it from the elastic-array and it have some marcos exported.
https://github.com/debris/elastic-array/blob/8f01572f850e6f387ad785fb1e59d599eb260ea0/src/lib.rs#L11-L28

I'm not sure whether will be some macros exported from this crate, so I didn't delete it 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we’re not doing it for the macros, then what is the purpose of this re-export? Can we remove it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. 👌

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think you need to do:

#[cfg(feature = "std")]
extern crate core;

(notice no pub)

…and then replace use core_::{… … with use core::{… ….

The idea is that when running with std you need to import the core as a crate. In no_std mode core is part of the prelude.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your guide!

@ordian
Copy link
Copy Markdown
Contributor

ordian commented May 15, 2019

Would be nice adding a README with a no-std section to parity-bytes (explaining it's currently nightly-only), similar to https://github.com/paritytech/parity-wasm#no_std-crates

@bradyjoestar
Copy link
Copy Markdown
Contributor Author

I have met the similar error when running cargo +nightly test --no-default-features:
rust-lang/rust#54010

#[macro_use] is added and I had forgot the String.

Copy link
Copy Markdown
Contributor

@ordian ordian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add cd parity-bytes; cargo build --no-default-features; cd .. for nightly in .travis.yml, cf.
https://github.com/paritytech/parity-wasm/blob/6aaa9648a6fcb97d143a0f35a0e2b6dfa4d3f00a/.travis.yml#L17

Comment thread parity-bytes/README.md Outdated
Comment thread parity-bytes/README.md Outdated
@ordian ordian changed the title support no-std for parity-bytes [parity-bytes] add no-std support May 15, 2019
bradyjoestar and others added 4 commits May 15, 2019 09:31
Comment thread parity-bytes/README.md Outdated

```toml
[dependencies]
parity-bytes = { version = "0.1.1", default-features = false }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nitpick but let’s do version = “0.1”.

Comment thread parity-bytes/src/lib.rs Outdated
extern crate alloc;

// Re-export libcore using an alias so that the macros can work without
// requiring `extern crate core` downstream.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we’re not doing it for the macros, then what is the purpose of this re-export? Can we remove it?

Comment thread parity-bytes/src/lib.rs
extern crate alloc;

#[doc(hidden)]
extern crate core;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvdplm dvdplm merged commit bcf86ae into paritytech:master May 16, 2019
@dvdplm
Copy link
Copy Markdown
Contributor

dvdplm commented May 16, 2019

@bradyjoestar thank you for your work here! :)

@bradyjoestar
Copy link
Copy Markdown
Contributor Author

my pleasure! :)

dvdplm added a commit that referenced this pull request May 16, 2019
…fix/zero-memory-for-hmac-signing-keys

* 'master' of github.com:paritytech/parity-common:
  [parity-bytes] add no-std support   (#154)
ordian added a commit to ordian/parity-common that referenced this pull request May 16, 2019
* paritytech/master:
  [parity-bytes] add no-std support   (paritytech#154)
  [parity-crypto] Derive Debug for digests and signatures (paritytech#155)
  Restore the previous API to allow variable size keys for Hmac operations (paritytech#152)
  Implemented TryFrom<biguint> for primitives (paritytech#148)
dvdplm added a commit that referenced this pull request May 19, 2019
* master:
  [parity-crypto] zero memory for hmac signing keys (#157)
  Added absolute path for 'Result' usage in macros to avoid type collisions. (#160)
  [parity-bytes] add no-std support   (#154)
  [parity-crypto] Derive Debug for digests and signatures (#155)
  Restore the previous API to allow variable size keys for Hmac operations (#152)
  Implemented TryFrom<biguint> for primitives (#148)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support paritybytes in #![no_std] libraries

4 participants