meson
meson copied to clipboard
Add option to support split debug informations
Use-case
The buildtype debugoptimized is useful to allow having debug info even for release build. On some toolchain (ex: gcc) it is possible to split that debug info from the binary, allowing to only distribute the binary to the user. This have space and confidentiality advantages.
Current situtation
Currently, the job must be done manually on each executable/library. This means the following command on each:
objcopy --only-keep-debug BIN .debug/BIN.debug strip --strip-debug --strip-unneeded BIN objcopy --add-gnu-debuglink=.debug/BIN.debug BIN.debug
Suggested feature
Add workspace option splitDebug
(as an alternative to simply split
) that would do such an operation on each binary without the user having to do anything.
Note: strip and objcopy may be interchangeable.
The functionality is something we probably do want. But to avoid option proliferation, we'd probably need to do something about #4574 first.
Any chance for this functionality to be implemented? Since it doesn't seem that #4574 will be resolved any time soon...
Ideally, there should be a debug-symbols
option with the choices like ['strip', 'keep', 'separate']
. This would remove the need for the separate strip
option (it will also allow to utilize various Debug Information
options in MSVS backend directly, instead of the current obscure --debug
option side-effect).
Alternative (stolen from @nirbheek from IRC): add --strip
/--split
to meson install
instead. Makes o-mega sense for Linux, but not sure if possible to implement on Windows.
On Windows debug info inside the object files is deprecated, and we don't support it anyway. It is always split. So the options don't have to do anything on Windows.
Noting that any solution we come up with here should also natively handle split debug info (-fsplit-dwarf
) on Linux. It does make things noticeably faster for big projects (I tested this by building Clang ages ago).
A couple of notes:
- The documentation for
--add-gnu-debuglink
in objcopy suggests not specifying any path components in the link; tools will then search several places for the debug info. - For my use case, I would like to have control over where the debug info gets installed (I distribute debug info separately from pre-built binaries, so for the packaging process it helps to have them installed to different places).
FYI, I have a PR for that: https://github.com/mesonbuild/meson/pull/10064.
This would be very useful for the work I am doing right now.
Something like: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28576 ?
Would be nice to have in meson, thou not sure for how many project it's really useful. I understand that Firefox and LibreOffice make sense, but smaller projects usually don't care much.
For proprietary projects, it can be a huge help.