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