all: Go 1.21 support
Этот коммит содержится в:
родитель
c25dd0a972
коммит
a93f0ed12a
16 изменённых файлов: 76 добавлений и 20 удалений
4
.github/workflows/build-macos.yml
предоставленный
4
.github/workflows/build-macos.yml
предоставленный
|
@ -27,7 +27,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Restore LLVM source cache
|
- name: Restore LLVM source cache
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
|
@ -126,7 +126,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Build TinyGo
|
- name: Build TinyGo
|
||||||
run: go install
|
run: go install
|
||||||
|
|
10
.github/workflows/linux.yml
предоставленный
10
.github/workflows/linux.yml
предоставленный
|
@ -18,7 +18,7 @@ jobs:
|
||||||
# statically linked binary.
|
# statically linked binary.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: golang:1.20-alpine
|
image: golang:1.21rc4-alpine
|
||||||
steps:
|
steps:
|
||||||
- name: Install apk dependencies
|
- name: Install apk dependencies
|
||||||
# tar: needed for actions/cache@v3
|
# tar: needed for actions/cache@v3
|
||||||
|
@ -135,7 +135,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Install wasmtime
|
- name: Install wasmtime
|
||||||
run: |
|
run: |
|
||||||
|
@ -177,7 +177,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
@ -290,7 +290,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Restore LLVM source cache
|
- name: Restore LLVM source cache
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
|
@ -407,7 +407,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Restore LLVM source cache
|
- name: Restore LLVM source cache
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
|
|
8
.github/workflows/windows.yml
предоставленный
8
.github/workflows/windows.yml
предоставленный
|
@ -35,7 +35,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Restore cached LLVM source
|
- name: Restore cached LLVM source
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
|
@ -143,7 +143,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Download TinyGo build
|
- name: Download TinyGo build
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
|
@ -173,7 +173,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Download TinyGo build
|
- name: Download TinyGo build
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
|
@ -209,7 +209,7 @@ jobs:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.21.0-rc.4'
|
||||||
cache: true
|
cache: true
|
||||||
- name: Download TinyGo build
|
- name: Download TinyGo build
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
|
|
|
@ -27,7 +27,7 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, 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:
|
// 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
|
// 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)
|
return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor)
|
||||||
|
|
|
@ -348,7 +348,7 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
|
||||||
// The list of allowed types is based on this proposal:
|
// The list of allowed types is based on this proposal:
|
||||||
// https://github.com/golang/go/issues/59149
|
// https://github.com/golang/go/issues/59149
|
||||||
func (c *compilerContext) checkWasmImport(f *ssa.Function, pragma string) {
|
func (c *compilerContext) checkWasmImport(f *ssa.Function, pragma string) {
|
||||||
if c.pkg.Path() == "runtime" {
|
if c.pkg.Path() == "runtime" || c.pkg.Path() == "syscall/js" {
|
||||||
// The runtime is a special case. Allow all kinds of parameters
|
// The runtime is a special case. Allow all kinds of parameters
|
||||||
// (importantly, including pointers).
|
// (importantly, including pointers).
|
||||||
return
|
return
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -31,3 +31,5 @@ require (
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace go.bug.st/serial => github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -12,6 +12,8 @@ github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moA
|
||||||
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
|
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
|
||||||
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
|
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
|
github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919 h1:Hi7G1bCG70NwlyqGswJKEHoIi4hJVN1SsmfwZ+DQHtw=
|
||||||
|
github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
|
||||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||||
|
@ -46,8 +48,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||||
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 h1:aQKxg3+2p+IFXXg97McgDGT5zcMrQoi0EICZs8Pgchs=
|
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 h1:aQKxg3+2p+IFXXg97McgDGT5zcMrQoi0EICZs8Pgchs=
|
||||||
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3/go.mod h1:9/etS5gpQq9BJsJMWg1wpLbfuSnkm8dPF6FdW2JXVhA=
|
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3/go.mod h1:9/etS5gpQq9BJsJMWg1wpLbfuSnkm8dPF6FdW2JXVhA=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
go.bug.st/serial v1.3.5 h1:k50SqGZCnHZ2MiBQgzccXWG+kd/XpOs1jUljpDDKzaE=
|
|
||||||
go.bug.st/serial v1.3.5/go.mod h1:z8CesKorE90Qr/oRSJiEuvzYRKol9r/anJZEb5kt304=
|
|
||||||
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|
|
@ -251,3 +251,13 @@ func IndexRabinKarp(s, substr string) int {
|
||||||
}
|
}
|
||||||
return -1
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ func growHeap() bool {
|
||||||
|
|
||||||
//export malloc
|
//export malloc
|
||||||
func libc_malloc(size uintptr) unsafe.Pointer {
|
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)
|
return alloc(size, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/runtime/metrics.go
Обычный файл
10
src/runtime/metrics.go
Обычный файл
|
@ -0,0 +1,10 @@
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
// Implementation of functions needed by runtime/metrics.
|
||||||
|
// Mostly just dummy implementations: we don't currently use any of these
|
||||||
|
// metrics.
|
||||||
|
|
||||||
|
//go:linkname godebug_registerMetric internal/godebug.registerMetric
|
||||||
|
func godebug_registerMetric(name string, read func() uint64) {
|
||||||
|
// Dummy function for compatibility with Go 1.21.
|
||||||
|
}
|
|
@ -100,3 +100,27 @@ func godebug_setUpdate(update func(string, string)) {
|
||||||
// variable changes (for example, via os.Setenv).
|
// variable changes (for example, via os.Setenv).
|
||||||
godebugUpdate = update
|
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.
|
||||||
|
// TODO: use unsafe.String instead once we require Go 1.20.
|
||||||
|
s := _string{
|
||||||
|
ptr: (*byte)(p),
|
||||||
|
length: uintptr(n),
|
||||||
|
}
|
||||||
|
str := *(*string)(unsafe.Pointer(&s))
|
||||||
|
printstring(str)
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ func abort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//export write
|
//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
|
// TODO: Proper handling write
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
putchar(*buf)
|
putchar(*buf)
|
||||||
|
|
|
@ -44,8 +44,8 @@ func nanosecondsToTicks(ns int64) timeUnit {
|
||||||
// This function is called by the scheduler.
|
// This function is called by the scheduler.
|
||||||
// Schedule a call to runtime.scheduler, do not actually sleep.
|
// Schedule a call to runtime.scheduler, do not actually sleep.
|
||||||
//
|
//
|
||||||
//export runtime.sleepTicks
|
//go:wasmimport gojs runtime.sleepTicks
|
||||||
func sleepTicks(d timeUnit)
|
func sleepTicks(d timeUnit)
|
||||||
|
|
||||||
//export runtime.ticks
|
//go:wasmimport gojs runtime.ticks
|
||||||
func ticks() timeUnit
|
func ticks() timeUnit
|
||||||
|
|
|
@ -5,11 +5,14 @@ type Frames struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
|
PC uintptr
|
||||||
|
|
||||||
|
Func *Func
|
||||||
|
|
||||||
Function string
|
Function string
|
||||||
|
|
||||||
File string
|
File string
|
||||||
Line int
|
Line int
|
||||||
PC uintptr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallersFrames(callers []uintptr) *Frames {
|
func CallersFrames(callers []uintptr) *Frames {
|
||||||
|
|
|
@ -68,6 +68,7 @@ const (
|
||||||
EISDIR Errno = 21
|
EISDIR Errno = 21
|
||||||
EINVAL Errno = 22
|
EINVAL Errno = 22
|
||||||
EMFILE Errno = 24
|
EMFILE Errno = 24
|
||||||
|
EROFS Errno = 30
|
||||||
EPIPE Errno = 32
|
EPIPE Errno = 32
|
||||||
EAGAIN Errno = 35
|
EAGAIN Errno = 35
|
||||||
ENOTCONN Errno = 57
|
ENOTCONN Errno = 57
|
||||||
|
|
|
@ -284,7 +284,7 @@
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {
|
gojs: {
|
||||||
// func ticks() float64
|
// func ticks() float64
|
||||||
"runtime.ticks": () => {
|
"runtime.ticks": () => {
|
||||||
return timeOrigin + performance.now();
|
return timeOrigin + performance.now();
|
||||||
|
@ -444,6 +444,10 @@
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Go 1.20 uses 'env'. Go 1.21 uses 'gojs'.
|
||||||
|
// For compatibility, we use both as long as Go 1.20 is supported.
|
||||||
|
this.importObject.env = this.importObject.gojs;
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(instance) {
|
async run(instance) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче