From 27bbb696ba85fcef8c62abcd95c65e793e558a87 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Thu, 4 Apr 2024 08:53:39 -0500 Subject: [PATCH] add frozen abi requirements --- Cargo.lock | 6 ++++++ program/Cargo.toml | 8 ++++++++ program/build.rs | 23 +++++++++++++++++++++++ program/src/lib.rs | 3 +++ 4 files changed, 40 insertions(+) create mode 100644 program/build.rs diff --git a/Cargo.lock b/Cargo.lock index 0b2faf1..30a71f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1340,6 +1340,12 @@ dependencies = [ name = "solana-vote-program" version = "0.1.0" dependencies = [ + "bincode", + "log", + "rustc_version", + "serde", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-program", ] diff --git a/program/Cargo.toml b/program/Cargo.toml index a7d6a06..a081384 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -16,7 +16,15 @@ bpf-entrypoint = [] test-sbf = [] [dependencies] +bincode = "1.3.3" +log = "0.4.20" +serde = { version = "1.0.193", features = ["derive"] } +solana-frozen-abi-macro = "1.18.2" +solana-frozen-abi = "1.18.2" solana-program = "1.18.2" [lib] crate-type = ["cdylib", "lib"] + +[build-dependencies] +rustc_version = "0.4" \ No newline at end of file diff --git a/program/build.rs b/program/build.rs new file mode 100644 index 0000000..929a639 --- /dev/null +++ b/program/build.rs @@ -0,0 +1,23 @@ +//! Required for `solana-frozen-abi-macro` to work. +extern crate rustc_version; +use rustc_version::{version_meta, Channel}; + +fn main() { + // Copied and adapted from + // https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example + // Licensed under Apache-2.0 + MIT + match version_meta().unwrap().channel { + Channel::Stable => { + println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); + } + Channel::Beta => { + println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); + } + Channel::Nightly => { + println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); + } + Channel::Dev => { + println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); + } + } +} diff --git a/program/src/lib.rs b/program/src/lib.rs index 699746f..6e89513 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -1,4 +1,7 @@ //! Vote Program. +// [Core BPF]: Required for `solana-frozen-abi-macro` to work. +#![allow(incomplete_features)] +#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))] #[cfg(all(target_os = "solana", feature = "bpf-entrypoint"))] mod entrypoint;