Re: go: shrink binaries

Greg Troxel <[email protected]> Mon, 25 May 2026 19:07:04 -0400
Newsgroups gmane.os.netbsd.devel.packages
Message-ID <[email protected]>
Jörg Sonnenberger <[email protected]> writes:

> On 5/25/26 9:00 AM, Adam wrote:
>> Hello,
>> To all go modules, can we add:
>> -ldflags='-s -w' to omit symbol table (-s) and strip debug
>> information (-w), and also
>> -trimpath to avoid baking full GOPATH/module paths into binaries (without it, there is a work directory reference, so CHECK_WRKREF_SKIP can possible be removed in lang/go/go-module.mk)
>
> I wouldn't want to strip symbol tables by default, that can make any
> debugging a lot more painful for little gain. Debug information is a
> different question.

I had the impression we had variables to control this and would think
that go binaries should have the exact same treatment as C binaries.

  $ nm -g /usr/pkg/bin/gm4
  nm: /usr/pkg/bin/gm4: no symbols

If you want to argue for changing the default and/or separating
variables for symbols and debug, that's ok.  But I don't see why go
should be different.