...
1# Checks that an identical binary is built with -trimpath from the same
2# source files, with GOROOT in two different locations.
3# Verifies golang.org/issue/38989
4
5[short] skip
6[!symlink] skip
7
8# Symlink the compiler to a local path
9env TEST_GOROOT=$GOROOT
10env GOROOT=$WORK/goroot1
11symlink $GOROOT -> $TEST_GOROOT
12
13# Set up fresh GOCACHE
14env GOCACHE=$WORK/gocache1
15mkdir $GOCACHE
16
17# Build a simple binary
18go build -o binary1 -trimpath -x main.go
19
20# Now repeat the same process with the compiler at a different local path
21env GOROOT=$WORK/goroot2
22symlink $GOROOT -> $TEST_GOROOT
23
24env GOCACHE=$WORK/gocache2
25mkdir $GOCACHE
26
27go build -o binary2 -trimpath -x main.go
28
29# Check that the binaries match exactly
30go tool buildid binary1
31cp stdout buildid1
32go tool buildid binary2
33cp stdout buildid2
34cmp buildid1 buildid2
35
36
37-- main.go --
38package main
39func main() {}
View as plain text