-
Notifications
You must be signed in to change notification settings - Fork 41
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 no_std support #108
Add no_std support #108
Conversation
It finally compiles but the design is not finalized. bare-io and hashbrown are used as temporary (?) shims.
@ailisp , @willemneal could you take a look? |
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
==========================================
- Coverage 93.43% 93.21% -0.22%
==========================================
Files 21 21
Lines 1219 1224 +5
==========================================
+ Hits 1139 1141 +2
- Misses 80 83 +3
Continue to review full report at Codecov.
|
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.
Re: "Replace bare-io with semi-custom Error and Write". If the only reason for this is the support for the String
error messages, I vote for dropping format!
and using a static string message (&'static str
). I don't want us to vendor the fork of std library.
@frol We updated the PR |
bare-io is incomplete: there are no hashmaps and hashsets. That's why anyway we should use std polyfill (like serde). |
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.
It seems that the test suite is not running under no-std
mode. I have just tested cargo test -Zpackage-features --package borsh --no-default-features
and it failed to compile for obvious reasons of using std contexts. Please, add the relevant cargo test
commands to .travis.yml
.
P.S. See next commentcargo test -Zpackage-features --workspace --no-default-features
is not working properly rust-lang/cargo#7160
Oh, well,
|
Co-authored-by: Vlad Frolov <[email protected]>
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.
In order to test no-std, we need to have #![cfg_attr(not(feature = "std"), no_std)]
in the test files. Once I add this line to our tests, if fails to compile now. Please, address the compilation errors and make sure that no-std is indeed tested.
P.S. There seems to be a conflict in .travis.yml
P.S.2. Ideally, we need to test that the data structures from no-std are deserializable in std context and wise-versa, but we can work on this under a separate issue.
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.
On the other hand, it would fail due to unsupported std types anyway, so it is fine as is, I guess.
@snjax @voidxnull Great work! It is good to be merged. Please, resolve the merge conflict on .travis.yml
(I don't have permissions to push to your PR branch to fix it myself)
@frol Done. |
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.
I am sorry to get back and forth here, but CI is completely broken now.
- stable and beta Rust complain about the
-Zpackage-features
flag being unstable. Let's replace the command withcd borsh && cargo test --no-default-features
nightly-2019-05-22
is too old, replace it withnightly-2020-05-15
, which we use for nearcore
584cbbc
to
7879fe8
Compare
@frol done |
Thank you! |
Add no_std support for borsh.
Polyfill is implemented at
borsh::lib::*
andborsh::error
(same as in serde).For no_std borsh HashMap is imported from
hashbrown
and Error and Write imported frombare_io
.