rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

Setting `--compilation_mode=opt` results in a binary with debug info + symbol table not being stripped

Open Strum355 opened this issue 1 year ago • 1 comments

What version of rules_go are you using?

0.46.0

What version of gazelle are you using?

0.35.0

What version of Bazel are you using?

7.1.0

Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

x86_64 linux (also tested on macOS)

Any other potentially useful information about your toolchain?

https://github.com/uber/hermetic_cc_toolchain on linux, presumably host toolchain on maOS

What did you do?

bazel build --compilation_mode={fastbuild,dbg,opt} //some/go_binary:target

What did you expect to see?

Setting --compilation_mode=opt results in a stripped binary without debug info. The current behaviour may be WIA, in which case this issue can probably be closed.

See Bazel slack thread for some discussion https://bazelbuild.slack.com/archives/CDBP88Z0D/p1712748379078069

What did you see instead?

batcheshelper.dbg:  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, Go BuildID=redacted, with debug_info, not stripped
batcheshelper.fast: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, Go BuildID=redacted, stripped
batcheshelper.opt:  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=redacted, with debug_info, not stripped

Strum355 avatar Apr 10 '24 13:04 Strum355

The current behavior was actually last modified by me in #3527

I looked into Bazel's documented behavior for --strip. It says:

 --strip (always|never|sometimes)

This option determines whether Bazel will strip debugging information from all binaries and shared libraries, by invoking the linker with the -Wl,--strip-debug option.

--strip=always means always strip debugging information.
--strip=never means never strip debugging information.
The default value of --strip=sometimes means strip if the --compilation_mode is fastbuild.

https://bazel.build/docs/user-manual#strip

To the best of my understanding, this works as intended.

malt3 avatar May 16 '24 13:05 malt3

I think you're right, Im not sure why I thought otherwise anymore :woozy_face:

Strum355 avatar Jun 04 '24 12:06 Strum355