Skip to content

Commit

Permalink
Set floor Go version at 1.20 (#2025)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
Co-authored-by: Edoardo Vacchi <[email protected]>
  • Loading branch information
mathetake and evacchi authored Feb 9, 2024
1 parent 25cf3c0 commit abf0ada
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 113 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
- os: macos-14
arch: arm64
go-version:
- "1.21" # Current Go version
- "1.19" # Floor Go version of wazero (current - 2)
- "1.22" # Current Go version
- "1.20" # Floor Go version of wazero (current - 2)

steps:

Expand Down Expand Up @@ -114,8 +114,8 @@ jobs:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
go-version:
- "1.21" # Current Go version
- "1.19" # Floor Go version of wazero (current - 2)
- "1.22" # Current Go version
- "1.20" # Floor Go version of wazero (current - 2)
arch:
- "amd64"
- "arm64"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
strategy:
matrix: # Use versions consistent with TinyGo.
go-version:
# TODO: Add 1.22 when TinyGo supports it.
- "1.20" # Latest Go version supported by TinyGo until its next version.
- "1.19" # Floor Go version of latest TinyGo

Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,20 +318,33 @@ jobs:
compiler: [baseline]
arch: [amd64]
go-version:
- "1.21" # Current Go version && The only version that supports wasip1.
- "1.21"
- "1.22"
include:
- os:
version: macos-14
name: macOS
compiler: optimizing
arch: "arm64"
go-version: "1.21"
- os:
version: macos-14
name: macOS
compiler: optimizing
arch: "arm64"
go-version: "1.22"
- os:
version: ubuntu-22.04
name: Ubuntu
compiler: optimizing
arch: "amd64"
go-version: "1.21"
- os:
version: ubuntu-22.04
name: Ubuntu
compiler: optimizing
arch: "amd64"
go-version: "1.22"

steps:
- id: setup-go
Expand All @@ -357,6 +370,12 @@ jobs:
cd ${{ env.STDLIB_TESTS }}
make build.gowasip1
# The wasip1 stdlib tests are really path sensitive, so they expect a writeable /tmp directory to be available.
# We create it at the root of `C:`. This is normally only necessary on GHA Windows runners.
- if: ${{ matrix.os.name == 'Windows' }}
run: |
mkdir /c/tmp
- name: Run built test binaries
run: |
cd ${{ env.STDLIB_TESTS }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/spectest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
go-version:
- "1.21" # Current Go version
- "1.19" # Floor Go version of wazero (current - 2)
- "1.22" # Current Go version
- "1.20" # Floor Go version of wazero (current - 2)
spec-version:
- "v1"
- "v2"
Expand All @@ -52,8 +52,8 @@ jobs:
fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
matrix: # Use versions consistent with wazero's Go support policy.
go-version:
- "1.21" # Current Go version
- "1.19" # Floor Go version of wazero (current - 2)
- "1.22" # Current Go version
- "1.20" # Floor Go version of wazero (current - 2)
arch:
- "arm64"
- "riscv64"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/tetratelabs/wazero

// Floor Go version of wazero (current - 2)
go 1.19
go 1.20

// All the beta tags are retracted and replaced with "pre" to prevent users
// from accidentally upgrading into the broken beta 1.
Expand Down
14 changes: 0 additions & 14 deletions imports/wasi_snapshot_preview1/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"math"
"os"
"path"
"runtime"
"testing"
gofstest "testing/fstest"
"time"
Expand Down Expand Up @@ -3558,11 +3557,6 @@ func Test_pathFilestatSetTimes(t *testing.T) {
},
}

if runtime.GOOS == "windows" && !platform.IsAtLeastGo120 {
// Windows 1.19 returns ENOSYS on no_symlink_follow
tests = tests[:len(tests)-1]
}

for _, tt := range tests {
tc := tt

Expand Down Expand Up @@ -4951,10 +4945,6 @@ func requireOpenFile(t *testing.T, tmpDir string, pathName string, data []byte,

// Test_fdReaddir_dotEntryHasARealInode because wasi-testsuite requires it.
func Test_fdReaddir_dotEntryHasARealInode(t *testing.T) {
if runtime.GOOS == "windows" && !platform.IsAtLeastGo120 {
t.Skip("windows before go 1.20 has trouble reading the inode information on directories.")
}

root := t.TempDir()
mod, r, _ := requireProxyModule(t, wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().WithDirMount(root, "/")),
Expand Down Expand Up @@ -5008,10 +4998,6 @@ func Test_fdReaddir_dotEntryHasARealInode(t *testing.T) {
// is visible. This is significant on Windows.
// https://github.com/ziglang/zig/blob/2ccff5115454bab4898bae3de88f5619310bc5c1/lib/std/fs/test.zig#L156-L184
func Test_fdReaddir_opened_file_written(t *testing.T) {
if runtime.GOOS == "windows" && !platform.IsAtLeastGo120 {
t.Skip("windows before go 1.20 has trouble reading the inode information on directories.")
}

tmpDir := t.TempDir()
mod, r, _ := requireProxyModule(t, wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().WithDirMount(tmpDir, "/")),
Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/fuzz/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/integration_test/fuzz

go 1.19
go 1.20

require github.com/tetratelabs/wazero v0.0.0

Expand Down
3 changes: 1 addition & 2 deletions internal/integration_test/stdlibs/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ var (
c, stdout, stderr = defaultModuleConfig()
c = c.WithFSConfig(
wazero.NewFSConfig().
WithDirMount(sysroot, "/").
WithDirMount(os.TempDir(), "/tmp")).
WithDirMount(sysroot, "/")).
WithEnv("PWD", normalizedTestdir)

args := []string{fname, "-test.short", "-test.v"}
Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/vs/time/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/integration_test/vs/clock

go 1.19
go 1.20

require golang.org/x/sys v0.1.0

Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/vs/wasmedge/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmedge

go 1.19
go 1.20

require (
github.com/second-state/WasmEdge-go v0.12.1
Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/vs/wasmtime/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tetratelabs/wazero/internal/integration_test/vs/wasmtime

go 1.19
go 1.20

require (
github.com/bytecodealliance/wasmtime-go/v9 v9.0.0
Expand Down
9 changes: 0 additions & 9 deletions internal/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
package platform

import (
"regexp"
"runtime"
)

// IsAtLeastGo120 checks features added in 1.20. We can remove this when Go
// 1.22 is out.
var IsAtLeastGo120 = isAtLeastGo120(runtime.Version())

func isAtLeastGo120(version string) bool {
return regexp.MustCompile("go1.[2-9][0-9][^0-9]").MatchString(version)
}

// archRequirementsVerified is set by platform-specific init to true if the platform is supported
var archRequirementsVerified bool

Expand Down
21 changes: 0 additions & 21 deletions internal/platform/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,3 @@ func Test_archRequirementsVerified(t *testing.T) {
require.False(t, archRequirementsVerified)
}
}

func Test_isAtLeastGo120(t *testing.T) {
tests := []struct {
input string
expected bool
}{
{input: "go1.18.10", expected: false},
{input: "go1.19.10", expected: false},
{input: "go1.20.5", expected: true},
{input: "devel go1.21-39c50707 Thu Jul 6 23:23:41 2023 +0000", expected: true},
{input: "go1.21rc2", expected: true},
{input: "go1.90.10", expected: true},
{input: "go2.0.0", expected: false},
}

for _, tt := range tests {
tc := tt

require.Equal(t, tc.expected, isAtLeastGo120(tc.input), tc.input)
}
}
2 changes: 1 addition & 1 deletion internal/sysfs/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestAdaptFS_Open_Read(t *testing.T) {

// We can't correct operating system portability issues with os.DirFS on
// windows. Use syscall.DirFS instead!
testOpen_Read(t, testFS, statSetsIno(), runtime.GOOS != "windows")
testOpen_Read(t, testFS, true, runtime.GOOS != "windows")

t.Run("path outside root invalid", func(t *testing.T) {
_, err := testFS.OpenFile("../foo", experimentalsys.O_RDONLY, 0)
Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/dirfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func TestDirFS_OpenFile(t *testing.T) {

testFS := DirFS(tmpDir)

testOpen_Read(t, testFS, statSetsIno(), true)
testOpen_Read(t, testFS, true, true)

testOpen_O_RDWR(t, tmpDir, testFS)

Expand Down
25 changes: 2 additions & 23 deletions internal/sysfs/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/fsapi"
"github.com/tetratelabs/wazero/internal/platform"
"github.com/tetratelabs/wazero/internal/testing/require"
"github.com/tetratelabs/wazero/sys"
)
Expand Down Expand Up @@ -195,9 +194,7 @@ func TestFileIno(t *testing.T) {
ino, errno := d.Ino()
require.EqualErrno(t, 0, errno)
// Results are inconsistent, so don't validate the opposite.
if statSetsIno() {
require.Equal(t, tc.expectedIno, ino)
}
require.Equal(t, tc.expectedIno, ino)
})
}

Expand All @@ -209,25 +206,10 @@ func TestFileIno(t *testing.T) {
ino, errno := d.Ino()
require.EqualErrno(t, 0, errno)
// Results are inconsistent, so don't validate the opposite.
if statSetsIno() {
require.Equal(t, st.Ino, ino)
}
require.Equal(t, st.Ino, ino)
})
}

// statSetsIno returns true if this will set sys.Stat_t Ino on stat. The
// reverse doesn't mean it won't. Rather it is inconsistent. This is needed
// because Windows on Go 1.19 sometimes, but not always returns non-zero inode.
func statSetsIno() bool {
if runtime.GOOS != "windows" {
return true
} else {
// Go can read the inode via a Windows file handle, but it is
// inconsistent on Go 1.19.
return platform.IsAtLeastGo120
}
}

func TestFileIsDir(t *testing.T) {
dirFS, embedFS, mapFS := dirEmbedMapFS(t, t.TempDir())

Expand Down Expand Up @@ -978,9 +960,6 @@ func TestFileUtimens(t *testing.T) {
case "linux", "darwin": // supported
case "freebsd": // TODO: support freebsd w/o CGO
case "windows":
if !platform.IsAtLeastGo120 {
t.Skip("windows only works after Go 1.20") // TODO: possibly 1.19 ;)
}
default: // expect ENOSYS and callers need to fall back to Utimens
t.Skip("unsupported GOOS", runtime.GOOS)
}
Expand Down
7 changes: 0 additions & 7 deletions internal/sysfs/futimens_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ import (
"syscall"

"github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/platform"
)

func utimens(path string, atim, mtim int64) sys.Errno {
return chtimes(path, atim, mtim)
}

func futimens(fd uintptr, atim, mtim int64) error {
// Before Go 1.20, ERROR_INVALID_HANDLE was returned for too many reasons.
// Kick out so that callers can use path-based operations instead.
if !platform.IsAtLeastGo120 {
return sys.ENOSYS
}

// Per docs, zero isn't a valid timestamp as it cannot be differentiated
// from nil. In both cases, it is a marker like sys.UTIME_OMIT.
// See https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfiletime
Expand Down
13 changes: 5 additions & 8 deletions internal/sysfs/open_file_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"unsafe"

"github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/platform"
)

func openFile(path string, oflag sys.Oflag, perm fs.FileMode) (*os.File, sys.Errno) {
Expand Down Expand Up @@ -150,13 +149,11 @@ func open(path string, mode int, perm uint32) (fd syscall.Handle, err error) {
}
}

if platform.IsAtLeastGo120 {
// This shouldn't be included before 1.20 to have consistent behavior.
// https://github.com/golang/go/commit/0f0aa5d8a6a0253627d58b3aa083b24a1091933f
if createmode == syscall.OPEN_EXISTING && access == syscall.GENERIC_READ {
// Necessary for opening directory handles.
attrs |= syscall.FILE_FLAG_BACKUP_SEMANTICS
}
// This shouldn't be included before 1.20 to have consistent behavior.
// https://github.com/golang/go/commit/0f0aa5d8a6a0253627d58b3aa083b24a1091933f
if createmode == syscall.OPEN_EXISTING && access == syscall.GENERIC_READ {
// Necessary for opening directory handles.
attrs |= syscall.FILE_FLAG_BACKUP_SEMANTICS
}

h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, attrs, 0)
Expand Down
4 changes: 2 additions & 2 deletions internal/sysfs/readfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ func TestReadFS_Open_Read(t *testing.T) {
fs: func(tmpDir string) sys.FS {
return &AdaptFS{FS: os.DirFS(tmpDir)}
},
expectFileIno: statSetsIno(),
expectFileIno: true,
expectDirIno: runtime.GOOS != "windows",
},
{
name: "mask(os.DirFS)",
fs: func(tmpDir string) sys.FS {
return &AdaptFS{FS: &MaskOsFS{Fs: os.DirFS(tmpDir)}}
},
expectFileIno: statSetsIno(),
expectFileIno: true,
expectDirIno: runtime.GOOS != "windows",
},
{
Expand Down
6 changes: 2 additions & 4 deletions internal/sysfs/stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,8 @@ func requireDir(t *testing.T, d experimentalsys.File, st sys.Stat_t) {

func requireDevIno(t *testing.T, f experimentalsys.File, st sys.Stat_t) {
// Results are inconsistent, so don't validate the opposite.
if statSetsIno() {
require.NotEqual(t, uint64(0), st.Dev)
require.NotEqual(t, uint64(0), st.Ino)
}
require.NotEqual(t, uint64(0), st.Dev)
require.NotEqual(t, uint64(0), st.Ino)

// Verify the special-cased properties supporting wasip2 "is_same_object"
// See https://github.com/WebAssembly/wasi-filesystem/pull/81
Expand Down
Loading

0 comments on commit abf0ada

Please sign in to comment.