tgstation / rust-g

Rust based libraries for tgstation
MIT License
28 stars 99 forks source link

Separate debug info from .so file #123

Open Mothblocks opened 1 year ago

Mothblocks commented 1 year ago

After #119, the release build of librust_g.so is 70 MB as opposed to the previous 10 MB.

This is extremely unideal. There are two ways I see to solve this.

One is that we make release w/ debug info a separate target, then ship both librust_g.so and librust_g_debug_info.so.

Another is that there might be a way to split it into its own file much like the .pdb. There's a few StackOverflow posts about this, something about objcopy? Not sure how doable it is but that would be ideal if it's feasible

willox commented 1 year ago

No need for separate targets. The binaries can be stripped post-build with the strip command line utility.

I'm not sure this really needs to be done on this repo since people can do it themselves, but it's no big deal.

willox commented 1 year ago

It's a little bit of a "standard" to have x.so and x.so.dbg available and to use the debug version when necessary for debugging core dumps.

Both are valid binaries (but the former has been stripped.)

Mothblocks commented 1 year ago

SpaceManiac gave this:

objcopy --only-keep-debug "$INPUT" "$INPUT.dbg"
strip "$INPUT"
objcopy --add-gnu-debuglink="$INPUT.dbg" "$INPUT"
Mothblocks commented 1 year ago

This new change in 1.65.0 could prove useful: https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#splitting-linux-debuginfo