Skip to content

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

Closed
@mvdan

Description

@mvdan

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

Activity

added
NeedsFixThe path to resolution is known, but the work has not been done.
on Dec 4, 2018
gopherbot

gopherbot commented on Dec 4, 2018

@gopherbot
Contributor

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

bcmills

bcmills commented on Dec 4, 2018

@bcmills
Contributor

#26849 is one possible mechanism.

added this to the Go1.13 milestone on Dec 15, 2018
mvdan

mvdan commented on Dec 15, 2018

@mvdan
MemberAuthor

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

bcmills commented on Jan 17, 2019

@bcmills
Contributor

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

locked and limited conversation to collaborators on Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mvdan@bcmills@gopherbot

        Issue actions

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