meson icon indicating copy to clipboard operation
meson copied to clipboard

Add option to support split debug informations

Open copelnug opened this issue 6 years ago • 11 comments

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.

copelnug avatar Feb 05 '19 22:02 copelnug

The functionality is something we probably do want. But to avoid option proliferation, we'd probably need to do something about #4574 first.

jpakkane avatar Feb 07 '19 23:02 jpakkane

Any chance for this functionality to be implemented? Since it doesn't seem that #4574 will be resolved any time soon...

TheQwertiest avatar Jun 26 '19 07:06 TheQwertiest

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).

TheQwertiest avatar Jun 26 '19 08:06 TheQwertiest

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.

TheQwertiest avatar Jul 10 '20 12:07 TheQwertiest

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.

nirbheek avatar Jul 12 '20 09:07 nirbheek

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).

jpakkane avatar Jul 12 '20 10:07 jpakkane

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).

bmerry avatar Aug 22 '23 12:08 bmerry

FYI, I have a PR for that: https://github.com/mesonbuild/meson/pull/10064.

xclaesse avatar Aug 22 '23 13:08 xclaesse

This would be very useful for the work I am doing right now.

judemille avatar Feb 21 '24 19:02 judemille

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.

okias avatar Apr 04 '24 17:04 okias

For proprietary projects, it can be a huge help.

judemille avatar Apr 05 '24 00:04 judemille