-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
buildGoModule
: Binaries are not stripped by default. Proposal to add -s -w
ldflags by default
#177698
Comments
|
Since #179622 is merged now, @zowoq any chance you can look into this again? I'm willing to help but I currently don't have enough horse power for mass rebuilds. /cc @SuperSandro2000 |
I'll follow up on this in the next couple of weeks. |
IMO we should enable this by default and disable it for the few packages that do not support it. |
Here is the PR: #182743 I still need to recheck what other distros are doing in case there are reasons not to do this and check for breakage in packages. |
Alpine have recently removed |
Just tested this -- our strip produces the same Did our strip at one point not work fully, or is that speculation? Did we all (as in, Alpine and us) just add the flags for completeness, when they were actually extraneous since we strip at the end? Or were they needed at some point to fully strip debug info? |
Assuming that this was on linux, it isn't the same on x86_64-darwin.
IIRC these flags did make a difference on linux at one point. Not sure why these flags were sometimes problematic in the past if the stdenv strip will produce the same result anyway. |
I (naively) only tested Linux, correct.
Do you remember how they were problematic? |
Removing these flags still seems to cause bigger binaries on linux? |
If I'm correctly understanding the point you're trying to make: yes, that's to be expected, as we only strip debug symbols by default (as opposed to stripping all symbols). If you manually run We can set |
nixpkgs/pkgs/stdenv/darwin/default.nix Line 65 in 0fdc722
Doesn't seem like we have a way of doing this consistently with strip. Guess that bring us back to where we started, setting |
fwiw, that's what we do in OpenBSD land: https://github.com/openbsd/ports/blob/master/lang/go/go.port.mk#L111 Maybe we can create an example |
I was wondering, is there a specific reason for
-s
and-w
ldflags not being in thebuildGoModule
'sbuildFlagsArray=()
and shouldn't we enable them by default or, for instance, when theldflags
attribute is not explicitly defined by package's derivation?As outlined in documentation for
cmd/link
, flag description is as follows:Right now, if these flags are not included, binaries are left unstripped and consequently bigger in size. Basically, to include these flags would mean to mimic what
strip
command does instdenv
. Or we could just addstrip
itself after the build if it's not already somehow inherited fromstdenv
.CC @NixOS/golang
The text was updated successfully, but these errors were encountered: