Skip to content

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

Open
@xphoniex

Description

@xphoniex

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions