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
9 env GOROOT=$WORK/goroot1
10 symlink $GOROOT -> $TESTGO_GOROOT
11
12 # Set up fresh GOCACHE
13 env GOCACHE=$WORK/gocache1
14 mkdir $GOCACHE
15
16 # Build a simple binary
17 go build -o binary1 -trimpath -x main.go
18
19 # Now repeat the same process with the compiler at a different local path
20 env GOROOT=$WORK/goroot2
21 symlink $GOROOT -> $TESTGO_GOROOT
22
23 env GOCACHE=$WORK/gocache2
24 mkdir $GOCACHE
25
26 go build -o binary2 -trimpath -x main.go
27
28 # Check that the binaries match exactly
29 go tool buildid binary1
30 cp stdout buildid1
31 go tool buildid binary2
32 cp stdout buildid2
33 cmp buildid1 buildid2
34
35
36 -- main.go --
37 package main
38 func main() {}
39
View as plain text