{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/26492","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/26492/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/26492/comments","events_url":"https://api.github.com/repos/golang/go/issues/26492/events","html_url":"https://github.com/golang/go/issues/26492","id":342928270,"node_id":"MDU6SXNzdWUzNDI5MjgyNzA=","number":26492,"title":"proposal: cmd/go: build: add -static flag","user":{"login":"kolyshkin","id":4522509,"node_id":"MDQ6VXNlcjQ1MjI1MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/4522509?v=4","gravatar_id":"","url":"https://api.github.com/users/kolyshkin","html_url":"https://github.com/kolyshkin","followers_url":"https://api.github.com/users/kolyshkin/followers","following_url":"https://api.github.com/users/kolyshkin/following{/other_user}","gists_url":"https://api.github.com/users/kolyshkin/gists{/gist_id}","starred_url":"https://api.github.com/users/kolyshkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolyshkin/subscriptions","organizations_url":"https://api.github.com/users/kolyshkin/orgs","repos_url":"https://api.github.com/users/kolyshkin/repos","events_url":"https://api.github.com/users/kolyshkin/events{/privacy}","received_events_url":"https://api.github.com/users/kolyshkin/received_events","type":"User","site_admin":false},"labels":[{"id":373401956,"node_id":"MDU6TGFiZWwzNzM0MDE5NTY=","url":"https://api.github.com/repos/golang/go/labels/NeedsDecision","name":"NeedsDecision","color":"ededed","default":false},{"id":236419512,"node_id":"MDU6TGFiZWwyMzY0MTk1MTI=","url":"https://api.github.com/repos/golang/go/labels/Proposal","name":"Proposal","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/30","html_url":"https://github.com/golang/go/milestone/30","labels_url":"https://api.github.com/repos/golang/go/milestones/30/labels","id":1373555,"node_id":"MDk6TWlsZXN0b25lMTM3MzU1NQ==","number":30,"title":"Proposal","description":"Proposals that are pending (not yet accepted/rejected).\r\n","creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":213,"closed_issues":553,"state":"open","created_at":"2015-10-24T01:40:49Z","updated_at":"2018-07-23T20:08:48Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-07-19T23:58:53Z","updated_at":"2018-07-23T20:39:48Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This is a proposal to add `-static` flag to `go build`.\r\n\r\nProducing a static build with go already requires a non-trivial amount of flags passed to `go build`, which on Linux currently amounts to something like:\r\n\r\n`-ldflags '-extldflags \"-fno-PIC -static\"' -buildmode pie -tags 'osusergo netgo static_build'` [1]\r\n\r\n...and this magic string keeps growing.\r\n\r\nIt would be nice encapsulate this sacred knowledge internally, exposing it via a new `-static` flag for `go build` and friends?\r\n\r\nIn addition to the above benefit of hiding the complexity, `-static` can also bring us another few nice things, such as:\r\n* automatic `static_build` build tag third-party software can rely upon. Currently it seems like a de-facto standard, used a lot, but it has to be explicitly defined like in [1] above.\r\n* providing `--static` flag to `pkg-config` invocations (those initiated by `// #cgo pkg-config: lib` lines in the source code). It will solve another issue (linking against a proper set of libraries for both static and dynamic link cases) for which a somewhat verbose workaround is currently required (for example, see [ploop_link_static.go](https://github.com/kolyshkin/goploop/blob/master/ploop_link_static.go) and [ploop_link_dynamic.go](https://github.com/kolyshkin/goploop/blob/master/ploop_link_dynamic.go)).\r\n\r\n### See also\r\n* https://github.com/golang/go/issues/12058 (original proposal for adding conditional `--static` to `pkg-config`)\r\n* https://github.com/golang/go/issues/24787 (initial version of this very proposal)  "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/407193609","html_url":"https://github.com/golang/go/issues/26492#issuecomment-407193609","issue_url":"https://api.github.com/repos/golang/go/issues/26492","id":407193609,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNzE5MzYwOQ==","user":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"created_at":"2018-07-23T20:39:48Z","updated_at":"2018-07-23T20:39:48Z","author_association":"CONTRIBUTOR","body":"This seems OK but the tag should just be \"static\" not \"static_build\" (it's a build tag already). And we should make os/user and net do the right thing - whatever that is - instead of having to hard-code their tags too. \r\n\r\nNote that the assumption is that -static does not disable cgo; it just makes the cgo uses statically linked. FWIW, I don't know how well statically linked cgo works, but apparently well enough.\r\n\r\nIt sounds like maybe the os/user and net non-cgo restrictions only apply on Linux (more precisely, GNU/Linux, since this is a glibc restriction)."}}
{"actor":{"display_login":"rsc"}}