-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Do not build anchor syn for the Solana target #3062
base: master
Are you sure you want to change the base?
Conversation
@LucasSte is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, but could you mention how you got these spurious stack error warnings? You'd get it if you included anchor-syn
as a direct dependency, but we don't have a direct dependency to it. You shouldn't run into this just from using anchor-lang
.
The contract I was testing had |
Yeah it's used for code generation, though only exception currently is the Lines 102 to 116 in 0a1d458
This feature is not being used much at all, but someone ran into an issue with it last year and submitted a fix (#2682). This is also what I meant when I said unreachable code in #3060 (comment). You get unnecessary stack errors even though that code never gets called. You don't even need a dependency for it, as you also get those errors if you just create a function that overflows the stack even if it never gets called. For example: pub fn _random_function_that_never_gets_called() {
let x = [u8::MAX; 8192];
format!("{x:?}");
} This should be fixed before fully blocking compilation imo. |
Now the issue with hash in the BPF target is interesting. The BPF target is deprecated for almost two years: solana-labs/solana#28125. We also have been replacing the |
I don't see why that code should exist in |
I can think of unused code in two ways:
|
It's not exactly about unused dependencies, it's about unused functions. You can add a dependency and use many functions from that library that doesn't overflow the stack, but you still get the stack error logs if there is a function that overflows the stack even it's not getting called from your program (or from your dependencies).
This kind of assumes people only use Solana crates in their program, we can't expect other crates in the Rust ecosystem to add that check to their crates.
Did you make the function you're testing public like the example I shared above? Putting the above function in |
Function inside
anchor/lang/syn
only serve for code generation, but are also built for Solana programs, leading to spurious stack error warnings.