-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: use the correct linker config in the buildID hash
The linker config is hashed into the buildID; however, the GOROOT_FINAL environment variable that is actually used when -trimpath is specified was not reflected in that hash. This change fixes that. Fixes #38989 Change-Id: I418a21a9f6293ca63c101d22b501dfdba8e91ac6 GitHub-Last-Rev: 4cf8292 GitHub-Pull-Request: #40296 Reviewed-on: https://go-review.googlesource.com/c/go/+/243557 Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Trust: Jay Conrod <jayconrod@google.com> Trust: Bryan C. Mills <bcmills@google.com>
- Loading branch information
Showing
3 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Checks that an identical binary is built with -trimpath from the same | ||
# source files, with GOROOT in two different locations. | ||
# Verifies golang.org/issue/38989 | ||
|
||
[short] skip | ||
[!symlink] skip | ||
|
||
# Symlink the compiler to a local path | ||
env GOROOT=$WORK/goroot1 | ||
symlink $GOROOT -> $TESTGO_GOROOT | ||
|
||
# Set up fresh GOCACHE | ||
env GOCACHE=$WORK/gocache1 | ||
mkdir $GOCACHE | ||
|
||
# Build a simple binary | ||
go build -o binary1 -trimpath -x main.go | ||
|
||
# Now repeat the same process with the compiler at a different local path | ||
env GOROOT=$WORK/goroot2 | ||
symlink $GOROOT -> $TESTGO_GOROOT | ||
|
||
env GOCACHE=$WORK/gocache2 | ||
mkdir $GOCACHE | ||
|
||
go build -o binary2 -trimpath -x main.go | ||
|
||
# Check that the binaries match exactly | ||
go tool buildid binary1 | ||
cp stdout buildid1 | ||
go tool buildid binary2 | ||
cp stdout buildid2 | ||
cmp buildid1 buildid2 | ||
|
||
|
||
-- main.go -- | ||
package main | ||
func main() {} |