-
Notifications
You must be signed in to change notification settings - Fork 408
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
Consider not adding -trimpath
flag by default when disabling compiler optimizations
#500
Comments
(By the way, I'd be happy to implement it.) |
Not making a judgement either way for now, but this issue explains why we added |
Thanks for the context, I ❤️ reproducible builds too. But when interactively debugging it's not as important IMHO. Or is |
I don't know enough about Skaffold, but does it have some "run this in debug mode" option that could disable If Skaffold's use case is iterative (local?) development and not releasing to prod, I care a lot less about the reproducibility of Skaffold's |
Thanks for the reply, I'm definitely happy to discuss other solutions! To your questions:
Yes, that's exactly the use case. Users run
(warning: long answer!) The integration between Skaffold and
The integration achieves the second point by programmatically setting the The challenge right now is that the only way to prevent Users who don't specify a build config in either As you suggest, we could always pass a build config to An alternative solution is to add a Thanks for reading all this! I hope it makes sense, and I'd be happy to clarify. |
If We could also maybe introduce a |
Do you mean rename the existing
If we go with two flags, We're using distroless as the default base image, and this flag doesn't change the base image to a |
+1 to separate flags, and maybe considering deprecating/hiding
I think we should just solve this with clear documentation about what Thanks for driving this and for being so through and considerate of all the options and user expectations. 👍 |
Skaffold doesn't use these flags, right? I'd be ok with exposing the I don't know if we want to drop |
That's right, Skaffold would just use So how about this:
As a result of this, if a user specifies This way we don't change the behavior of Does this sound ok? Thanks both of you for your feedback and your help in shaping this. 👍 |
SGTM |
Enables programmatic control of whether `ko` adds the `-trimpath` flag to `go build`. The `-trimpath` flag removes file system paths from the resulting binary. `ko` adds `-trimpath` by default as it aids in achieving reproducible builds. However, removing file system paths makes interactive debugging more challenging, in particular in mapping source file locations in the IDE to debug information in the binary. If you set `Trimpath` to `false` to enable interactive debugging, you probably also want to set `DisableOptimizations` to `true` to disable compiler optimizations and inlining. Reference for `-trimpath`: https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies Resolves: #500 Related: #71, #78, GoogleContainerTools/skaffold#6843
Enables programmatic control of whether `ko` adds the `-trimpath` flag to `go build`. The `-trimpath` flag removes file system paths from the resulting binary. `ko` adds `-trimpath` by default as it aids in achieving reproducible builds. However, removing file system paths makes interactive debugging more challenging, in particular in mapping source file locations in the IDE to debug information in the binary. If you set `Trimpath` to `false` to enable interactive debugging, you probably also want to set `DisableOptimizations` to `true` to disable compiler optimizations and inlining. Reference for `-trimpath`: https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies Resolves: #500 Related: #71, #78, GoogleContainerTools/skaffold#6843
ko
adds the-trimpath
flag if no build config is specified: /~https://github.com/google/ko/blob/5617d1ebf8560df778aa884fa328fe05f62bdb5e/pkg/build/gobuild.go#L562This removes information necessary for remote debugging, see: GoogleContainerTools/skaffold#6843 (comment)
Users who want to debug would typically also use the
--disable-optimizations
flag.Should we default to not add
-trimpath
ifdisableOptimizations
is true?In other words, change this conditional from
!ok
to!ok && !g.disableOptimizations
?A workaround is to ask users to specify a build config if they want to control whether the
-trimpath
flag is added.The text was updated successfully, but these errors were encountered: