-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add nostd support #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! So we don't have a bunch of small changes getting reversed back and forth, maybe we should squash this down into one or a couple commits? Either I can do a squash merge or you can do it first.
src/strobe.rs
Outdated
@@ -1,7 +1,7 @@ | |||
//! Minimal implementation of (parts of) Strobe. | |||
|
|||
use keccak; | |||
use std::ops::{Deref, DerefMut}; | |||
use ::core::ops::{Deref, DerefMut}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustfmt seems to want this line above use keccak
and without the leading ::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @isislovecruft. I did this locally while on vacation, but failed to push it :O
Thanks for the PR! I am a little hesitant about merging it without having some reliable way to test that the |
For the testing we can do what subtle currently does with cross-compile on nightly. I'll add that to the Note that this branch currently does not pass the test, and isn't yet |
first pass nostd, turn off default features and add std/alloc features Update Cargo.toml Update Cargo.toml use core ops when in alloc mode chain features remove std::ops entirely since we always have core anyway remove hex and debug transcript to get rid of std errors alloc default set no_std config attribute remove core crate extern import core crate before use don't add extern crate core; use global namespace when referring to core include core explicitly if we're in std mode re-enable debug-transcript feature re-enable debug-transcript feature fmt fixes
I put your .travil.yml changes onto my branch.
I didn't actually have any problems using my branch in no_std mode inside MC code. But it's definitely failing the test after the travis change:
It doesn't make a lot of sense that rand_core would be pulling in std here; Cargo.toml is pretty explicit:
I tried running the xargo build --no-default-features command locally, and I got failures in byteorder and clear_on_drop in addition to rand_core:
I explicitly tried installing the target to make sure that wasn't the problem:
So, really not sure what's going on here. Do you have a working example of a crate that builds in no_std mode using the xargo command above? |
I tried cargo nono, which didn't think byteorder was a problem, but agreed that rand_core was:
Checking rand_core sources now... |
Ok, I was able to fix the cargo nono rand_core error by upgrading to 0.4:
The clear_on_drop failure appears to be spurious; the first line of the lib.rs defines no_std in all non-test modes:
I'll see how the xargo command works now with rand_core 0.4. |
xargo is still failing. So I checked out subtle, to see if it was working there. Looks like it was turned off because it no longer works:
So cargo nono now works, modulo the bogus clear_on_drop error. Can I comment out the xargo test from .travis.yml, and we'll add it back later once subtle does as well? |
Okay @isislovecruft @hdevalence I have a PR in for cargo-nono to fix the spurious error from clear_on_drop: hobofan/cargo-nono#38 I've updated this PR to use cargo nono in .travis.yml. It's currently failing in CI but it will work once the other PR gets pushed and there is a new cargo-nono release. |
Is this PR superseded by #43? |
PR #43 uses xargo to implement a no_std CI check, whereas this PR uses cargo-nono. Unfortunately both tools appear to be broken at this time @hdevalence, so neither can be merged as-is. I haven't heard anything about my cargo-nono PR in almost three weeks, and @isislovecruft says that xargo is no longer being maintained, so we're kind of at an impasse for now. |
Would using something like the script in this README work: https://github.com/hdevalence/no_std_test_lib ? |
My cargo-nono changes were merged and released last night @hdevalence so I'm running a new build to see if it's working. If it's still broken I'll check out your no_std_test_lib. |
The crates.io index is still returning the old 1.1.4 cargo-nono, I'm trying to get it updated now. I tried the script, but it's giving the same errors as xargo. |
…e set when default features turned off
I managed to get cargo-nono v1.1.5 available via crates.io @hdevalence, and CI is now passing. Let me know if there's anything else you need from me. |
Cargo.toml
Outdated
nightly = ["clear_on_drop/nightly"] | ||
debug-transcript = ["hex"] | ||
std = ["rand_core/std", "byteorder/std"] | ||
alloc = ["rand_core/alloc"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the alloc
feature actually get used for anything? I don't think Merlin allocates, so if this feature is only being used to enable a corresponding feature in rand_core
, I'm not sure we need it -- since Cargo features are additive, anything else that needs rand_core/alloc
can enable it themselves.
Cargo.toml
Outdated
nightly = ["clear_on_drop/nightly"] | ||
debug-transcript = ["hex"] | ||
std = ["rand_core/std", "byteorder/std"] | ||
alloc = ["rand_core/alloc"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alloc = ["rand_core/alloc"] |
src/lib.rs
Outdated
@@ -1,3 +1,5 @@ | |||
#![cfg_attr(not(feature = "std"), no_std)] | |||
#![cfg_attr(feature = "alloc", feature(alloc))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#![cfg_attr(feature = "alloc", feature(alloc))] |
Hi, this looks good aside from the |
Nope, I removed the alloc feature and everything still works perfectly. PR is updated, CI is still working. I think we're good now, let me know if you need anything else. And thanks for all your help with this! |
Merged into |
Excellent, thanks @hdevalence. Looking forward to the release so I can make my bulletproofs PR, which was the end goal all along :) |
Released 1.2.0! |
This change implements nostd support for the merlin library. It mostly consists of config directives, and some remapping of std:: to core::.