Keeping debug info, but smaller?

Debug information that Rust generates is huge. In my case, in release mode, it's 480MB of debug info for a 22MB stripped executable.

I would like to keep some minimal debug info to get line numbers in backtraces, but 480MB for this seems excessive.

  • Is it normal that the debug info is so large?
  • Can I do something to generate only minimal debug information (line numbers only)?

Seems like you want -C debuginfo=1:

What setting are you currently using for the debug key in your release profile? You can set it to 1 which is in between the default dev setting and the default release setting. Or you can use 0 (default for the release profile) which I think still emits enough info for stack traces.

debug = 1

That said, I'm not sure why your debuginfo is so large. I just tested one of my (much smaller) projects, on MacOS, and it is:

  • 2.0 MB stripped
  • 2.4 MB with debug = 0
  • 2.7 MB with debug = 1
  • 2.7 MB with debug = 2

debug=1 took it down from 480MB to 105MB, thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.