]> Cypherpunks repositories - gostls13.git/commit
cmd/link: strip STAB (symbolic debugging) symbols on darwin
authorCherry Zhang <cherryyz@google.com>
Wed, 26 Aug 2020 22:19:03 +0000 (18:19 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 8 Sep 2020 15:09:48 +0000 (15:09 +0000)
commite8f918535e6c9fc7b85a9dadc9e8035a2e1d1fa4
treee16045b3cb9c52364a1d10d2c235e5d06b4edc18
parent565ad134c994b7a831e1bea336fdc64f0aeefc85
cmd/link: strip STAB (symbolic debugging) symbols on darwin

On darwin, with external linking, the system linker produces STAB
(symbolic debugging) symbols in the binary's symbol table. These
include paths of the intermediate object files, like
<tmpdir>/go.o, which changes from run to run, making the build
non-reproducible.

Since we run dsymutil to produce debug info and combine them
back into the binary, we don't need those STAB symbols anymore.
Strip them after running dsymutil.

If DWARF is not enabled, we don't run dsymutil. We can pass
"-Wl,-S" to let the system linker not generate those symbols.

While here, also make it more consistent about DWARF combining.
Currently we only do DWARF combining on macOS/AMD64, when DWARF
is enabled. On ARM64, we run dsymutil, but then throw the result
away. This CL changes it to not run dsymutil (and strip) on
ARM64.

TODO: add a test. We don't do it here as it fails on some
(non-darwin) platforms.

Fixes #40979.

Change-Id: If770f7828cdb858857d6079e0585bf067f8f7a92
Reviewed-on: https://go-review.googlesource.com/c/go/+/250944
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/lib.go