Skip to content

Conversation

@bytehash69
Copy link

Problem

When anchor build is run, if program compilation fails, the build process
would still attempt to generate IDLs. This is wasteful because:

  • IDL generation requires successfully compiled programs
  • It produces confusing error messages
  • Mirrors the logical dependency: compile → then generate IDL

Solution

Add early exit in _build_rust_cwd function when compilation fails,
preventing IDL generation from being attempted.

Changes

  • Added explicit check for compilation success before IDL generation
  • Return error immediately when cargo build-sbf fails
  • IDL generation now only runs after confirmed successful compilation

Related

  • Respects the logical flow: anchor build --no-idlanchor idl build

closes #4056

@vercel
Copy link

vercel bot commented Nov 20, 2025

@bytehash69 is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@jamie-osec
Copy link
Collaborator

if program compilation fails, the build process would still attempt to generate IDLs

Can you explain how to reproduce this situation? Invoking anchor build in a program with code containing errors reports the error and stops, it does not seem to attempt to build the IDL (unless anchor idl build) is explicitly requested.

@jamie-osec
Copy link
Collaborator

Also, the change here doesn't seem to match the PR description. It just makes anchor build --verifiable respect --no-idl, and a failed build propagate the error instead of immediately exiting.

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.

IDL build step should be skipped when program build is failed

2 participants