wasm: add support for GOOS=wasip1

This adds true GOOS=wasip1 support in addition to our existing
-target=wasi support. The old support for WASI isn't removed, but should
be treated as deprecated and will likely be removed eventually to reduce
the test burden.
This commit is contained in:
Ayke van Laethem
2023-08-10 22:36:35 +02:00
committed by Ron Evans
parent f4375d0452
commit a545f17d2e
40 changed files with 99 additions and 38 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && !baremetal && !wasi
//go:build linux && !baremetal && !wasi && !wasip1
package os
+1 -1
View File
@@ -6,7 +6,7 @@
// fairly similar: we use fdopendir, fdclosedir, and readdir from wasi-libc in
// a similar way that the darwin code uses functions from libc.
//go:build wasi
//go:build wasi || wasip1
package os
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || linux
//go:build darwin || linux || wasip1
package os_test
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || windows
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris || wasip1 || windows
package os
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build baremetal || (wasm && !wasi)
//go:build baremetal || (wasm && !wasi && !wasip1)
package os
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal)
//go:build darwin || (linux && !baremetal) || wasip1
// target wasi sets GOOS=linux and thus the +linux build tag,
// even though it doesn't show up in "tinygo info target -wasi"
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build windows || darwin || (linux && !baremetal)
//go:build windows || darwin || (linux && !baremetal) || wasip1
package os_test
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !wasi
//go:build !wasi && !wasip1
package os_test
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build wasi
//go:build wasi || wasip1
package os_test
+1 -2
View File
@@ -1,4 +1,4 @@
//go:build windows || darwin || (linux && !baremetal)
//go:build windows || darwin || (linux && !baremetal) || wasip1
package os_test
@@ -23,7 +23,6 @@ var dot = []string{
"os_test.go",
"types.go",
"stat_darwin.go",
"stat_linux.go",
}
func randomName() string {
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !baremetal && !js && !wasi
//go:build !baremetal && !js && !wasi && !wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !windows && !baremetal && !js && !wasi
//go:build !windows && !baremetal && !js && !wasi && !wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !baremetal && !js && !wasi
//go:build !baremetal && !js && !wasi && !wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !baremetal && !js && !wasi
//go:build !baremetal && !js && !wasi && !wasip1
package os
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build baremetal || js || wasi
//go:build baremetal || js || wasi || wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -1,9 +1,13 @@
//go:build linux && !baremetal
//go:build (linux && !baremetal) || wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Note: this file is used for both Linux and WASI.
// Eventually it might be better to spit it up, and make the syscall constants
// match the typical WASI constants instead of the Linux-equivalents used here.
package os
import (
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build baremetal || (wasm && !wasi)
//go:build baremetal || (wasm && !wasi && !wasip1)
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal)
//go:build darwin || (linux && !baremetal) || wasip1
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !baremetal && !js && !wasi
//go:build !baremetal && !js && !wasi && !wasip1
package os_test
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build darwin || (linux && !baremetal)
//go:build darwin || (linux && !baremetal) || wasip1
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build linux || darwin || windows
//go:build linux || darwin || windows || wasip1
package runtime
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build linux || darwin
//go:build linux || darwin || wasip1
package runtime
+10
View File
@@ -0,0 +1,10 @@
//go:build wasip1
package runtime
// The actual GOOS=wasip1, as newly added in the Go 1.21 toolchain.
// Previously we supported -target=wasi, but that was essentially faked by using
// linux/arm instead because that was the closest thing that was already
// supported in the Go standard library.
const GOOS = "wasip1"
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build wasm && !wasi
//go:build wasm && !wasi && !wasip1
package runtime
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build wasm && !wasi && !scheduler.none
//go:build wasm && !wasi && !scheduler.none && !wasip1
package runtime
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build tinygo.wasm && wasi
//go:build tinygo.wasm && (wasi || wasip1)
package runtime
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !wasi && !darwin
//go:build !wasi && !wasip1 && !darwin
package syscall
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build baremetal || wasm
//go:build baremetal || (wasm && !wasip1)
// This file emulates some file-related functions that are only available
// under a real operating system.
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !baremetal && !wasm
//go:build !(baremetal || (wasm && !wasip1))
// This file assumes there is a libc available that runs on a real operating
// system.
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build baremetal || wasi || wasm
//go:build baremetal || tinygo.wasm
// This file emulates some process-related functions that are only available
// under a real operating system.
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build !baremetal && !wasi && !wasm
//go:build !baremetal && !tinygo.wasm
// This file assumes there is a libc available that runs on a real operating
// system.
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build darwin || nintendoswitch || wasi
//go:build darwin || nintendoswitch || wasi || wasip1
package syscall
+1 -1
View File
@@ -1,4 +1,4 @@
//go:build wasi
//go:build wasi || wasip1
package syscall
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
//go:build !wasi
//go:build !wasi && !wasip1
package testing_test
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
//go:build wasi
//go:build wasi || wasip1
package testing_test