coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

anchor build --idl fails with Solana 1.17 and Anchor 0.30 #2984

Open lorisleiva opened 1 month ago

lorisleiva commented 1 month ago

Hi there,

Anchor 0.30.0 doesn't seem to be compatible with Solana 1.17 anymore.

Steps to reproduce

  1. Use Solana 1.17.34. (sh -c "$(curl -sSfL https://release.solana.com/v1.17.34/install)").
  2. Use Anchor 0.30.0. (avm install latest).
  3. Run anchor init my-project and cd into it.
  4. Add solana-program = "=1.17.34" to your program dependencies.
  5. Run anchor build. The first build works but the second (for the IDL) fails with the following error:
error[E0635]: unknown feature `stdsimd`
  --> /Users/loris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ahash-0.8.5/src/lib.rs:99:42
   |
99 | #![cfg_attr(feature = "stdsimd", feature(stdsimd))]

Potential reason

Having seen this PR (https://github.com/coral-xyz/anchor/pull/2893), my guess is that, unpinning the nightly version made it work for 1.18 but broke it for 1.17.

acheroncrypto commented 1 month ago

Solana CLI version is irrelevant to the IDL build process. What is your Rust version?

lorisleiva commented 1 month ago

1.75.0

acheroncrypto commented 1 month ago

Do you still have the error if you update Rust with rustup update?

lorisleiva commented 1 month ago

Unfortunately yes, I get the same error with Rust 1.78.0.

CleanShot 2024-05-27 at 09 44 42@2x

acheroncrypto commented 1 month ago

Solana 1.17 crates have ahash version pinned:

https://github.com/anza-xyz/agave/blob/4a70bc1e00c572857546d44f059b8b6406539587/Cargo.toml#L135

and combined with https://github.com/tkaitchuck/aHash/issues/200, the crates don't get built with the nightly compiler.

I've created an issue in the Agave repo https://github.com/anza-xyz/agave/issues/1572 describing the problem, and included a fix in https://github.com/anza-xyz/agave/pull/1573.

nabeel99 commented 1 month ago

is there any work around this to build the idl ?

Burning-Tiger commented 1 month ago

cargo update --package ahash did it for me.

acheroncrypto commented 1 month ago

is there any work around this to build the idl ?

@nabeel99 You can use solana-program 1.18 which doesn't have this problem.

nabeel99 commented 1 month ago

is there any work around this to build the idl ?

@nabeel99 You can use solana-program 1.18 which doesn't have this problem.

I was integrating the mpl-core crate which use 1.17, as you pointed out ahash js pinned in 1.17.

acheroncrypto commented 1 month ago

I was integrating the mpl-core crate which use 1.17, as you pointed out ahash js pinned in 1.17.

Looks like there isn't going to be another v1.17 release (https://github.com/anza-xyz/agave/pull/1573#issuecomment-2146954062).

You can, however, apply this patch to your root Cargo.toml:

[patch.crates-io]
solana-program = { git = "https://github.com/acheroncrypto/solana", branch = "v1.17-unpin-ahash-version" }

If you have an existing lock file, you might also need to run:

cargo update -p ahash@0.8.5 --precise 0.8.7