Skip to content

Commit 1f96da7

Browse files
committed
all: Go 1.21 support
1 parent 3871b83 commit 1f96da7

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

builder/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ 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 > 20 {
36+
if major != 1 || minor < 18 || minor > 21 {
3737
// Note: when this gets updated, also update the Go compatibility matrix:
3838
// https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md
3939
return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor)

src/internal/bytealg/bytealg.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,13 @@ func IndexRabinKarp(s, substr string) int {
251251
}
252252
return -1
253253
}
254+
255+
// MakeNoZero makes a slice of length and capacity n without zeroing the bytes.
256+
// It is the caller's responsibility to ensure uninitialized bytes
257+
// do not leak to the end user.
258+
func MakeNoZero(n int) []byte {
259+
// Note: this does zero the buffer even though that's not necessary.
260+
// For performance reasons we might want to change this (similar to the
261+
// malloc function implemented in the runtime).
262+
return make([]byte, n)
263+
}

src/runtime/baremetal.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func growHeap() bool {
3838

3939
//export malloc
4040
func libc_malloc(size uintptr) unsafe.Pointer {
41+
// Note: this zeroes the returned buffer which is not necessary.
42+
// The same goes for bytealg.MakeNoZero.
4143
return alloc(size, nil)
4244
}
4345

src/runtime/runtime.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,8 @@ func godebug_setUpdate(update func(string, string)) {
100100
// variable changes (for example, via os.Setenv).
101101
godebugUpdate = update
102102
}
103+
104+
//go:linkname godebug_setNewIncNonDefault internal/godebug.setNewIncNonDefault
105+
func godebug_setNewIncNonDefault(newIncNonDefault func(string) func()) {
106+
// Dummy function necessary in Go 1.21.
107+
}

src/runtime/symtab.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ type Frames struct {
55
}
66

77
type Frame struct {
8+
PC uintptr
9+
10+
Func *Func
11+
812
Function string
913

1014
File string
1115
Line int
12-
PC uintptr
1316
}
1417

1518
func CallersFrames(callers []uintptr) *Frames {

0 commit comments

Comments
 (0)