You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes.
What did you do?
I set GOFLAGS="-ldflags='-s -w'" to automatically exclude the symbol table on all binaries we compile.
What did you expect to see?
I expected it to work the same as if I passed -ldflags='-s -w'.
What did you see instead?
go: parsing $GOFLAGS: unknown flag -w'
This is because the compiler naively just splits GOFLAGS on spaces without considering quotes. The docs support this unfortunate behavior.
A space-separated list of -flag=value settings to apply to go commands by default, when the given flag is known by the current command. Each entry must be a standalone flag. Because the entries are space-separated, flag values must not contain spaces. Flags listed on the command line are applied after this list and therefore override it.
There is no workaround for this, other than to not use GOFLAGS for this purpose. Passing GOFLAGS="-ldflags=-s -ldflags=-w" as was previously suggested by the documention does not work, becuase only the last flag will be applied, as per the documentation for -ldflags.
This issue was previously mentioned in #29053 but was not truly fixed.
Either the GOFLAGS parsing logic should be amended to account for quotes instead of just splitting on spaces, or another env var (perhpas GO_LDFLAGS to align with what make.bash offers) should be added.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
I set
GOFLAGS="-ldflags='-s -w'"
to automatically exclude the symbol table on all binaries we compile.What did you expect to see?
I expected it to work the same as if I passed
-ldflags='-s -w'
.What did you see instead?
This is because the compiler naively just splits
GOFLAGS
on spaces without considering quotes. The docs support this unfortunate behavior.There is no workaround for this, other than to not use
GOFLAGS
for this purpose. PassingGOFLAGS="-ldflags=-s -ldflags=-w"
as was previously suggested by the documention does not work, becuase only the last flag will be applied, as per the documentation for-ldflags
.This issue was previously mentioned in #29053 but was not truly fixed.
Either the
GOFLAGS
parsing logic should be amended to account for quotes instead of just splitting on spaces, or another env var (perhpasGO_LDFLAGS
to align with what make.bash offers) should be added.The text was updated successfully, but these errors were encountered: