Skip to content

Commit a93f0ed

Browse files
aykevldeadprogram
authored andcommitted
all: Go 1.21 support
1 parent c25dd0a commit a93f0ed

File tree

16 files changed

+76
-20
lines changed

16 files changed

+76
-20
lines changed

.github/workflows/build-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install Go
2828
uses: actions/setup-go@v3
2929
with:
30-
go-version: '1.20'
30+
go-version: '1.21.0-rc.4'
3131
cache: true
3232
- name: Restore LLVM source cache
3333
uses: actions/cache/restore@v3
@@ -126,7 +126,7 @@ jobs:
126126
- name: Install Go
127127
uses: actions/setup-go@v3
128128
with:
129-
go-version: '1.20'
129+
go-version: '1.21.0-rc.4'
130130
cache: true
131131
- name: Build TinyGo
132132
run: go install

.github/workflows/linux.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# statically linked binary.
1919
runs-on: ubuntu-latest
2020
container:
21-
image: golang:1.20-alpine
21+
image: golang:1.21rc4-alpine
2222
steps:
2323
- name: Install apk dependencies
2424
# tar: needed for actions/cache@v3
@@ -135,7 +135,7 @@ jobs:
135135
- name: Install Go
136136
uses: actions/setup-go@v3
137137
with:
138-
go-version: '1.20'
138+
go-version: '1.21.0-rc.4'
139139
cache: true
140140
- name: Install wasmtime
141141
run: |
@@ -177,7 +177,7 @@ jobs:
177177
- name: Install Go
178178
uses: actions/setup-go@v3
179179
with:
180-
go-version: '1.20'
180+
go-version: '1.21.0-rc.4'
181181
cache: true
182182
- name: Install Node.js
183183
uses: actions/setup-node@v3
@@ -290,7 +290,7 @@ jobs:
290290
- name: Install Go
291291
uses: actions/setup-go@v3
292292
with:
293-
go-version: '1.20'
293+
go-version: '1.21.0-rc.4'
294294
cache: true
295295
- name: Restore LLVM source cache
296296
uses: actions/cache/restore@v3
@@ -407,7 +407,7 @@ jobs:
407407
- name: Install Go
408408
uses: actions/setup-go@v3
409409
with:
410-
go-version: '1.20'
410+
go-version: '1.21.0-rc.4'
411411
cache: true
412412
- name: Restore LLVM source cache
413413
uses: actions/cache/restore@v3

.github/workflows/windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install Go
3636
uses: actions/setup-go@v3
3737
with:
38-
go-version: '1.20'
38+
go-version: '1.21.0-rc.4'
3939
cache: true
4040
- name: Restore cached LLVM source
4141
uses: actions/cache/restore@v3
@@ -143,7 +143,7 @@ jobs:
143143
- name: Install Go
144144
uses: actions/setup-go@v3
145145
with:
146-
go-version: '1.20'
146+
go-version: '1.21.0-rc.4'
147147
cache: true
148148
- name: Download TinyGo build
149149
uses: actions/download-artifact@v2
@@ -173,7 +173,7 @@ jobs:
173173
- name: Install Go
174174
uses: actions/setup-go@v3
175175
with:
176-
go-version: '1.20'
176+
go-version: '1.21.0-rc.4'
177177
cache: true
178178
- name: Download TinyGo build
179179
uses: actions/download-artifact@v2
@@ -209,7 +209,7 @@ jobs:
209209
- name: Install Go
210210
uses: actions/setup-go@v3
211211
with:
212-
go-version: '1.20'
212+
go-version: '1.21.0-rc.4'
213213
cache: true
214214
- name: Download TinyGo build
215215
uses: actions/download-artifact@v2

builder/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) {
2727
if err != nil {
2828
return nil, err
2929
}
30-
if major != 1 || minor < 18 || minor > 20 {
30+
if major != 1 || minor < 18 || minor > 21 {
3131
// Note: when this gets updated, also update the Go compatibility matrix:
3232
// https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md
3333
return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor)

compiler/symbol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
348348
// The list of allowed types is based on this proposal:
349349
// https://github.com/golang/go/issues/59149
350350
func (c *compilerContext) checkWasmImport(f *ssa.Function, pragma string) {
351-
if c.pkg.Path() == "runtime" {
351+
if c.pkg.Path() == "runtime" || c.pkg.Path() == "syscall/js" {
352352
// The runtime is a special case. Allow all kinds of parameters
353353
// (importantly, including pointers).
354354
return

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ require (
3131
github.com/mailru/easyjson v0.7.7 // indirect
3232
github.com/mattn/go-isatty v0.0.12 // indirect
3333
)
34+
35+
replace go.bug.st/serial => github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moA
1212
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
1313
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
1414
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
15+
github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919 h1:Hi7G1bCG70NwlyqGswJKEHoIi4hJVN1SsmfwZ+DQHtw=
16+
github.com/deadprogram/go-serial v0.0.0-20230717164825-4529b3232919/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
1517
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
1618
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
1719
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
4648
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 h1:aQKxg3+2p+IFXXg97McgDGT5zcMrQoi0EICZs8Pgchs=
4749
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3/go.mod h1:9/etS5gpQq9BJsJMWg1wpLbfuSnkm8dPF6FdW2JXVhA=
4850
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
49-
go.bug.st/serial v1.3.5 h1:k50SqGZCnHZ2MiBQgzccXWG+kd/XpOs1jUljpDDKzaE=
50-
go.bug.st/serial v1.3.5/go.mod h1:z8CesKorE90Qr/oRSJiEuvzYRKol9r/anJZEb5kt304=
5151
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
5252
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5353
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

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/metrics.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package runtime
2+
3+
// Implementation of functions needed by runtime/metrics.
4+
// Mostly just dummy implementations: we don't currently use any of these
5+
// metrics.
6+
7+
//go:linkname godebug_registerMetric internal/godebug.registerMetric
8+
func godebug_registerMetric(name string, read func() uint64) {
9+
// Dummy function for compatibility with Go 1.21.
10+
}

0 commit comments

Comments
 (0)