1

Within a new empty project,

after adding the apecs crate:

[dependencies]
anchor-lang = "0.28.0"
apecs = "0.7.0"

I get the following errors:

Error: Function _ZN15crossbeam_epoch8internal6Global8push_bag17hfdcb92dd856eedecE Stack offset of 4104 exceeded max offset of 4096 by 8 bytes, please minimize large stack variables
Error: Function _ZN15crossbeam_epoch8internal6Global7collect17h2361c8dbc180126aE Stack offset of 4176 exceeded max offset of 4096 by 80 bytes, please minimize large stack variables
...
error: could not compile `async-executor`

with:

anchor-lang 0.28.0
anchor-cli 0.28.0
solana-cli 1.16.16 

1 Answer 1

2

Unfortunately, Solana programs cannot bring in every possible dependency, mainly because the runtime only provides access to certain syscalls.

The apecs crate appears to bring in many other dependencies, such as a full async runtime. The crate needs to be dramatically reduced in scope in order to work on-chain.

You can find more information about dependencies at https://docs.solana.com/developing/on-chain-programs/developing-rust#project-dependencies

2
  • Thank you. Any hint for what's causing the "exceeded max offset of 4096 by x bytes, please minimize large stack variables" kind of issues? Seems Anchor specific, although apecs wouldn't work anyway for the async libs and missing syscalls as you mentioned. I'm hitting this issue with several existing libs. Jan 15 at 7:59
  • 1
    That's a separate issue, due to how stack frames work in Solana BPF currently. Essentially, functions only get a maximum of 4096 bytes for stack variables, so if you go past that, the function will fail during runtime. You can read more about it at docs.solana.com/developing/on-chain-programs/faq#stack -- if your program uses those functions, they'll need to get modified
    – Jon C
    Jan 15 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.