1 # Regression test for https://go.dev/issue/48319:
2 # cgo builds should not include debug information from a stale GOROOT_FINAL.
3
4 [short] skip
5 [!cgo] skip
6
7 # This test has problems when run on the LUCI darwin longtest builder,
8 # which uses a more contemporary Xcode version that is unfriendly to
9 # reproducible builds (see issue #64947 for the gory details). Note
10 # that individual developers running "go test cmd/go" on Darwin may
11 # still run into failures depending on their Xcode version.
12 [GOOS:darwin] [go-builder] skip
13
14 # This test is sensitive to cache invalidation,
15 # so use a separate build cache that we can control.
16 env GOCACHE=$WORK/gocache
17 mkdir $GOCACHE
18
19 # Build a binary using a specific value of GOROOT_FINAL.
20 env GOROOT_FINAL=$WORK${/}goroot1
21 go build -o main.exe
22 mv main.exe main1.exe
23
24 # Now clean the cache and build using a different GOROOT_FINAL.
25 # The resulting binaries should differ in their debug metadata.
26 go clean -cache
27 env GOROOT_FINAL=$WORK${/}goroot2
28 go build -o main.exe
29 mv main.exe main2.exe
30 ! cmp -q main2.exe main1.exe
31
32 # Set GOROOT_FINAL back to the first value.
33 # If the build is properly reproducible, the two binaries should match.
34 env GOROOT_FINAL=$WORK${/}goroot1
35 go build -o main.exe
36 cmp -q main.exe main1.exe
37
38 -- go.mod --
39 module main
40
41 go 1.18
42 -- main.go --
43 package main
44
45 import "C"
46
47 import "runtime"
48
49 var _ C.int
50
51 func main() {
52 println(runtime.GOROOT())
53 }
54
View as plain text