-
Notifications
You must be signed in to change notification settings - Fork 20
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
WIP: feedback needed - no_std #25
Conversation
data-encoding-macro = "0.1.8" | ||
base-x = { git = "https://github.com/whalelephant/base-x-rs", branch = "no_std", default-features = false } | ||
data-encoding = { version = "2.3", default-features = false, features = ["alloc"] } | ||
lazy_static = { features = ["spin_no_std"], version = "1.4.0" } |
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.
You shouldn't use spin_no_std
with this package's std
feature. Spin locks are almost always bad when there is another scheduler.
Also, I'd say rather than using lazy_static, which has runtime overhead which might matter in small no-std environments. I would just (maybe conditionally) define the constants the results of evaluation for no-std, and test that those hand-written constants equal to the original compile-time-evaluated definitions. |
There are currently const &str for base10 and some base58 which are then used as base input for base-x encoding / decoding when implementing BaseCodec. But it looks like base-x shouldn't be used for base16 (hex), base32, or base64 as it is not compliant. I am not sure if this is what you had in mind or I might have misunderstood. Please could you clarify? thanks! |
@whalelephant |
#[cfg(not(feature = "std"))] | ||
use core as std; | ||
|
||
use std::fmt; |
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.
Could we just use core
directly, without special-casing no_std?
So this would just be use core::fmt and further below
core::result::Result<T, Error>`.
@whalelephant sorry for the lack of feedback.
Yes that's correct. -- @mriise when I look into the diff between between this master branch and yours master...mriise:nstd, it seems that I also think the I've also left some comments on this PR which are still part of yours. |
Hi @vmx thanks for the feedback regarding using core. Agree with not using |
@whalelephant while it does say that in the doc, forcing |
@mriise I am not very familiar with it either, but running your branch with ▶ multibase: ✅
base-x: ✅
data-encoding: ✅
data-encoding-macro: ❌
- Did not find a #![no_std] attribute or a simple conditional attribute like #[cfg_attr(not(feature = "std"), no_std)] in the crate source. Crate most likely doesn't support no_std without changes. |
@whalelephant I've never seen that tool before, looks useful. |
Is it possible that a flag in a dev-dependency used in the build leaks into the production crate? There is an unstable solution for that in cargo, but on stable build still pollutes production dependency flags. |
I had a look. I guess it's referring to the use of the internal macro, though it's strange that if it is only a build dependency, it's still listed under the normal dependencies. Though, even if it would be a dev dependency, it won't change the fact that |
So after doing a few hours of playing around with the data-encoding library, it turns out while normally std does leak into the proc macro as the proc_macro crate depends on std, the compiler seems to be able to understand and build the proc_macro with std before using it if you set the I made sure this worked properly by building with |
Sorry if the missing no-std support for data-encoding-macro has delayed this pull-request. Thanks @mriise for reaching out. Let me know if I can help further (I'll wait confirmation to know if a release is needed otherwise I'll wait to do further improvements before releasing which may take up to a month). |
@ia0 no worries! Thanks for the quick response to get this through! @whalelephant @vmx would it be preferable to make PRs on whale's fork or to make a separate PR on this repo? |
@ia0: Waiting sounds good to me, there is no immediate rush (I hope others agree, if not, please comment).
I have no preference, whatever is easier for you @mriise. |
Awesome! Happy for this to be closed and @mriise can work on the latest code. 👍 |
Actually I managed to do the other improvements I wanted (essentially support for no-alloc in addition to no-std). So you can use version
|
@whalelephant no_std compatable with #30 🎉 |
Hi,
Referring to #24, this PR supports no_std by
const
required compile time eval are now using the suggestedlazy_static
withspin_no_std
no_std
branch forked from published crates. PR hereJust want to start the discussion as to how best to proceed to get this PR merge. Thanks!