aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2022-12-06 10:22:09 -0500
committerThan McIntosh <thanm@google.com>2022-12-06 15:55:39 +0000
commitfe67a21625ee811897077b32d4e75566ef74c6c4 (patch)
tree3c093243f01564384984b2e419951d17d2000864
parent1eb0465fa596a2d6e9c1a632499989544f0d7e68 (diff)
downloadgo-fe67a21625ee811897077b32d4e75566ef74c6c4.tar.gz
go-fe67a21625ee811897077b32d4e75566ef74c6c4.zip
cmd/link: pass -Wl,--no-insert-timestamp to external linker on windows
Pass -Wl,--no-insert-timestamp to the external linker on windows, so as to suppress generation of the PE file header data/time stamp. This is in order to make it possible to get reproducible CGO builds on windows (note that we already zero the timestamp field in question for internal linkage). Updates #35006. Change-Id: I3d69cf1fd32e099bd9bb4b0431a4c5f43e4b08f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/455535 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--src/cmd/link/internal/ld/lib.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index d225a8a163..c0730179db 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1619,6 +1619,17 @@ func (ctxt *Link) hostlink() {
argv = append(argv, unusedArguments)
}
+ if ctxt.IsWindows() {
+ // Suppress generation of the PE file header timestamp,
+ // so as to avoid spurious build ID differences between
+ // linked binaries that are otherwise identical other than
+ // the date/time they were linked.
+ const noTimeStamp = "-Wl,--no-insert-timestamp"
+ if linkerFlagSupported(ctxt.Arch, argv[0], altLinker, noTimeStamp) {
+ argv = append(argv, noTimeStamp)
+ }
+ }
+
const compressDWARF = "-Wl,--compress-debug-sections=zlib"
if ctxt.compressDWARF && linkerFlagSupported(ctxt.Arch, argv[0], altLinker, compressDWARF) {
argv = append(argv, compressDWARF)