rake-compiler / rake-compiler-dock

Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.
MIT License
77 stars 30 forks source link

Including -s in LDFLAGS makes it hard to save debug symbols of release gems #107

Open apolcyn opened 1 year ago

apolcyn commented 1 year ago

Currently, rake-compiler-dock sets -s in LDFLAGS when installing rubies for cross-compilation (done in https://github.com/rake-compiler/rake-compiler-dock/blob/9e840c4192ddad4ad640511f88f1eb3b9f9fb4ad/Dockerfile.mri.erb#L165).

I want to say this logic was carried over from https://github.com/rake-compiler/rake-compiler/pull/165.

Speaking for the grpc gem, when shipping release gems, this -s flag is normally OK because we want to strip symbols anyways.

But it's become apparent that we need to make debug symbols for our pre-compiled binaries available (otherwise, it can be hard to deal with bugs in the wild).

I came up with an approach in https://github.com/grpc/grpc/pull/34632, the idea is:

1) build an unstripped native library

2) save debug symbols off to the side

3) strip the native library, and include this in a release gem

4) publish debug symbols from 2) in a separate auxiliary package

Problem:

Because we have -s in LDFLAGS, in order to do step 1) we need to manually find and remove -s from $LDFLAGS in our extconf.rb.

Finding and removing -s seems fragile long term. For example, if the flag was renamed to --strip-all, our logic would break.

I'm wondering if we can create more explicit way to prevent automatic stripping on the rake-compiler/rake-compiler-dock side.

flavorjones commented 10 months ago

@apolcyn Thanks for starting this conversation. I'll explore some options and write them up here for feedback from you and other users.