Skip to content
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/go: add a way to support GOFLAGS=-ldflags='-w -s' #29096

Closed
mvdan opened this issue Dec 4, 2018 · 4 comments
Closed

cmd/go: add a way to support GOFLAGS=-ldflags='-w -s' #29096

mvdan opened this issue Dec 4, 2018 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Dec 4, 2018

The previous documentation example mentioned GOFLAGS='-ldflags=-w -ldflags=-s', which does something completely different. The second per-package flag overrides the first, so the linker ends up being called with just -s and not -w -s.

There should be a way to do go build -ldflags='-w -s' via GOFLAGS. This can either be done by tweaking GOFLAGS, or by tweaking per-package flags - I personally don't mind, as long as there's a way to achieve it.

/cc @bcmills @rsc

@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 4, 2018
@gopherbot
Copy link

Change https://golang.org/cl/152479 mentions this issue: cmd/go: revert multi-flag GOFLAGS doc example

@bcmills
Copy link
Contributor

bcmills commented Dec 4, 2018

#26849 is one possible mechanism.

gopherbot pushed a commit that referenced this issue Dec 4, 2018
This partially reverts https://golang.org/cl/135035.

Reason for revert: multiple -ldflags=-foo flags simply override each
other, since that's the logic for per-package flags. The suggested
'GOFLAGS=-ldflags=-s -ldflags=-w' has never worked for 'go build', and
even breaks 'go test' and 'go vet'.

There should be a way to specify -ldflags='-w -s' via GOFLAGS, which is
being tracked in #29096. For now, just remove the incorrect suggestion.

Fixes #29053.

Change-Id: I9203056f7e5191e894bcd16595a92df2fb704ea7
Reviewed-on: https://go-review.googlesource.com/c/152479
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
@mvdan mvdan added this to the Go1.13 milestone Dec 15, 2018
@mvdan
Copy link
Member Author

mvdan commented Dec 15, 2018

Go 1.11 supposedly shipped with this feature, so I'm milestoning this for 1.13 to "get that back". Within quotes because it never actually worked :)

@bcmills
Copy link
Contributor

bcmills commented Jan 17, 2019

The underlying use-case is the same as #26849. Consolidating into that issue.

@bcmills bcmills closed this as completed Jan 17, 2019
@golang golang locked and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants