Skip to content

config: make strip a bool_flag#3526

Closed
malt3 wants to merge 1 commit intobazel-contrib:masterfrom
malt3:fix/strip-flag
Closed

config: make strip a bool_flag#3526
malt3 wants to merge 1 commit intobazel-contrib:masterfrom
malt3:fix/strip-flag

Conversation

@malt3
Copy link
Copy Markdown
Contributor

@malt3 malt3 commented Apr 11, 2023

What type of PR is this?

Uncomment one line below and remove others.

Bug fix

Feature
Documentation
Other

What does this PR do? Why is it needed?

Allows specifying the strip config setting via a flag. This allows configuration of the strip setting via a bazel command line flag and makes it easier to switch between stripped and non-stripped builds.

Which issues(s) does this PR fix?

Fixes #3325

Other notes for review

As far as I can tell, changing this setting to be a bool_flag just works. It does perform stripping as expected1. I couldn't find any reason as to why the strip setting is handled differently from the rest. If there was a reason, please state it and we can close this.

Edit: This is one possible resolution. See also #3527 for an alternative solution that respects the global bazel strip setting.

Footnotes

  1. running file on a resulting binary when using the flag shows ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, not stripped, while it shows ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, with debug_info, not stripped without the flag. This seems to be consistent with what the docs say about this flag (it is equivalent to -w on the go build options). I was expecting this to also set -s for the go build options which would change the last part of the output to say stripped, but this is a separate issue.

@fmeum
Copy link
Copy Markdown
Member

fmeum commented Apr 11, 2023

I do see one reason: Bazel's --strip flag should also control Go stripping and, compared to the Go-specific flag, ensures that stripping is consistent across languages.

Did you check whether this works? Do you have a use case which for stripping Go but not other languages?

@malt3
Copy link
Copy Markdown
Contributor Author

malt3 commented Apr 11, 2023

I do see one reason: Bazel's --strip flag should also control Go stripping [...].
Did you check whether this works? Do you have a use case which for stripping Go but not other languages?

I added this to my .bazelrc: build --strip=always and the file command still says with debug_info if I use rules_go from main. Is this maybe a bug or an incorrect use on my side? (EDIT: I'm using -c opt but this doesn't seem to make a difference)

@malt3
Copy link
Copy Markdown
Contributor Author

malt3 commented May 5, 2023

Superseded by #3527

@malt3 malt3 closed this May 5, 2023
@malt3 malt3 deleted the fix/strip-flag branch May 5, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrecognized build option errors when trying to use @io_bazel_rules_go//go/config:strip

2 participants