Debug symbols in separate file?

I would like to have symbols separate from a binary for both debug and release builds. How can I achieve it?

PS: the goal I pursue is to be able to resolve crash stack symbols offline. I understand it should be the same as for C++: there will be fewer symbols for release builds than for debug, but it still should be possible to resolve all non inline functions with the right symbol files?

You can enable debuginfo in release builds in your Cargo.toml:

[profile.release]
debug = true

The process for splitting debuginfo to a separate file is the same as it is for C/C++ using e.g. objcopy and strip.

2 Likes

Would be good for 'cargo build' to take care the automation of necessary procedures to achieve the effect... ? I understand on windows pdbs are always available anyway. Could be good to be consistent.

But PDBs are the default behavior on Windows, and external debuginfo files are not the default on Linux.

but cargo build could give the desirable effect under some option enabled in toml file to override default behaviour on Linux? is it doable?

1 Like