diff --git a/builder/config.go b/builder/config.go index f9fe715b76..66eea404e0 100644 --- a/builder/config.go +++ b/builder/config.go @@ -33,7 +33,7 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { if err != nil { return nil, fmt.Errorf("could not read version from GOROOT (%v): %v", goroot, err) } - if major != 1 || minor < 18 || minor > 20 { + if major != 1 || minor < 18 || minor > 21 { // Note: when this gets updated, also update the Go compatibility matrix: // https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor) diff --git a/src/internal/bytealg/bytealg.go b/src/internal/bytealg/bytealg.go index a6744c4144..72be9ac587 100644 --- a/src/internal/bytealg/bytealg.go +++ b/src/internal/bytealg/bytealg.go @@ -251,3 +251,13 @@ func IndexRabinKarp(s, substr string) int { } return -1 } + +// MakeNoZero makes a slice of length and capacity n without zeroing the bytes. +// It is the caller's responsibility to ensure uninitialized bytes +// do not leak to the end user. +func MakeNoZero(n int) []byte { + // Note: this does zero the buffer even though that's not necessary. + // For performance reasons we might want to change this (similar to the + // malloc function implemented in the runtime). + return make([]byte, n) +} diff --git a/src/runtime/baremetal.go b/src/runtime/baremetal.go index a51191bb95..173d0db25e 100644 --- a/src/runtime/baremetal.go +++ b/src/runtime/baremetal.go @@ -38,6 +38,8 @@ func growHeap() bool { //export malloc func libc_malloc(size uintptr) unsafe.Pointer { + // Note: this zeroes the returned buffer which is not necessary. + // The same goes for bytealg.MakeNoZero. return alloc(size, nil) } diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index ceb6a2240c..b8be787b54 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -100,3 +100,21 @@ func godebug_setUpdate(update func(string, string)) { // variable changes (for example, via os.Setenv). godebugUpdate = update } + +//go:linkname godebug_setNewIncNonDefault internal/godebug.setNewIncNonDefault +func godebug_setNewIncNonDefault(newIncNonDefault func(string) func()) { + // Dummy function necessary in Go 1.21. +} + +// Write to the given file descriptor. +// This is called from internal/godebug starting with Go 1.21, and only seems to +// be called with the stderr file descriptor. +func write(fd uintptr, p unsafe.Pointer, n int32) int32 { + if fd == 2 { // stderr + // Convert to a string, because we know that p won't change during the + // call to printstring. + printstring(unsafe.String((*byte)(p), n)) + return n + } + return 0 +} diff --git a/src/runtime/runtime_nintendoswitch.go b/src/runtime/runtime_nintendoswitch.go index f2606023ff..bcfa5151d0 100644 --- a/src/runtime/runtime_nintendoswitch.go +++ b/src/runtime/runtime_nintendoswitch.go @@ -105,7 +105,7 @@ func abort() { } //export write -func write(fd int32, buf *byte, count int) int { +func libc_write(fd int32, buf *byte, count int) int { // TODO: Proper handling write for i := 0; i < count; i++ { putchar(*buf) diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index cfc9885d7f..37c21ee895 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -5,11 +5,14 @@ type Frames struct { } type Frame struct { + PC uintptr + + Func *Func + Function string File string Line int - PC uintptr } func CallersFrames(callers []uintptr) *Frames {