Skip to content

Commit 2fba94d

Browse files
committed
builder: add support for Go 1.20
Not all features work yet, but allow it to compile with this Go version.
1 parent b678295 commit 2fba94d

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

.circleci/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ jobs:
105105
- test-linux:
106106
llvm: "14"
107107
resource_class: large
108+
test-llvm15-go120:
109+
docker:
110+
- image: golang:1.20-rc-buster
111+
steps:
112+
- test-linux:
113+
llvm: "15"
114+
resource_class: large
108115

109116
workflows:
110117
test-all:
111118
jobs:
112119
# This tests our lowest supported versions of Go and LLVM, to make sure at
113120
# least the smoke tests still pass.
114121
- test-llvm14-go118
122+
- test-llvm15-go120

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ TEST_PACKAGES_FAST = \
286286
container/list \
287287
container/ring \
288288
crypto/des \
289-
crypto/internal/subtle \
290289
crypto/md5 \
291290
crypto/rc4 \
292291
crypto/sha1 \

builder/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) {
3333
if err != nil {
3434
return nil, fmt.Errorf("could not read version from GOROOT (%v): %v", goroot, err)
3535
}
36-
if major != 1 || minor < 18 || minor > 19 {
37-
return nil, fmt.Errorf("requires go version 1.18 through 1.19, got go%d.%d", major, minor)
36+
if major != 1 || minor < 18 || minor > 20 {
37+
return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor)
3838
}
3939

4040
clangHeaderPath := getClangHeaderPath(goenv.Get("TINYGOROOT"))

cgo/cgo_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"go/types"
1212
"os"
1313
"path/filepath"
14+
"regexp"
1415
"runtime"
1516
"strings"
1617
"testing"
@@ -21,9 +22,15 @@ var flagUpdate = flag.Bool("update", false, "Update images based on test output.
2122

2223
// normalizeResult normalizes Go source code that comes out of tests across
2324
// platforms and Go versions.
24-
func normalizeResult(result string) string {
25-
actual := strings.ReplaceAll(result, "\r\n", "\n")
26-
return actual
25+
func normalizeResult(t *testing.T, result string) string {
26+
result = strings.ReplaceAll(result, "\r\n", "\n")
27+
28+
// This changed to 'undefined:', in Go 1.20.
29+
result = strings.ReplaceAll(result, ": undeclared name:", ": undefined:")
30+
// Go 1.20 added a bit more detail
31+
result = regexp.MustCompile(`(unknown field z in struct literal).*`).ReplaceAllString(result, "$1")
32+
33+
return result
2734
}
2835

2936
func TestCGo(t *testing.T) {
@@ -88,7 +95,7 @@ func TestCGo(t *testing.T) {
8895
if err != nil {
8996
t.Errorf("could not write out CGo AST: %v", err)
9097
}
91-
actual := normalizeResult(buf.String())
98+
actual := normalizeResult(t, buf.String())
9299

93100
// Read the file with the expected output, to compare against.
94101
outfile := filepath.Join("testdata", name+".out.go")

cgo/testdata/errors.out.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// Type checking errors after CGo processing:
99
// testdata/errors.go:102: cannot use 2 << 10 (untyped int constant 2048) as C.char value in variable declaration (overflows)
1010
// testdata/errors.go:105: unknown field z in struct literal
11-
// testdata/errors.go:108: undeclared name: C.SOME_CONST_1
11+
// testdata/errors.go:108: undefined: C.SOME_CONST_1
1212
// testdata/errors.go:110: cannot use C.SOME_CONST_3 (untyped int constant 1234) as byte value in variable declaration (overflows)
13-
// testdata/errors.go:112: undeclared name: C.SOME_CONST_4
13+
// testdata/errors.go:112: undefined: C.SOME_CONST_4
1414

1515
package main
1616

testdata/stdlib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
syscall.Getppid()
2525

2626
// package math/rand
27-
fmt.Println("pseudorandom number:", rand.Int31())
27+
fmt.Println("pseudorandom number:", rand.New(rand.NewSource(1)).Int31())
2828

2929
// package strings
3030
fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd'))

0 commit comments

Comments
 (0)