Skip to content

Pass rustc the equivalent of -Wframe-larger-than=1000 #121

Open

Description

@ojeda
No description provided.

Activity

  1. changed the title [-]Pass rustc the equivalent of -Wframe-larger-than=1000[/-] [+]Pass `rustc` the equivalent of `-Wframe-larger-than=1000`[/+] on Mar 18, 2021
  2. mpe commented on Apr 10, 2021

    @mpe

    Is there such a thing? I had a look and couldn't find it, but I'm not a rustc expert.

  3. ojeda commented on Apr 10, 2021

    @ojeda
    MemberAuthor

    Not sure -- we may need to implement it ourselves! :)

  4. bjorn3 commented on Apr 15, 2021

    @bjorn3
    Member

    No, there isn't a direct option, but there are things that can help. There is rust-lang/rust#83519 for moves of large values. This includes assignments. For stack frame sizes, only LLVM knows about it. With -Z emit-stack-sizes it is possible to tell LLVM to add a section containing info about stack frame sizes. This option was added to rustc for https://github.com/japaric/cargo-call-stack.

  5. mpe commented on Apr 16, 2021

    @mpe

    OK. I used -Z emit-stack-sizes to debug issue #155, which worked well enough to find the large functions. I guess that's not useful for an upstream stack size warning option though, because it would require nightly rustc (AIUI).

  6. TheSven73 commented on Apr 16, 2021

    @TheSven73
    Collaborator

    @mpe would you mind sharing how you obtained a list of function stack sizes using -Z emit-stack-sizes? I'd like to do the same for arm 32-bit. It's quite possible that stack overflows are happening there too.

  7. mpe commented on Apr 16, 2021

    @mpe

    Something like this:

    $ make KRUSTCFLAGS="-Z emit-stack-sizes"
    $ cargo install stack-sizes
    $ stack-sizes vmlinux | sort -nk 2
    
  8. ojeda commented on Apr 16, 2021

    @ojeda
    MemberAuthor

    I guess that's not useful for an upstream stack size warning option though, because it would require nightly rustc (AIUI).

    Yeah -- we should use it nevertheless. That way the rustc folks know it is useful and being used (see the #2 list), and that we will want it stabilized at some point. If really needed, we can always gate it or take it out later.

  9. bjorn3 commented on Apr 16, 2021

    @bjorn3
    Member

    I don't know what stability guarantee LLVM has for this feature. If LLVM doesn't guarantee that it will remain the same forever, I think it is unlikely that it will be stabilized in rustc.

  10. ojeda commented on Apr 16, 2021

    @ojeda
    MemberAuthor

    My thinking was that given Clang supports -Wframe-larger-than=, LLVM will need to support the feature one way or another, which means it should be fairly easy for rustc to keep providing it too.

  11. bjorn3 commented on Apr 16, 2021

    @bjorn3
    Member

    Clang doesn't use the stack size section. Instead it instructs LLVM to emit a diagnostic whenever the stack size is above a certain threshold. Rustc doesn't have any support for handling LLVM diagnostics except for inline asm.

    https://github.com/llvm/llvm-project/blob/a9968c0a339ab47f5d6da1c513b2754f1e98a596/llvm/lib/CodeGen/PrologEpilogInserter.cpp#L278-L284

    llvm/llvm-project@728c554

  12. nickdesaulniers commented on Jul 22, 2026

    @nickdesaulniers
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    • toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions