Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idl: Ignore compiler warnings during builds #3396

Conversation

acheroncrypto
Copy link
Collaborator

Problem

The current IDL build process uses the nightly compiler to generate the IDL. The recent cargo 1.85.0-nightly (4c39aaff6 2024-11-25) introduced a new set of warnings, for example:

warning: unexpected `cfg` condition value: `custom-heap`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `feature` are: `cpi`, `default`, `idl-build`, `no-entrypoint`, `no-idl`, and `no-log-ix-name`
  = help: consider adding `custom-heap` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default
  = note: this warning originates in the macro `$crate::custom_heap_default` which comes from the expansion of the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `solana`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, and `vita` and 6 more
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: this warning originates in the macro `$crate::custom_heap_default` which comes from the expansion of the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `custom-panic`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `feature` are: `cpi`, `default`, `idl-build`, `no-entrypoint`, `no-idl`, and `no-log-ix-name`
  = help: consider adding `custom-panic` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: this warning originates in the macro `$crate::custom_panic_default` which comes from the expansion of the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `solana`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, and `vita` and 6 more
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: this warning originates in the macro `$crate::custom_panic_default` which comes from the expansion of the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `anchor-debug`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `feature` are: `cpi`, `default`, `idl-build`, `no-entrypoint`, `no-idl`, and `no-log-ix-name`
  = help: consider adding `anchor-debug` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: this warning originates in the attribute macro `program` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `anchor-debug`
 --> programs/warnings/src/lib.rs:5:1
  |
5 | #[program]
  | ^^^^^^^^^^
  |
  = note: expected values for `feature` are: `cpi`, `default`, `idl-build`, `no-entrypoint`, `no-idl`, and `no-log-ix-name`
  = help: consider adding `anchor-debug` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: this warning originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)

Some of these warnings come from Anchor and some from Solana. Furthermore, all of the above warnings come from macro code, so there isn't much the user can do to fix them (other than allowing/ignoring them).

Another related problem is that most of the times, the warnings produced by the Solana build toolchain is the same as the nightly compiler, meaning we show the same warnings unnecessarily.

Summary of changes

Ignore all compiler warnings during IDL builds.

Resolves #3386

Copy link

vercel bot commented Nov 29, 2024

@acheroncrypto is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added idl related to the IDL, either program or client side fix Bug fix PR labels Nov 29, 2024
@acheroncrypto acheroncrypto merged commit 6fbfc40 into coral-xyz:master Nov 29, 2024
52 of 53 checks passed
@robertohuertasm
Copy link

I'm following the 2024 bootcamp and I'm using npx create-solana-app. Not sure if I'm missing something but I'm getting all the warnings above. Furthermore, I've created a project with anchor init and again, the same warnings.

The only way to get rid of the warnings is to do anchor build with a pinned version of nightly. Is that ok? I assumed this PR would avoid showing the warnings.

@acheroncrypto
Copy link
Collaborator Author

The only way to get rid of the warnings is to do anchor build with a pinned version of nightly. Is that ok?

Yes, that's totally fine.

I assumed this PR would avoid showing the warnings.

This PR was merged into master but we don't yet have a release that includes it. You can include this fix by installing the CLI via avm install 6fbfc40.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PR idl related to the IDL, either program or client side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warning messages while running anchor test on clean project
2 participants