-
Notifications
You must be signed in to change notification settings - Fork 253
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
build: Enhance binary #416
Conversation
Signed-off-by: Christian Menges <[email protected]>
fc9fdeb
to
466e342
Compare
Signed-off-by: Christian Menges <[email protected]>
466e342
to
89ecc11
Compare
Here the test run failed, I see that the reason for the error report is timeout, should you adjust it? |
@Garfield96 Thank you! I like this PR |
I was able to reproduce the error locally. Unfortunately,
Postponing PIE until the go compiler supports static builds, is probably the best choice. The current state of the implementation is tracked here: golang/go#26492 |
@Garfield96 Which base build image do you think might have the runtime linker? Can we use |
Signed-off-by: Christian Menges <[email protected]>
@benjaminhuo Sorry for the late reply. We would need to replace https://github.com/fluent/fluent-operator/blob/master/cmd/fluent-manager/Dockerfile#L23 by e.g. Alpine. However, the watcher images are fine, since they use base images which include a runtime linker. I removed |
Got it. Thank you! |
@Garfield96 Revert this PR for now because some users reported #429 and @wenchajun found it's related to this PR. |
What this PR does / why we need it:
This PR changes multiple go compiler options:
-i
: This flag is deprecated and no longer required.-buildmode=pie
: This option increases the security by compiling the binary as a position-independent executable to enable address space layout randomization (ASLR). The downsides of enabling this option are an increasing binary size as well as a small performance degradation (usually 5-10 %). However, ASLR is commonly used (e.g. many distributions use it for package builds by default), and this application doesn't require very high performance.-trimpath
: This option reduces the binary size by using relative paths instead of absolute paths. Since the paths no longer depend on the build environment, the build is more reproducible, and stack traces are easier to read.Documentation for these options can be found here: https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies
Which issue(s) this PR fixes:
Fixes #
Does this PR introduced a user-facing change?
Additional documentation, usage docs, etc.: