From 991bd7cf407b97720ae94080b120393b7dac7366 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 25 Jul 2025 12:05:30 +0200 Subject: [PATCH 1/2] sdk!: Remove `program` feature #### Problem The `program` feature has existed since v1.3 so that people can use solana-sdk in on-chain programs. `cargo-build-sbf` even had a special case where it would enable the `program` feature when building solana-sdk, but it was removed in https://github.com/anza-xyz/agave/pull/5870. This means that our current build-sbf script fails when using v2.3 of the tools. #### Summary of changes Remove the `program` feature from the sdk, and fix the build-sbf script to exclude the sdk, and then try to build without default features. Rather than adding more excludes, I also changes the build-sbf script to use `cargo hack`, which is a bit cleaner. --- .github/workflows/main.yml | 9 +++++++- scripts/build-sbf.sh | 45 ++++++++++++++++++-------------------- sdk/Cargo.toml | 5 ----- sdk/src/log.rs | 2 -- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 000d5112b..69e37a9fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -377,7 +377,9 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup with: - stable-toolchain: true + nightly-toolchain: true + cargo-cache-key: cargo-sbf-build + cargo-cache-fallback-key: cargo-sbf - name: Determine Solana CLI version run: | @@ -391,6 +393,11 @@ jobs: version: ${{ env.SOLANA_VERSION }} cache: true + - name: Install cargo-hack + uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: cargo-hack + - name: Run cargo-build-sbf run: ./scripts/build-sbf.sh diff --git a/scripts/build-sbf.sh b/scripts/build-sbf.sh index d39654f80..fb096a85d 100755 --- a/scripts/build-sbf.sh +++ b/scripts/build-sbf.sh @@ -5,29 +5,26 @@ here="$(dirname "$0")" src_root="$(readlink -f "${here}/..")" cd "${src_root}" -exclude_list=( - ".github" - "scripts" - "client-traits" - "ed25519-program" - "example-mocks" - "file-download" - "genesis-config" - "keypair" - "logger" - "offchain-message" - "presigner" - "quic-definitions" - "rent-collector" - "sdk-wasm-js" - "secp256k1-program" - "secp256r1-program" - "system-transaction" - "transaction" +build_sbf_excludes=( + --exclude solana-client-traits + --exclude solana-ed25519-program + --exclude solana-example-mocks + --exclude solana-file-download + --exclude solana-genesis-config + --exclude solana-keypair + --exclude solana-logger + --exclude solana-offchain-message + --exclude solana-presigner + --exclude solana-quic-definitions + --exclude solana-rent-collector + --exclude solana-sdk-wasm-js + --exclude solana-secp256k1-program + --exclude solana-secp256r1-program + --exclude solana-system-transaction + --exclude solana-transaction + --exclude solana-sdk ) -for dir in $(git ls-tree -d --name-only HEAD .); do - if [[ ! " ${exclude_list[*]} " =~ [[:space:]]${dir}[[:space:]] ]]; then - (cd "$dir" && RUSTFLAGS="-Dwarnings" cargo build-sbf) - fi -done +./cargo nightly hack --workspace "${build_sbf_excludes[@]}" build-sbf + +./cargo nightly build-sbf --manifest-path sdk/Cargo.toml --no-default-features diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 30e819828..b76294d20 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -20,11 +20,6 @@ rustdoc-args = ["--cfg=docsrs"] crate-type = ["rlib"] [features] -# "program" feature is a legacy feature retained to support v1.3 and older -# programs. New development should not use this feature. Instead use the -# solana-program crate -program = [] - default = [ "borsh", "full", # functionality that is not compatible or needed for on-chain programs diff --git a/sdk/src/log.rs b/sdk/src/log.rs index 748b241c0..988ae703a 100644 --- a/sdk/src/log.rs +++ b/sdk/src/log.rs @@ -1,3 +1 @@ -#![cfg(feature = "program")] - pub use solana_program::log::*; From 6144f68cb0447998131960648c9a0d8c29813458 Mon Sep 17 00:00:00 2001 From: Jon C Date: Sat, 26 Jul 2025 00:43:12 +0200 Subject: [PATCH 2/2] Exclude solana-sdk --- scripts/build-sbf.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build-sbf.sh b/scripts/build-sbf.sh index fb096a85d..951d854fb 100755 --- a/scripts/build-sbf.sh +++ b/scripts/build-sbf.sh @@ -27,4 +27,5 @@ build_sbf_excludes=( ./cargo nightly hack --workspace "${build_sbf_excludes[@]}" build-sbf -./cargo nightly build-sbf --manifest-path sdk/Cargo.toml --no-default-features +# This can be added back in once the SDK upgrades to v2.3 of Agave tools +#./cargo nightly build-sbf --manifest-path sdk/Cargo.toml --no-default-features