-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cmd] Add new make targets with ldflags to build lite version binaries #34698
[cmd] Add new make targets with ldflags to build lite version binaries #34698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Frapschen, I'm curious how this impacts end users, if you're able to provide more information.
- Does this change impact debugging with Delve?
- Is there any impact from this change on pprof?
- Are stacks logged by the
zap.Logger
or during a panic/crash impacted?
1(2). Sure, pprof and Delve can't work if we add |
We discussed this PR in the Collector sig meeting today, and the general consensus was that we should keep debugging symbols to make sure the pprof extension works properly by default. Users can build their own collector binaries without them if they'd prefer that. If you want, you could even add new |
My opinion is that the binaries distributed by the project should include the debugging symbols. This does not block users from building their own binaries with the debug symbols excluded. As a side note, this change does not modify the binaries published by the project at https://github.com/open-telemetry/opentelemetry-collector-releases/releases/. It only modifies the binaries that users build locally with |
-w -s
ldflags to build lite version binaries
-w -s
ldflags to build lite version binaries
@crobert-1 as you suggest, I keep the Collector's default build behavior and add new target to build a lite version of binaries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a changelog entry for this, as it may be misleading to users. It may be worthwhile to add to a README somewhere, if there's anywhere that makes sense.
a143d50
to
2f33d34
Compare
2f33d34
to
b52a403
Compare
@crobert-1 PTAL thanks |
Co-authored-by: Curtis Robert <[email protected]>
otelcontribcollite: | ||
cd ./cmd/otelcontribcol && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/otelcontribcol_$(GOOS)_$(GOARCH)$(EXTENSION) \ | ||
-tags $(GO_BUILD_TAGS) -ldflags $(GO_BUILD_LDFLAGS) . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of repetition between otelcontribcol
and otelcontribcollight
targets. Perhaps it could be improved into something like:
otelcontribcollite: | |
cd ./cmd/otelcontribcol && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/otelcontribcol_$(GOOS)_$(GOARCH)$(EXTENSION) \ | |
-tags $(GO_BUILD_TAGS) -ldflags $(GO_BUILD_LDFLAGS) . | |
otelcontribcollite: | |
GO_BUILD_LDFLAGS="-s -w" $(MAKE) otelcontribcol |
open-telemetry#34698) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> We can use ldflags `-w` and `-s` to downscale the binary size. The official docs explanation of the two options: ``` -s Omit the symbol table and debug information. -w Omit the DWARF symbol table. ``` After building with the above options, the binary size scales down 28%: ``` -rwxr-xr-x 1 fraps staff 249M Aug 15 14:23 otelcontribcol_darwin_arm64 -rwxr-xr-x 1 fraps staff 347M Aug 8 18:20 otelcontribcol_darwin_arm64-old ``` I think it's worth adding them. The only degradation is we can't use GDB to debug however it rare use case. **Link to tracking Issue:** <Issue number if applicable> **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.> --------- Co-authored-by: Curtis Robert <[email protected]>
Description:
We can use ldflags
-w
and-s
to downscale the binary size. The official docs explanation of the two options:After building with the above options, the binary size scales down 28%:
I think it's worth adding them. The only degradation is we can't use GDB to debug however it rare use case.
Link to tracking Issue:
Testing:
Documentation: