On Wed, May 27, 2020 at 10:08 AM X Xiao <
laos...@gmail.com> wrote:
>
> what's the difference between `go build -ldflags="-s -w"` and `go build` plus `strip myBinary`? it seems their result is different, sometimes running `strip` gives me smaller size, then why bother with ldflags?
I just tried a simple hello, world test and running strip produced a
larger binary (on amd64 GNU/Linux). I think the results are going to
depend on the exact section sizes and alignments. The strip program
is of course a general tool, that knows nothing about Go, that
produces a new copy of the executable.
That said, broadly speaking there shouldn't be any real difference in
the final result. You should use whichever works better for you.
Ian