-
Couldn't load subscription status.
- Fork 140
feat: add no_std support for cluster-type crate
#337
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
base: master
Are you sure you want to change the base?
feat: add no_std support for cluster-type crate
#337
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.
Amazing stuff! Let's add that crate to scripts/check-no-std.sh, to make sure it's tested in CI.
22fcbb5 to
aa5c23d
Compare
|
looks like this MR is blocked by #323 error[E0599]: no method named `fetch_add` found for struct `core::sync::atomic::AtomicU64` in the current scope
--> atomic-u64/src/lib.rs:15:20
|
15 | self.0.fetch_add(v, atomic::Ordering::Relaxed)
| ^^^^^^^^^ method not found in `core::sync::atomic::AtomicU64`
Some errors have detailed explanations: E0463, E0599.
For more information about an error, try `rustc --explain E0463`. |
The only use of `alloc` was construction of the error message. To make the crate build for the upstream eBPF targets and without `alloc`, use `thiserror` without default features for the error enum.
aa5c23d to
8c74f33
Compare
|
I went ahead and rebased it. #323 fixed the error you mentioned, but then the next one appeared (we were using |
many thanks. Will take a look shortly |
|
@joncinque I'll let you review, since I touched the code 🙂 |
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 overall! Just a few small things
Co-authored-by: Jon C <[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.
A few more questions, sorry for the back and forth
| #[cfg(feature = "std")] | ||
| extern crate std; |
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.
Is the std feature needed at all? If anything, we might only need std for frozen-abi, so may as well just gate bringing in std on that feature, if it's actually required.
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.
needed for frozen-abi
clippy lint command
cargo +nightly-2025-06-29 clippy --workspace --all-targets --features frozen-abi -- --deny=warnings --deny=clippy::def
ault_trait_access --deny=clippy::arithmetic_side_effects --deny=clippy::manual_let_else --deny=clippy::used_underscore_bindingfails with the next error, without std during the CI step
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `std`
--> cluster-type/src/lib.rs:10:43
|
10 | #[cfg_attr(feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor))]
| ^^^^^^^^^^ use of unresolved module or unlinked crate `std`
|
= help: if you wanted to use a crate named `std`, use `cargo add std` to add it to your `Cargo.toml`
= note: this error originates in the derive macro `AbiExample` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
cluster-type/src/lib.rs
Outdated
|
|
||
| impl FromStr for ClusterType { | ||
| type Err = String; | ||
| type Err = ParseClusterTypeError; |
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.
Looking at this one more time, what if we just had type Err = &'static str; and returned a string error directly? that way we don't need the new error type, and it's less of a breaking change
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.
replaced with static str,
i also would prefer to "unmark" this small change as a "breaking"
Problem
solana-cluster-typecrate has nono_stdsupportSummary of Changes
stdfeature and make it enabled by defaultserdeandsolana-hashand and their std features in std mode of thesolana-cluster-typecratesolana-genesis-configcrate dependency to not use std featuresolana-cluster-type