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

emit-stack-sizes not reporting correct stack size #108741

Open
xphoniex opened this issue Mar 4, 2023 · 2 comments
Open

emit-stack-sizes not reporting correct stack size #108741

xphoniex opened this issue Mar 4, 2023 · 2 comments
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@xphoniex
Copy link
Contributor

xphoniex commented Mar 4, 2023

I have a library and and app using the library, and compiling for AVR target using avr-gcc. It's seem to be overflowing the device so I want to check stack usage. I tried building my library which is pure rust and got:

$ RUSTFLAGS="-Z emit-stack-sizes" cargo  build --lib -r
...

$ size -A target/release/libnoble_secp256k1.rlib | grep -A1 -B1 double
.text                                                                               0      0
.text._ZN15noble_secp256k15point5Point17double_assign_mod17h64c79c0a4005e01fE    3040      0
.stack_sizes                                                                       10      0

which makes no sense as the function works with 64-byte numbers, and does a few allocations. I turned to cargo-call-stack and as it doesn't support AVR either (japaric/cargo-call-stack#92), I chose an ARM target to view call-stack output:
Screenshot from 2023-03-04 17-33-27

so according to cargo-call-stack which uses emit-stack-sizes under the hood, the same function double_assign_mod uses 1424 bytes, which makes more sense.

related:

rustc --version --verbose:

nightly-2022-07-10

@japaric

@xphoniex xphoniex added the C-bug Category: This is a bug. label Mar 4, 2023
@Noratrieb Noratrieb added the O-AVR Target: AVR processors (ATtiny, ATmega, etc.) label Mar 4, 2023
@xphoniex
Copy link
Contributor Author

xphoniex commented Mar 4, 2023

@Nilstrieb this is not exactly AVR as I'm running RUSTFLAGS="-Z emit-stack-sizes" when building library, which is pure rust, and target shouldn't matter.

@xphoniex
Copy link
Contributor Author

xphoniex commented Mar 4, 2023

maybe this is related:

The tool only supports ELF binaries because -Z emit-stack-sizes only supports the ELF format.

@workingjubilee workingjubilee added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-emit-stack-sizes A-CLI Area: Command-line interface (CLI) to the compiler and removed -Zemit-stack-sizes labels Mar 5, 2023
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: Command-line interface (CLI) to the compiler A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants