aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-08-10 22:36:35 +0200
committerRon Evans <[email protected]>2023-08-17 18:16:54 +0200
commita545f17d2ea55807de4b97cf4f52f01d5d4f1815 (patch)
tree075ea83380859d7604f67ca4dbaafc7ff76f4e90 /src
parentf4375d045213c416fad2d19773e7700b6b02f685 (diff)
downloadtinygo-a545f17d2ea55807de4b97cf4f52f01d5d4f1815.tar.gz
tinygo-a545f17d2ea55807de4b97cf4f52f01d5d4f1815.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/os/dir_unix.go2
-rw-r--r--src/os/dir_wasi.go2
-rw-r--r--src/os/env_unix_test.go2
-rw-r--r--src/os/exec_posix.go2
-rw-r--r--src/os/file_other.go2
-rw-r--r--src/os/file_unix.go2
-rw-r--r--src/os/getpagesize_test.go2
-rw-r--r--src/os/is_wasi_no_test.go2
-rw-r--r--src/os/is_wasi_test.go2
-rw-r--r--src/os/os_anyos_test.go3
-rw-r--r--src/os/os_chmod_test.go2
-rw-r--r--src/os/os_symlink_test.go2
-rw-r--r--src/os/read_test.go2
-rw-r--r--src/os/removeall_noat.go2
-rw-r--r--src/os/removeall_other.go2
-rw-r--r--src/os/stat_linuxlike.go (renamed from src/os/stat_linux.go)6
-rw-r--r--src/os/stat_other.go2
-rw-r--r--src/os/stat_unix.go2
-rw-r--r--src/os/tempfile_test.go2
-rw-r--r--src/os/types_unix.go2
-rw-r--r--src/runtime/env.go2
-rw-r--r--src/runtime/env_unix.go2
-rw-r--r--src/runtime/os_wasip1.go10
-rw-r--r--src/runtime/runtime_wasm_js.go2
-rw-r--r--src/runtime/runtime_wasm_js_scheduler.go2
-rw-r--r--src/runtime/runtime_wasm_wasi.go2
-rw-r--r--src/syscall/errno_other.go2
-rw-r--r--src/syscall/file_emulated.go2
-rw-r--r--src/syscall/file_hosted.go2
-rw-r--r--src/syscall/proc_emulated.go2
-rw-r--r--src/syscall/proc_hosted.go2
-rw-r--r--src/syscall/syscall_libc.go2
-rw-r--r--src/syscall/syscall_libc_wasi.go2
-rw-r--r--src/testing/is_wasi_no_test.go2
-rw-r--r--src/testing/is_wasi_test.go2
35 files changed, 48 insertions, 35 deletions
diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go
index f290ea38e..baacdd68d 100644
--- a/src/os/dir_unix.go
+++ b/src/os/dir_unix.go
@@ -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
diff --git a/src/os/dir_wasi.go b/src/os/dir_wasi.go
index 60a941f24..23be3950e 100644
--- a/src/os/dir_wasi.go
+++ b/src/os/dir_wasi.go
@@ -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
diff --git a/src/os/env_unix_test.go b/src/os/env_unix_test.go
index b5f6473e1..034f48154 100644
--- a/src/os/env_unix_test.go
+++ b/src/os/env_unix_test.go
@@ -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
diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go
index 151520cca..3ccb6963b 100644
--- a/src/os/exec_posix.go
+++ b/src/os/exec_posix.go
@@ -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
diff --git a/src/os/file_other.go b/src/os/file_other.go
index 7e5833d35..d093e3d18 100644
--- a/src/os/file_other.go
+++ b/src/os/file_other.go
@@ -1,4 +1,4 @@
-//go:build baremetal || (wasm && !wasi)
+//go:build baremetal || (wasm && !wasi && !wasip1)
package os
diff --git a/src/os/file_unix.go b/src/os/file_unix.go
index 6314db8fa..665fb0937 100644
--- a/src/os/file_unix.go
+++ b/src/os/file_unix.go
@@ -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"
diff --git a/src/os/getpagesize_test.go b/src/os/getpagesize_test.go
index 705cfd47d..80475552b 100644
--- a/src/os/getpagesize_test.go
+++ b/src/os/getpagesize_test.go
@@ -1,4 +1,4 @@
-//go:build windows || darwin || (linux && !baremetal)
+//go:build windows || darwin || (linux && !baremetal) || wasip1
package os_test
diff --git a/src/os/is_wasi_no_test.go b/src/os/is_wasi_no_test.go
index a8d04b674..aa7745085 100644
--- a/src/os/is_wasi_no_test.go
+++ b/src/os/is_wasi_no_test.go
@@ -1,4 +1,4 @@
-//go:build !wasi
+//go:build !wasi && !wasip1
package os_test
diff --git a/src/os/is_wasi_test.go b/src/os/is_wasi_test.go
index 551e00075..619b1cb64 100644
--- a/src/os/is_wasi_test.go
+++ b/src/os/is_wasi_test.go
@@ -1,4 +1,4 @@
-//go:build wasi
+//go:build wasi || wasip1
package os_test
diff --git a/src/os/os_anyos_test.go b/src/os/os_anyos_test.go
index 76bf4f368..44606e163 100644
--- a/src/os/os_anyos_test.go
+++ b/src/os/os_anyos_test.go
@@ -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 {
diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go
index af54815d8..911438d95 100644
--- a/src/os/os_chmod_test.go
+++ b/src/os/os_chmod_test.go
@@ -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
diff --git a/src/os/os_symlink_test.go b/src/os/os_symlink_test.go
index f231f8d9d..f252116f5 100644
--- a/src/os/os_symlink_test.go
+++ b/src/os/os_symlink_test.go
@@ -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
diff --git a/src/os/read_test.go b/src/os/read_test.go
index 6915dfaf9..e037b2349 100644
--- a/src/os/read_test.go
+++ b/src/os/read_test.go
@@ -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
diff --git a/src/os/removeall_noat.go b/src/os/removeall_noat.go
index 03339ae3b..ae945c249 100644
--- a/src/os/removeall_noat.go
+++ b/src/os/removeall_noat.go
@@ -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
diff --git a/src/os/removeall_other.go b/src/os/removeall_other.go
index a388a6c22..ec055a987 100644
--- a/src/os/removeall_other.go
+++ b/src/os/removeall_other.go
@@ -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
diff --git a/src/os/stat_linux.go b/src/os/stat_linuxlike.go
index d407c5c7e..f2ff8a5f6 100644
--- a/src/os/stat_linux.go
+++ b/src/os/stat_linuxlike.go
@@ -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 (
diff --git a/src/os/stat_other.go b/src/os/stat_other.go
index 162313b11..ff1bc3774 100644
--- a/src/os/stat_other.go
+++ b/src/os/stat_other.go
@@ -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
diff --git a/src/os/stat_unix.go b/src/os/stat_unix.go
index 4667d96a7..54b2bb485 100644
--- a/src/os/stat_unix.go
+++ b/src/os/stat_unix.go
@@ -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
diff --git a/src/os/tempfile_test.go b/src/os/tempfile_test.go
index f25390d6c..4b7416f4e 100644
--- a/src/os/tempfile_test.go
+++ b/src/os/tempfile_test.go
@@ -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
diff --git a/src/os/types_unix.go b/src/os/types_unix.go
index 68a4e628a..943fc00f5 100644
--- a/src/os/types_unix.go
+++ b/src/os/types_unix.go
@@ -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
diff --git a/src/runtime/env.go b/src/runtime/env.go
index dceb6bd18..72232e2f5 100644
--- a/src/runtime/env.go
+++ b/src/runtime/env.go
@@ -1,4 +1,4 @@
-//go:build linux || darwin || windows
+//go:build linux || darwin || windows || wasip1
package runtime
diff --git a/src/runtime/env_unix.go b/src/runtime/env_unix.go
index e205c14d6..42dfd5158 100644
--- a/src/runtime/env_unix.go
+++ b/src/runtime/env_unix.go
@@ -1,4 +1,4 @@
-//go:build linux || darwin
+//go:build linux || darwin || wasip1
package runtime
diff --git a/src/runtime/os_wasip1.go b/src/runtime/os_wasip1.go
new file mode 100644
index 000000000..bc233ffe8
--- /dev/null
+++ b/src/runtime/os_wasip1.go
@@ -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"
diff --git a/src/runtime/runtime_wasm_js.go b/src/runtime/runtime_wasm_js.go
index 443ed9e2e..18ca44abe 100644
--- a/src/runtime/runtime_wasm_js.go
+++ b/src/runtime/runtime_wasm_js.go
@@ -1,4 +1,4 @@
-//go:build wasm && !wasi
+//go:build wasm && !wasi && !wasip1
package runtime
diff --git a/src/runtime/runtime_wasm_js_scheduler.go b/src/runtime/runtime_wasm_js_scheduler.go
index 8f8823fef..fc599a2a8 100644
--- a/src/runtime/runtime_wasm_js_scheduler.go
+++ b/src/runtime/runtime_wasm_js_scheduler.go
@@ -1,4 +1,4 @@
-//go:build wasm && !wasi && !scheduler.none
+//go:build wasm && !wasi && !scheduler.none && !wasip1
package runtime
diff --git a/src/runtime/runtime_wasm_wasi.go b/src/runtime/runtime_wasm_wasi.go
index aec27e4c8..f258039ae 100644
--- a/src/runtime/runtime_wasm_wasi.go
+++ b/src/runtime/runtime_wasm_wasi.go
@@ -1,4 +1,4 @@
-//go:build tinygo.wasm && wasi
+//go:build tinygo.wasm && (wasi || wasip1)
package runtime
diff --git a/src/syscall/errno_other.go b/src/syscall/errno_other.go
index 19822a1c6..a00109652 100644
--- a/src/syscall/errno_other.go
+++ b/src/syscall/errno_other.go
@@ -1,4 +1,4 @@
-//go:build !wasi && !darwin
+//go:build !wasi && !wasip1 && !darwin
package syscall
diff --git a/src/syscall/file_emulated.go b/src/syscall/file_emulated.go
index f12d74e58..5ed57f13b 100644
--- a/src/syscall/file_emulated.go
+++ b/src/syscall/file_emulated.go
@@ -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.
diff --git a/src/syscall/file_hosted.go b/src/syscall/file_hosted.go
index 553322f02..d9198a779 100644
--- a/src/syscall/file_hosted.go
+++ b/src/syscall/file_hosted.go
@@ -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.
diff --git a/src/syscall/proc_emulated.go b/src/syscall/proc_emulated.go
index 46570f530..d8e7ff7a9 100644
--- a/src/syscall/proc_emulated.go
+++ b/src/syscall/proc_emulated.go
@@ -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.
diff --git a/src/syscall/proc_hosted.go b/src/syscall/proc_hosted.go
index ab35762d0..05c509e6f 100644
--- a/src/syscall/proc_hosted.go
+++ b/src/syscall/proc_hosted.go
@@ -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.
diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go
index ea0a000d1..7a13245b6 100644
--- a/src/syscall/syscall_libc.go
+++ b/src/syscall/syscall_libc.go
@@ -1,4 +1,4 @@
-//go:build darwin || nintendoswitch || wasi
+//go:build darwin || nintendoswitch || wasi || wasip1
package syscall
diff --git a/src/syscall/syscall_libc_wasi.go b/src/syscall/syscall_libc_wasi.go
index a3bd3a487..5e6a231df 100644
--- a/src/syscall/syscall_libc_wasi.go
+++ b/src/syscall/syscall_libc_wasi.go
@@ -1,4 +1,4 @@
-//go:build wasi
+//go:build wasi || wasip1
package syscall
diff --git a/src/testing/is_wasi_no_test.go b/src/testing/is_wasi_no_test.go
index 86fab391e..630467ec0 100644
--- a/src/testing/is_wasi_no_test.go
+++ b/src/testing/is_wasi_no_test.go
@@ -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
diff --git a/src/testing/is_wasi_test.go b/src/testing/is_wasi_test.go
index e50af901b..e20e15fc0 100644
--- a/src/testing/is_wasi_test.go
+++ b/src/testing/is_wasi_test.go
@@ -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