Skip to content

Commit 3abc1b0

Browse files
committed
testdata/script: include regression test for LTO
Signed-off-by: Morten Linderud <[email protected]>
1 parent 70ebb76 commit 3abc1b0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Regression test for https://go.dev/issue/413974:
2+
# cgo build should reproduce binaries with LTO enable
3+
4+
[!cgo] skip
5+
6+
env GOFLAGS=-ldflags=-linkmode=external
7+
env CGO_CFLAGS=-flto
8+
9+
go build -o main.exe
10+
mv main.exe main1.exe
11+
12+
env GOCACHE=$WORK${/}gocache
13+
mkdir $GOCACHE
14+
go build -o main.exe
15+
mv main.exe main2.exe
16+
17+
cmp -q main2.exe main1.exe
18+
19+
-- go.mod --
20+
module main
21+
22+
go 1.18
23+
-- main.go --
24+
package main
25+
26+
import "C"
27+
28+
var _ C.int
29+
30+
func main() {
31+
println("Hello World")
32+
}

0 commit comments

Comments
 (0)