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 [windows] skip # The Go Windows builders have an extremely out-of-date gcc that does not support reproducible builds; see https://go.dev/issue/50824.
7
8 # This test is sensitive to cache invalidation,
9 # so use a separate build cache that we can control.
10 env GOCACHE=$WORK/gocache
11 mkdir $GOCACHE
12
13 # Build a binary using a specific value of GOROOT_FINAL.
14 env GOROOT_FINAL=$WORK${/}goroot1
15 go build -o main.exe
16 mv main.exe main1.exe
17
18 # Now clean the cache and build using a different GOROOT_FINAL.
19 # The resulting binaries should differ in their debug metadata.
20 go clean -cache
21 env GOROOT_FINAL=$WORK${/}goroot2
22 go build -o main.exe
23 mv main.exe main2.exe
24 ! cmp main2.exe main1.exe
25
26 # Set GOROOT_FINAL back to the first value.
27 # If the build is properly reproducible, the two binaries should match.
28 env GOROOT_FINAL=$WORK${/}goroot1
29 go build -o main.exe
30 cmp -q main.exe main1.exe
31
32 -- go.mod --
33 module main
34
35 go 1.18
36 -- main.go --
37 package main
38
39 import "C"
40
41 import "runtime"
42
43 var _ C.int
44
45 func main() {
46 println(runtime.GOROOT())
47 }
48
View as plain text