rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

feat: Strip debug info from opt builds

Open matte1 opened this issue 1 year ago • 1 comments

Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds.

https://github.com/rust-lang/cargo/issues/4122#issuecomment-1868318860

matte1 avatar Feb 22 '24 23:02 matte1

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Feb 22 '24 23:02 google-cla[bot]

Looks like this change needs a rebase.

UebelAndre avatar Mar 26 '24 18:03 UebelAndre

@UebelAndre can you point me in the right direction for the CI error I'm getting?

matte1 avatar Mar 26 '24 19:03 matte1

Looks like a CI infra issue. @meteorcloudy @scentini

I see this on other PRs

UebelAndre avatar Mar 26 '24 20:03 UebelAndre

Sorry about the breakage, we fixed the CI and I re-triggered your presubmit.

meteorcloudy avatar Mar 27 '24 10:03 meteorcloudy

@UebelAndre what did you have in mind for checking that it transitions correctly?

I could do something a little hacky where I compile for copt and then use output of that in a test where I check for debug symbols using file or something? But seems like there is probably a cleaner way to do this test

matte1 avatar Mar 27 '24 13:03 matte1

@UebelAndre what did you have in mind for checking that it transitions correctly?

I could do something a little hacky where I compile for copt and then use output of that in a test where I check for debug symbols using file or something? But seems like there is probably a cleaner way to do this test

https://github.com/bazelbuild/rules_rust/pull/2578 is what I was thinking (though this is for opt_level). Something like this but that covers strip_level.

UebelAndre avatar Mar 27 '24 13:03 UebelAndre

@UebelAndre I added a new strip_level test tho it might be cleaner to just include that in the opt_level test. Could go either way here.

It looks like the windows builds are broken. I don't have a windows machine and have little insight here on how it wants to handle the debug symbols which seem to be in a separate file. @UebelAndre @scentini any thoughts here? I could just disable this feature for windows builds but that seems sad.

matte1 avatar Mar 29 '24 18:03 matte1

Feel free to ping me when this is ready for review!

UebelAndre avatar Apr 02 '24 17:04 UebelAndre

@UebelAndre I think this could use a look now. I had to do some special handling for the pdb tests and I just patterned matched what we did for the strip_level tests.

matte1 avatar Apr 02 '24 17:04 matte1