Skip to content

fix: use real cfg gates instead of faking target_os="solana"#100

Merged
L0STE merged 1 commit intomasterfrom
fix/cfg-target-arch-bpf
Mar 27, 2026
Merged

fix: use real cfg gates instead of faking target_os="solana"#100
L0STE merged 1 commit intomasterfrom
fix/cfg-target-arch-bpf

Conversation

@L0STE
Copy link
Copy Markdown
Contributor

@L0STE L0STE commented Mar 27, 2026

Summary

  • Gate entrypoint, sysvar macro, and string accessors on any(target_os = "solana", target_arch = "bpf") instead of just target_os = "solana"
  • Remove --cfg target_os="solana" from the scaffold template — no longer needed since target_arch = "bpf" is the real cfg for bpfel-unknown-none
  • Matches the pattern already used in ~30 other cfg sites across the codebase

This covers both build paths using real cfg values:

Build path Real cfg that matches
cargo build-sbf (sbf-solana-solana) target_os = "solana"
cargo build-bpf (bpfel-unknown-none) target_arch = "bpf"

Closes #95
Closes #96

The scaffold template injected `--cfg target_os="solana"` into
rustflags for the `bpfel-unknown-none` target, lying about the
actual target OS. Newer nightly rustc rejects this with
`explicit_builtin_cfgs_in_flags`.

Instead, gate on `target_arch = "bpf"` (the real cfg for
bpfel-unknown-none) alongside the existing `target_os = "solana"`
(real for sbf-solana-solana). This matches the pattern already
used in ~30 other cfg sites across the codebase — the entrypoint,
sysvar macro, and string accessors were the only stragglers.

Closes #95
Closes #96
@github-actions
Copy link
Copy Markdown

⚡ CU Benchmark (Vault)

Instruction Base PR Delta
Deposit 1,577 1,577 0 ⚪
Withdraw 411 411 0 ⚪

Binary size: 6,888 bytes (0 ⚪ bytes)

@L0STE L0STE merged commit 5fda2f5 into master Mar 27, 2026
8 checks passed
@L0STE L0STE deleted the fix/cfg-target-arch-bpf branch March 27, 2026 16:12
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.

CLI - build: could not compile when target is upstream

1 participant