Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sonicfromnewyoke
Copy link
Contributor

Problem

solana-cluster-type crate has no no_std support

Summary of Changes

  • add std feature and make it enabled by default
  • use optional serde and solana-hash and and their std features in std mode of the solana-cluster-type crate
  • modify solana-genesis-config crate dependency to not use std feature solana-cluster-type

Copy link
Member

@vadorovsky vadorovsky left a 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.

@sonicfromnewyoke
Copy link
Contributor Author

looks like this MR is blocked by #323
ci step will fail with the next error

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`.

sonicfromnewyoke and others added 3 commits October 21, 2025 14:53
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.
@vadorovsky vadorovsky force-pushed the sonic/no-std-cluster-type branch from aa5c23d to 8c74f33 Compare October 21, 2025 13:11
@vadorovsky
Copy link
Member

I went ahead and rebased it. #323 fixed the error you mentioned, but then the next one appeared (we were using alloc unconditionally) - I added commit that fixes it.

@sonicfromnewyoke
Copy link
Contributor Author

sonicfromnewyoke commented Oct 21, 2025

I went ahead and rebased it. #323 fixed the error you mentioned, but then the next one appeared (we were using alloc unconditionally) - I added commit that fixes it.

many thanks. Will take a look shortly

@vadorovsky vadorovsky requested a review from joncinque October 21, 2025 14:44
@vadorovsky
Copy link
Member

@joncinque I'll let you review, since I touched the code 🙂

@joncinque joncinque added the breaking PR contains breaking changes label Oct 21, 2025
Copy link
Collaborator

@joncinque joncinque left a 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

Copy link
Collaborator

@joncinque joncinque left a 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

Comment on lines +4 to +5
#[cfg(feature = "std")]
extern crate std;
Copy link
Collaborator

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.

Copy link
Contributor Author

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_binding

fails 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


impl FromStr for ClusterType {
type Err = String;
type Err = ParseClusterTypeError;
Copy link
Collaborator

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

Copy link
Contributor Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking PR contains breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants