Skip to content

Commit 7f5af09

Browse files
johanbrandhorstRichard Musiolachille-rousselPryzevanphx
committed
cmd: add wasip1 support
For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I530ea78a3cd142f3a745f650b21c30e7f10ce981 Reviewed-on: https://go-review.googlesource.com/c/go/+/479621 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
1 parent 1777031 commit 7f5af09

File tree

11 files changed

+52
-23
lines changed

11 files changed

+52
-23
lines changed

src/cmd/compile/internal/types2/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Only run where builders (build.golang.org) have
66
// access to compiled packages for import.
77
//
8-
//go:build !android && !ios && !js
8+
//go:build !android && !ios && !js && !wasip1
99

1010
package types2_test
1111

src/cmd/dist/test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ func (t *tester) registerTests() {
675675
}
676676

677677
// Runtime CPU tests.
678-
if !t.compileOnly && goos != "js" { // js can't handle -cpu != 1
678+
if !t.compileOnly && t.hasParallelism() {
679679
t.registerTest("runtime:cpu124", "GOMAXPROCS=2 runtime -cpu=1,2,4 -quick",
680680
&goTest{
681681
timeout: 300 * time.Second,
@@ -737,9 +737,9 @@ func (t *tester) registerTests() {
737737
// On the builders only, test that a moved GOROOT still works.
738738
// Fails on iOS because CC_FOR_TARGET refers to clangwrap.sh
739739
// in the unmoved GOROOT.
740-
// Fails on Android and js/wasm with an exec format error.
740+
// Fails on Android, js/wasm and wasip1/wasm with an exec format error.
741741
// Fails on plan9 with "cannot find GOROOT" (issue #21016).
742-
if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() && goos != "plan9" && goos != "js" {
742+
if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() && goos != "plan9" && goos != "js" && goos != "wasip1" {
743743
t.tests = append(t.tests, distTest{
744744
name: "moved_goroot",
745745
heading: "moved GOROOT",
@@ -835,7 +835,7 @@ func (t *tester) registerTests() {
835835
}
836836

837837
// sync tests
838-
if goos != "js" { // js doesn't support -cpu=10
838+
if t.hasParallelism() {
839839
t.registerTest("sync_cpu", "sync -cpu=10",
840840
&goTest{
841841
timeout: 120 * time.Second,
@@ -1476,6 +1476,14 @@ func (t *tester) hasSwig() bool {
14761476
return true
14771477
}
14781478

1479+
func (t *tester) hasParallelism() bool {
1480+
switch goos {
1481+
case "js", "wasip1":
1482+
return false
1483+
}
1484+
return true
1485+
}
1486+
14791487
func (t *tester) raceDetectorSupported() bool {
14801488
if gohostos != goos {
14811489
return false

src/cmd/go/internal/base/signal_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build unix || js
5+
//go:build unix || js || wasip1
66

77
package base
88

src/cmd/go/internal/cache/cache_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"bytes"
99
"encoding/binary"
1010
"fmt"
11-
"internal/testenv"
1211
"os"
1312
"path/filepath"
1413
"runtime"
@@ -152,8 +151,8 @@ func dummyID(x int) [HashSize]byte {
152151
}
153152

154153
func TestCacheTrim(t *testing.T) {
155-
if runtime.GOOS == "js" {
156-
testenv.SkipFlaky(t, 35220)
154+
if runtime.GOOS == "js" || runtime.GOOS == "wasip1" {
155+
t.Skip("file lock is unsupported on +" + runtime.GOOS)
157156
}
158157

159158
dir, err := os.MkdirTemp("", "cachetest-")

src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !js && !plan9
5+
//go:build !js && !plan9 && !wasip1
66

77
package filelock_test
88

src/cmd/go/internal/lockedfile/lockedfile_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// js does not support inter-process file locking.
5+
// js and wasip1 do not support inter-process file locking.
66
//
7-
//go:build !js
7+
//go:build !js && !wasip1
88

99
package lockedfile_test
1010

src/cmd/go/internal/lockedfile/transform_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// js does not support inter-process file locking.
5+
// js and wasip1 do not support inter-process file locking.
66
//
7-
//go:build !js
7+
//go:build !js && !wasip1
88

99
package lockedfile_test
1010

src/cmd/go/internal/mmap/mmap_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build (js && wasm) || plan9
5+
//go:build (js && wasm) || wasip1 || plan9
66

77
package mmap
88

src/cmd/go/internal/work/build_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package work
66

77
import (
88
"fmt"
9+
"internal/testenv"
910
"io/fs"
1011
"os"
1112
"path/filepath"
@@ -221,13 +222,6 @@ func pkgImportPath(pkgpath string) *load.Package {
221222
// directory.
222223
// See https://golang.org/issue/18878.
223224
func TestRespectSetgidDir(t *testing.T) {
224-
switch runtime.GOOS {
225-
case "ios":
226-
t.Skip("can't set SetGID bit with chmod on iOS")
227-
case "windows", "plan9":
228-
t.Skip("chown/chmod setgid are not supported on Windows or Plan 9")
229-
}
230-
231225
var b Builder
232226

233227
// Check that `cp` is called instead of `mv` by looking at the output
@@ -250,12 +244,23 @@ func TestRespectSetgidDir(t *testing.T) {
250244
// the new temporary directory.
251245
err = os.Chown(setgiddir, os.Getuid(), os.Getgid())
252246
if err != nil {
247+
if testenv.SyscallIsNotSupported(err) {
248+
t.Skip("skipping: chown is not supported on " + runtime.GOOS)
249+
}
253250
t.Fatal(err)
254251
}
255252

256253
// Change setgiddir's permissions to include the SetGID bit.
257254
if err := os.Chmod(setgiddir, 0755|fs.ModeSetgid); err != nil {
255+
if testenv.SyscallIsNotSupported(err) {
256+
t.Skip("skipping: chmod is not supported on " + runtime.GOOS)
257+
}
258+
t.Fatal(err)
259+
}
260+
if fi, err := os.Stat(setgiddir); err != nil {
258261
t.Fatal(err)
262+
} else if fi.Mode()&fs.ModeSetgid == 0 {
263+
t.Skip("skipping: Chmod ignored ModeSetgid on " + runtime.GOOS)
259264
}
260265

261266
pkgfile, err := os.CreateTemp("", "pkgfile")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2023 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build wasip1
6+
7+
package osinfo
8+
9+
import (
10+
"errors"
11+
"fmt"
12+
)
13+
14+
// Version returns the OS version name/number.
15+
func Version() (string, error) {
16+
return "", fmt.Errorf("unable to determine OS version: %w", errors.ErrUnsupported)
17+
}

0 commit comments

Comments
 (0)