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

Skip to content

Conversation

@febo
Copy link
Contributor

@febo febo commented Oct 17, 2025

Problem

The upstream compiler uses target_arch = "bpf" when compiling to bpfel-unknown-none target, while the cfg conditional compilation is currently using only target_os = "solana".

Solution

Add target_arch = "bpf" along side target_os = "solana".

@febo febo marked this pull request as draft October 17, 2025 22:50
@febo
Copy link
Contributor Author

febo commented Oct 17, 2025

Needs #387 to go first.

@febo febo marked this pull request as ready for review October 19, 2025 12:25
bytemuck = ["copy", "dep:bytemuck", "dep:bytemuck_derive"]
copy = []
curve25519 = ["dep:curve25519-dalek", "error", "sha2"]
curve25519 = ["dep:curve25519-dalek", "sha2", "syscalls"]
Copy link
Contributor Author

@febo febo Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling feature "curve25519" will enable the syscalls module, which will try to use solana-define-syscall dependency when target_os = "solana" or target_arch = "bpf", breaking the build. The fix here enables the "syscalls" feature so the dependency is found; it has no effect on other targets, it will only bring the required "error" feature.

Alternatively, we could improve the separation between the "curve25519" and "syscalls" features, but this does not seem necessary at the moment.

@febo febo requested a review from joncinque October 19, 2025 12:31

/// Marker used to find program derived addresses (PDAs).
#[cfg(target_arch = "bpf")]
pub static PDA_MARKER: &[u8; 21] = b"ProgramDerivedAddress";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_arch = "bpf" only supports scalar constants, so we need to switch this to be static instead.

macro_rules! declare_id {
($address:expr) => {
/// The const program ID.
pub static ID: $crate::Address = $crate::Address::from_str_const($address);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, needs to be static for target_arch = "bpf".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant