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