]> Cypherpunks repositories - gostls13.git/commit
cmd/go: omit build metadata that may contain system paths when -trimpath is set
authorBryan C. Mills <bcmills@google.com>
Fri, 27 May 2022 19:54:44 +0000 (15:54 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 28 Jun 2022 16:04:54 +0000 (16:04 +0000)
commita6e5be0d30770e8bd1ba1e4bac2089218df121d9
tree789c2563cd7753afa3e8efa4c2fae371f734c9ed
parentd3ffff2790059226ae3aa90856d687e138701b5c
cmd/go: omit build metadata that may contain system paths when -trimpath is set

CGO flag variables often include system paths for header files and
compiled libraries. The point of -trimpath is to avoid dependending on
system paths, so stamping these variables is counterproductive.

Moreover, the point of stamping build information is to improve
reproducibility. Since we don't also stamp the versions of C
compilers, headers, and libraries used in a cgo build, only the most
trivial cgo programs can be faithfully reproduced from the stamped
information.

Likewise, the -ldflags flag may include system-specific paths,
particularly if external linking is in use. For now, we omit -ldflags
entirely; however, in the future we may instead want to parse and
redact the individual flags.

Fixes #52372.

Change-Id: I73318a01cce4371d66955b3261fc7ee58d4b33dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/409174
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/load/pkg.go
src/cmd/go/testdata/script/version_build_settings.txt