Skip to content

no-std checks#33

Merged
grod220 merged 4 commits intomainfrom
no-std-checks
May 8, 2026
Merged

no-std checks#33
grod220 merged 4 commits intomainfrom
no-std-checks

Conversation

@grod220
Copy link
Copy Markdown
Member

@grod220 grod220 commented May 8, 2026

Introduces optional no-std package checks to the main action.

API

Consumers provide package lists by no-std mode:

  • no-std-core-packages runs make check-no-std-core-<package>
  • no-std-alloc-packages runs make check-no-std-alloc-<package>

The consumer owns the exact cargo hack flags (and any necessary excludes) for each mode:

check-no-std-core-%:
	cargo $(nightly) hack check \
		--target bpfel-unknown-none \
		--each-feature \
		--package $* \
		-Zbuild-std=core \
		$(ARGS)

check-no-std-alloc-%:
	cargo $(nightly) hack check \
		--target bpfel-unknown-none \
		--each-feature \
		--package $* \
		-Zbuild-std=alloc,core \
		--exclude-features serde \
		$(ARGS)

Workflow usage looks like:

name: Main

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  NO_STD_ALLOC_PACKAGES: "['spl-token-2022-interface']"

jobs:
  set_env:
    name: Set variables to be used in strategy definitions in reusable workflow
    runs-on: ubuntu-latest
    outputs:
      RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }}
      NO_STD_ALLOC_PACKAGES: ${{ steps.compute.outputs.NO_STD_ALLOC_PACKAGES }}
    steps:
      - name: Git Checkout
        uses: actions/checkout@v4

      - name: Compute variables
        id: compute
        shell: bash
        run: |
          {
            echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)"
            echo "NO_STD_ALLOC_PACKAGES=${{ env.NO_STD_ALLOC_PACKAGES }}"
          } >> "$GITHUB_OUTPUT"

  main:
    needs: set_env
    uses: solana-program/actions/.github/workflows/main.yml@main
    with:
      no-std-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }}
      no-std-alloc-packages: ${{ needs.set_env.outputs.NO_STD_ALLOC_PACKAGES }}

@grod220 grod220 requested a review from joncinque May 8, 2026 00:20
Copy link
Copy Markdown
Contributor

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

The JSON configuration feels a bit over-engineered -- how about having two separate jobs, one for core and one for alloc?

As for features, we should be able to keep the interfaces and programs simple enough that they don't need default features, which means we don't need to exclude.

What do you think?

@grod220
Copy link
Copy Markdown
Member Author

grod220 commented May 8, 2026

we should be able to keep the interfaces and programs simple enough that they don't need default features, which means we don't need to exclude.

The issue is the non-default features that are checked as well via --each-feature. Or are you saying we don't need no-std checks for those? Or we could keep that and expect consumers to add global feature excludes in their makefile (and not main.yml) if they needed it (expecting no feature name collisions between packages):

check-no-std-%:
	cargo $(nightly) hack check \
		--target bpfel-unknown-none \
		--each-feature \
+       --exclude-features atomic,batch-verify,bincode... \
		--package $* \
		$(ARGS)

What do you think?

@joncinque
Copy link
Copy Markdown
Contributor

Ah sorry I forgot about the cargo-hack usage -- I prefer your suggestion of having each Makefile specify exclusion features at the top, if needed.

@grod220 grod220 requested a review from joncinque May 8, 2026 13:58
Copy link
Copy Markdown
Contributor

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

Just a small point, the rest looks great to me!

Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml Outdated
grod220 and others added 2 commits May 8, 2026 11:51
Co-authored-by: Jon C <me@jonc.dev>
Co-authored-by: Jon C <me@jonc.dev>
@grod220 grod220 requested a review from joncinque May 8, 2026 15:52
Copy link
Copy Markdown
Contributor

@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 great!

@grod220 grod220 merged commit a59cf68 into main May 8, 2026
@grod220 grod220 deleted the no-std-checks branch May 8, 2026 16:02
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.

2 participants