From 47f433cd9fd61777663ce88eb47d57b0600e5736 Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Fri, 12 Aug 2022 16:38:41 +0800 Subject: [PATCH 1/6] feat:add new target to support wasm unknow --- src/os/dir_other.go | 4 +- src/os/dir_unix.go | 4 +- src/os/dirent_linux.go | 4 +- src/os/env_unix_test.go | 4 +- src/os/exec_posix.go | 4 +- src/os/executable_other.go | 4 +- src/os/executable_procfs.go | 4 +- src/os/file_anyos.go | 4 +- src/os/file_anyos_test.go | 4 +- src/os/file_other.go | 4 +- src/os/file_unix.go | 4 +- src/os/getpagesize_test.go | 4 +- src/os/os_anyos_test.go | 4 +- src/os/os_chmod_test.go | 4 +- src/os/os_symlink_test.go | 4 +- src/os/pipe_test.go | 4 +- src/os/read_test.go | 4 +- src/os/removeall_noat.go | 4 +- src/os/removeall_other.go | 4 +- src/os/removeall_test.go | 4 +- src/os/seek_unix_bad.go | 4 +- src/os/stat_linux.go | 4 +- src/os/stat_other.go | 4 +- src/os/stat_unix.go | 4 +- src/os/tempfile.go | 3 + src/os/tempfile_test.go | 4 +- src/os/types_anyos.go | 4 +- src/os/types_unix.go | 4 +- src/runtime/os_linux.go | 4 +- src/runtime/os_other.go | 4 +- src/runtime/runtime_tinygowasm.go | 4 +- src/runtime/runtime_unix.go | 4 +- src/runtime/runtime_wasm_js.go | 4 +- src/runtime/runtime_wasm_js_scheduler.go | 4 +- src/runtime/runtime_wasm_unknow.go | 78 ++++++++++++++++++++++++ src/runtime/runtime_wasm_wasi.go | 4 +- src/syscall/file_emulated.go | 4 +- src/syscall/file_hosted.go | 4 +- src/syscall/proc_emulated.go | 4 +- src/syscall/proc_hosted.go | 4 +- src/syscall/syscall_nonhosted.go | 4 +- src/syscall/tables_nonhosted.go | 4 +- targets/unknow_wasm.json | 24 ++++++++ 43 files changed, 185 insertions(+), 80 deletions(-) create mode 100644 src/runtime/runtime_wasm_unknow.go create mode 100644 targets/unknow_wasm.json diff --git a/src/os/dir_other.go b/src/os/dir_other.go index aebeed4e45..9a5d43454f 100644 --- a/src/os/dir_other.go +++ b/src/os/dir_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || wasi || windows -// +build baremetal js wasi windows +//go:build baremetal || js || wasi || windows || unknow_wasm +// +build baremetal js wasi windows unknow_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go index 659b612bbd..8dd34702f2 100644 --- a/src/os/dir_unix.go +++ b/src/os/dir_unix.go @@ -2,8 +2,8 @@ // 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 -// +build linux,!baremetal,!wasi +//go:build linux && !baremetal && !wasi && !unknow_wasm +// +build linux,!baremetal,!wasi,!unknow_wasm package os diff --git a/src/os/dirent_linux.go b/src/os/dirent_linux.go index c249f615a3..0fb15bb1c2 100644 --- a/src/os/dirent_linux.go +++ b/src/os/dirent_linux.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi -// +build !baremetal,!js,!wasi +//go:build !baremetal && !js && !wasi && !unknow_wasm +// +build !baremetal,!js,!wasi,!unknow_wasm // Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/env_unix_test.go b/src/os/env_unix_test.go index d567acf1ee..9b34697294 100644 --- a/src/os/env_unix_test.go +++ b/src/os/env_unix_test.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || linux -// +build darwin linux +//go:build darwin || (linux && !unknow_wasm) +// +build darwin linux,!unknow_wasm package os_test diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index f100d63174..59b55a2ed7 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -2,8 +2,8 @@ // 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 -// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || (linux && !unknow_wasm) || netbsd || openbsd || solaris || windows +// +build aix darwin dragonfly freebsd js,wasm linux,!unknow_wasm netbsd openbsd solaris windows package os diff --git a/src/os/executable_other.go b/src/os/executable_other.go index 4bf1f04236..b7da1ee382 100644 --- a/src/os/executable_other.go +++ b/src/os/executable_other.go @@ -1,5 +1,5 @@ -//go:build !linux || baremetal -// +build !linux baremetal +//go:build !linux || baremetal || unknow_wasm +// +build !linux baremetal unknow_wasm package os diff --git a/src/os/executable_procfs.go b/src/os/executable_procfs.go index cabe3744f2..6da291d107 100644 --- a/src/os/executable_procfs.go +++ b/src/os/executable_procfs.go @@ -4,8 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !baremetal -// +build linux,!baremetal +//go:build linux && !baremetal && !unknow_wasm +// +build linux,!baremetal,!unknow_wasm package os diff --git a/src/os/file_anyos.go b/src/os/file_anyos.go index 117f173f6f..4b9fbb3143 100644 --- a/src/os/file_anyos.go +++ b/src/os/file_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js -// +build !baremetal,!js +//go:build !baremetal && !js && !unknow_wasm +// +build !baremetal,!js,!unknow_wasm // Portions copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/file_anyos_test.go b/src/os/file_anyos_test.go index 25fcfd2817..1d3bb270c8 100644 --- a/src/os/file_anyos_test.go +++ b/src/os/file_anyos_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js -// +build !baremetal,!js +//go:build !baremetal && !js && !unknow_wasm +// +build !baremetal,!js,!unknow_wasm package os_test diff --git a/src/os/file_other.go b/src/os/file_other.go index 82c84e9581..73464dde05 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || (wasm && !wasi) -// +build baremetal wasm,!wasi +//go:build baremetal || unknow_wasm || (wasm && !wasi) +// +build baremetal unknow_wasm wasm,!wasi package os diff --git a/src/os/file_unix.go b/src/os/file_unix.go index a76f5ff132..017d2f37eb 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal) -// +build darwin linux,!baremetal +//go:build darwin || (linux && !baremetal && !unknow_wasm) +// +build darwin linux,!baremetal,!unknow_wasm // 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 bcba9643f8..0a9959f89d 100644 --- a/src/os/getpagesize_test.go +++ b/src/os/getpagesize_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal) -// +build windows darwin linux,!baremetal +//go:build windows || darwin || (linux && !baremetal && !unknow_wasm) +// +build windows darwin linux,!baremetal,!unknow_wasm package os_test diff --git a/src/os/os_anyos_test.go b/src/os/os_anyos_test.go index dd255fb466..8743a05fbf 100644 --- a/src/os/os_anyos_test.go +++ b/src/os/os_anyos_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal) -// +build windows darwin linux,!baremetal +//go:build windows || darwin || (linux && !baremetal && !unknow_wasm) +// +build windows darwin linux,!baremetal,!unknow_wasm package os_test diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go index 01ec7f662c..679638250a 100644 --- a/src/os/os_chmod_test.go +++ b/src/os/os_chmod_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi -// +build !baremetal,!js,!wasi +//go:build !baremetal && !js && !wasi && !unknow_wasm +// +build !baremetal,!js,!wasi,!unknow_wasm // 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 dd97479715..7f4bacd6f9 100644 --- a/src/os/os_symlink_test.go +++ b/src/os/os_symlink_test.go @@ -1,5 +1,5 @@ -//go:build !windows && !baremetal && !js && !wasi -// +build !windows,!baremetal,!js,!wasi +//go:build !windows && !baremetal && !js && !wasi && !unknow_wasm +// +build !windows,!baremetal,!js,!wasi,!unknow_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go index dcb9952846..5e6e05cee5 100644 --- a/src/os/pipe_test.go +++ b/src/os/pipe_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !wasi) -// +build windows darwin linux,!baremetal,!wasi +//go:build windows || darwin || (linux && !baremetal && !wasi && !unknow_wasm) +// +build windows darwin linux,!baremetal,!wasi,!unknow_wasm // Copyright 2021 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 0051f97636..36061bb17a 100644 --- a/src/os/read_test.go +++ b/src/os/read_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi -// +build !baremetal,!js,!wasi +//go:build !baremetal && !js && !wasi && !unknow_wasm +// +build !baremetal,!js,!wasi,!unknow_wasm // 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 8b41282be9..4c746a3fd2 100644 --- a/src/os/removeall_noat.go +++ b/src/os/removeall_noat.go @@ -2,8 +2,8 @@ // 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 -// +build !baremetal,!js,!wasi +//go:build !baremetal && !js && !wasi && !unknow_wasm +// +build !baremetal,!js,!wasi,!unknow_wasm package os diff --git a/src/os/removeall_other.go b/src/os/removeall_other.go index 41cb0f5444..cf20e83565 100644 --- a/src/os/removeall_other.go +++ b/src/os/removeall_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || wasi -// +build baremetal js wasi +//go:build baremetal || unknow_wasm || js || wasi +// +build baremetal unknow_wasm js wasi // 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_test.go b/src/os/removeall_test.go index 81e7f58f2b..e985f96bf0 100644 --- a/src/os/removeall_test.go +++ b/src/os/removeall_test.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !js && !wasi) -// +build darwin linux,!baremetal,!js,!wasi +//go:build darwin || (linux && !baremetal && !js && !wasi && !unknow_wasm) +// +build darwin linux,!baremetal,!js,!wasi,!unknow_wasm // TODO: implement ReadDir on windows diff --git a/src/os/seek_unix_bad.go b/src/os/seek_unix_bad.go index 13f1d98c20..f5d9b7d630 100644 --- a/src/os/seek_unix_bad.go +++ b/src/os/seek_unix_bad.go @@ -1,5 +1,5 @@ -//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi) -// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi +//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi && !unknow_wasm) +// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi,!unknow_wasm package os diff --git a/src/os/stat_linux.go b/src/os/stat_linux.go index d186926abd..0d981834e0 100644 --- a/src/os/stat_linux.go +++ b/src/os/stat_linux.go @@ -1,5 +1,5 @@ -//go:build linux && !baremetal -// +build linux,!baremetal +//go:build linux && !baremetal && !unknow_wasm +// +build linux,!baremetal,!unknow_wasm // 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_other.go b/src/os/stat_other.go index 5b574abbae..29fb5905bd 100644 --- a/src/os/stat_other.go +++ b/src/os/stat_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || (wasm && !wasi) -// +build baremetal wasm,!wasi +//go:build baremetal || unknow_wasm || (wasm && !wasi) +// +build baremetal unknow_wasm wasm,!wasi // 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 68f0168b74..b2e80dd2ce 100644 --- a/src/os/stat_unix.go +++ b/src/os/stat_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal) -// +build darwin linux,!baremetal +//go:build darwin || (linux && !baremetal && !unknow_wasm) +// +build darwin linux,!baremetal,!unknow_wasm // 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.go b/src/os/tempfile.go index 383d4c1815..16fcada004 100644 --- a/src/os/tempfile.go +++ b/src/os/tempfile.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !unknow_wasm +// +build !unknow_wasm + package os import ( diff --git a/src/os/tempfile_test.go b/src/os/tempfile_test.go index 7c3e706e35..240b0db8e7 100644 --- a/src/os/tempfile_test.go +++ b/src/os/tempfile_test.go @@ -2,8 +2,8 @@ // 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 -// +build !baremetal,!js,!wasi +//go:build !baremetal && !js && !wasi && !unknow_wasm +// +build !baremetal,!js,!wasi,!unknow_wasm package os_test diff --git a/src/os/types_anyos.go b/src/os/types_anyos.go index e8013cb4f7..c2fd21efc7 100644 --- a/src/os/types_anyos.go +++ b/src/os/types_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js -// +build !baremetal,!js +//go:build !baremetal && !js && !unknow_wasm +// +build !baremetal,!js,!unknow_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/types_unix.go b/src/os/types_unix.go index 095fabda73..857b32cd01 100644 --- a/src/os/types_unix.go +++ b/src/os/types_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal) -// +build darwin linux,!baremetal +//go:build darwin || (linux && !baremetal && !unknow_wasm) +// +build darwin linux,!baremetal,!unknow_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 8f15726587..50ddaa3bbc 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -1,5 +1,5 @@ -//go:build linux && !baremetal && !nintendoswitch && !wasi -// +build linux,!baremetal,!nintendoswitch,!wasi +//go:build linux && !baremetal && !nintendoswitch && !wasi && !unknow_wasm +// +build linux,!baremetal,!nintendoswitch,!wasi,!unknow_wasm package runtime diff --git a/src/runtime/os_other.go b/src/runtime/os_other.go index 93773e536f..b71fc63e98 100644 --- a/src/runtime/os_other.go +++ b/src/runtime/os_other.go @@ -1,6 +1,6 @@ -//go:build linux && (baremetal || nintendoswitch || wasi) +//go:build linux && (baremetal || nintendoswitch || wasi || unknow_wasm) // +build linux -// +build baremetal nintendoswitch wasi +// +build baremetal nintendoswitch wasi unknow_wasm // Other systems that aren't operating systems supported by the Go toolchain // need to pretend to be an existing operating system. Linux seems like a good diff --git a/src/runtime/runtime_tinygowasm.go b/src/runtime/runtime_tinygowasm.go index 73a9eddf9b..b854e5cf63 100644 --- a/src/runtime/runtime_tinygowasm.go +++ b/src/runtime/runtime_tinygowasm.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm -// +build tinygo.wasm +//go:build tinygo.wasm && !unknow_wasm +// +build tinygo.wasm,!unknow_wasm package runtime diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go index 604f21c6d2..1506a06e54 100644 --- a/src/runtime/runtime_unix.go +++ b/src/runtime/runtime_unix.go @@ -1,5 +1,5 @@ -//go:build (darwin || (linux && !baremetal && !wasi)) && !nintendoswitch -// +build darwin linux,!baremetal,!wasi +//go:build (darwin || (linux && !baremetal && !wasi && !unknow_wasm)) && !nintendoswitch +// +build darwin linux,!baremetal,!wasi,!unknow_wasm // +build !nintendoswitch package runtime diff --git a/src/runtime/runtime_wasm_js.go b/src/runtime/runtime_wasm_js.go index ecc9d73d39..58e61f5516 100644 --- a/src/runtime/runtime_wasm_js.go +++ b/src/runtime/runtime_wasm_js.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi -// +build wasm,!wasi +//go:build wasm && !wasi && !unknow_wasm +// +build wasm,!wasi,!unknow_wasm package runtime diff --git a/src/runtime/runtime_wasm_js_scheduler.go b/src/runtime/runtime_wasm_js_scheduler.go index ab80cf1d30..b2a0658757 100644 --- a/src/runtime/runtime_wasm_js_scheduler.go +++ b/src/runtime/runtime_wasm_js_scheduler.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi && !scheduler.none -// +build wasm,!wasi,!scheduler.none +//go:build wasm && !wasi && !unknow_wasm && !scheduler.none +// +build wasm,!wasi,!unknow_wasm,!scheduler.none package runtime diff --git a/src/runtime/runtime_wasm_unknow.go b/src/runtime/runtime_wasm_unknow.go new file mode 100644 index 0000000000..2eb1eb927c --- /dev/null +++ b/src/runtime/runtime_wasm_unknow.go @@ -0,0 +1,78 @@ +//go:build unknow_wasm +// +build unknow_wasm + +package runtime + +import ( + "unsafe" +) + +//export _start +func _start() { + // These need to be initialized early so that the heap can be initialized. + heapStart = uintptr(unsafe.Pointer(&heapStartSymbol)) + heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize) + run() +} + +// Abort executes the wasm 'unreachable' instruction. +func abort() { + trap() +} + +//go:linkname os_runtime_args os.runtime_args +func os_runtime_args() []string { + return []string{} +} + +//go:linkname syscall_runtime_envs syscall.runtime_envs +func syscall_runtime_envs() []string { + return []string{} +} + +func putchar(c byte) { +} + +func getchar() byte { + return 0 +} + +func buffered() int { + return 0 +} + +type timeUnit int64 + +func ticksToNanoseconds(ticks timeUnit) int64 { + panic("unimplemented: ticksToNanoseconds") +} + +func nanosecondsToTicks(ns int64) timeUnit { + panic("unimplemented: nanosecondsToTicks") +} + +func sleepTicks(d timeUnit) { + panic("unimplemented: sleepTicks") +} + +func ticks() timeUnit { + panic("unimplemented: ticks") +} + +//go:linkname now time.now +func now() (int64, int32, int64) { + panic("unimplemented: now") +} + +//go:linkname syscall_Exit syscall.Exit +func syscall_Exit(code int) { + return +} + +//go:linkname procPin sync/atomic.runtime_procPin +func procPin() { +} + +//go:linkname procUnpin sync/atomic.runtime_procUnpin +func procUnpin() { +} diff --git a/src/runtime/runtime_wasm_wasi.go b/src/runtime/runtime_wasm_wasi.go index 52fd79d61a..ebe42c925b 100644 --- a/src/runtime/runtime_wasm_wasi.go +++ b/src/runtime/runtime_wasm_wasi.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm && wasi -// +build tinygo.wasm,wasi +//go:build tinygo.wasm && wasi && !unknow_wasm +// +build tinygo.wasm,wasi,!unknow_wasm package runtime diff --git a/src/syscall/file_emulated.go b/src/syscall/file_emulated.go index b1859bb1bf..e91b00abd5 100644 --- a/src/syscall/file_emulated.go +++ b/src/syscall/file_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasm -// +build baremetal wasm +//go:build baremetal || wasm || unknow_wasm +// +build baremetal wasm unknow_wasm // 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 86fc62c408..c6415aa752 100644 --- a/src/syscall/file_hosted.go +++ b/src/syscall/file_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasm -// +build !baremetal,!wasm +//go:build !baremetal && !wasm && !unknow_wasm +// +build !baremetal,!wasm,!unknow_wasm // 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 4ed0b44c10..28e0d55fc8 100644 --- a/src/syscall/proc_emulated.go +++ b/src/syscall/proc_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasi || wasm -// +build baremetal wasi wasm +//go:build baremetal || wasi || wasm || unknow_wasm +// +build baremetal wasi wasm unknow_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 dd7c289ca6..04cedc3f9d 100644 --- a/src/syscall/proc_hosted.go +++ b/src/syscall/proc_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasi && !wasm -// +build !baremetal,!wasi,!wasm +//go:build !baremetal && !wasi && !wasm && !unknow_wasm +// +build !baremetal,!wasi,!wasm,!unknow_wasm // This file assumes there is a libc available that runs on a real operating // system. diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index 399e97428b..a02da50fc6 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -1,5 +1,5 @@ -//go:build baremetal || js -// +build baremetal js +//go:build baremetal || js || unknow_wasm +// +build baremetal js unknow_wasm package syscall diff --git a/src/syscall/tables_nonhosted.go b/src/syscall/tables_nonhosted.go index ae0c7cc573..b47412f49d 100644 --- a/src/syscall/tables_nonhosted.go +++ b/src/syscall/tables_nonhosted.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build baremetal || nintendoswitch || js -// +build baremetal nintendoswitch js +//go:build baremetal || nintendoswitch || js || unknow_wasm +// +build baremetal nintendoswitch js unknow_wasm package syscall diff --git a/targets/unknow_wasm.json b/targets/unknow_wasm.json new file mode 100644 index 0000000000..3e7997229f --- /dev/null +++ b/targets/unknow_wasm.json @@ -0,0 +1,24 @@ +{ + "llvm-target": "wasm32-unknown-unknown", + "cpu": "generic", + "features": "+bulk-memory,+nontrapping-fptoint,+sign-ext", + "build-tags": ["tinygo.wasm", "unknow_wasm", "runtime_memhash_leveldb"], + "goos": "linux", + "goarch": "arm", + "linker": "wasm-ld", + "libc": "", + "scheduler": "asyncify", + "default-stack-size": 16384, + "cflags": [ + "-mbulk-memory", + "-mnontrapping-fptoint", + "-msign-ext" + ], + "ldflags": [ + "--allow-undefined", + "--stack-first", + "--no-demangle" + ], + "emulator": "wasmtime {}", + "wasm-abi": "generic" +} From b69430c6e6850e96aca07aa47b15d62d86fc4a58 Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Mon, 22 Aug 2022 11:26:09 +0800 Subject: [PATCH 2/6] rename unknow to unknown --- src/os/dir_other.go | 4 ++-- src/os/dir_unix.go | 4 ++-- src/os/dirent_linux.go | 4 ++-- src/os/env_unix_test.go | 4 ++-- src/os/exec_posix.go | 4 ++-- src/os/executable_other.go | 4 ++-- src/os/executable_procfs.go | 4 ++-- src/os/file_anyos.go | 4 ++-- src/os/file_anyos_test.go | 4 ++-- src/os/file_other.go | 4 ++-- src/os/file_unix.go | 4 ++-- src/os/getpagesize_test.go | 4 ++-- src/os/os_anyos_test.go | 4 ++-- src/os/os_chmod_test.go | 4 ++-- src/os/os_symlink_test.go | 4 ++-- src/os/pipe_test.go | 4 ++-- src/os/read_test.go | 4 ++-- src/os/removeall_noat.go | 4 ++-- src/os/removeall_other.go | 4 ++-- src/os/removeall_test.go | 4 ++-- src/os/seek_unix_bad.go | 4 ++-- src/os/stat_other.go | 4 ++-- src/os/stat_unix.go | 4 ++-- src/os/tempfile.go | 4 ++-- src/os/tempfile_test.go | 4 ++-- src/os/types_anyos.go | 4 ++-- src/os/types_unix.go | 4 ++-- src/runtime/os_linux.go | 4 ++-- src/runtime/os_other.go | 4 ++-- src/runtime/runtime_tinygowasm.go | 4 ++-- src/runtime/runtime_unix.go | 4 ++-- src/runtime/runtime_wasm_js.go | 4 ++-- src/runtime/runtime_wasm_js_scheduler.go | 4 ++-- .../{runtime_wasm_unknow.go => runtime_wasm_unknown.go} | 4 ++-- src/runtime/runtime_wasm_wasi.go | 4 ++-- src/syscall/file_emulated.go | 4 ++-- src/syscall/file_hosted.go | 4 ++-- src/syscall/proc_emulated.go | 4 ++-- src/syscall/proc_hosted.go | 4 ++-- src/syscall/syscall_nonhosted.go | 4 ++-- src/syscall/tables_nonhosted.go | 4 ++-- targets/{unknow_wasm.json => unknown_wasm.json} | 2 +- 42 files changed, 83 insertions(+), 83 deletions(-) rename src/runtime/{runtime_wasm_unknow.go => runtime_wasm_unknown.go} (96%) rename targets/{unknow_wasm.json => unknown_wasm.json} (87%) diff --git a/src/os/dir_other.go b/src/os/dir_other.go index 9a5d43454f..832bd897fe 100644 --- a/src/os/dir_other.go +++ b/src/os/dir_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || wasi || windows || unknow_wasm -// +build baremetal js wasi windows unknow_wasm +//go:build baremetal || js || wasi || windows || unknown_wasm +// +build baremetal js wasi windows unknown_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go index 8dd34702f2..91e6065fa3 100644 --- a/src/os/dir_unix.go +++ b/src/os/dir_unix.go @@ -2,8 +2,8 @@ // 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 && !unknow_wasm -// +build linux,!baremetal,!wasi,!unknow_wasm +//go:build linux && !baremetal && !wasi && !unknown_wasm +// +build linux,!baremetal,!wasi,!unknown_wasm package os diff --git a/src/os/dirent_linux.go b/src/os/dirent_linux.go index 0fb15bb1c2..bda4550364 100644 --- a/src/os/dirent_linux.go +++ b/src/os/dirent_linux.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknow_wasm -// +build !baremetal,!js,!wasi,!unknow_wasm +//go:build !baremetal && !js && !wasi && !unknown_wasm +// +build !baremetal,!js,!wasi,!unknown_wasm // Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/env_unix_test.go b/src/os/env_unix_test.go index 9b34697294..fff8dce2bc 100644 --- a/src/os/env_unix_test.go +++ b/src/os/env_unix_test.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || (linux && !unknow_wasm) -// +build darwin linux,!unknow_wasm +//go:build darwin || (linux && !unknown_wasm) +// +build darwin linux,!unknown_wasm package os_test diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index 59b55a2ed7..83f1b952aa 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -2,8 +2,8 @@ // 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 && !unknow_wasm) || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux,!unknow_wasm netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || (linux && !unknown_wasm) || netbsd || openbsd || solaris || windows +// +build aix darwin dragonfly freebsd js,wasm linux,!unknown_wasm netbsd openbsd solaris windows package os diff --git a/src/os/executable_other.go b/src/os/executable_other.go index b7da1ee382..2c509b788b 100644 --- a/src/os/executable_other.go +++ b/src/os/executable_other.go @@ -1,5 +1,5 @@ -//go:build !linux || baremetal || unknow_wasm -// +build !linux baremetal unknow_wasm +//go:build !linux || baremetal || unknown_wasm +// +build !linux baremetal unknown_wasm package os diff --git a/src/os/executable_procfs.go b/src/os/executable_procfs.go index 6da291d107..82f9a39307 100644 --- a/src/os/executable_procfs.go +++ b/src/os/executable_procfs.go @@ -4,8 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !baremetal && !unknow_wasm -// +build linux,!baremetal,!unknow_wasm +//go:build linux && !baremetal && !unknown_wasm +// +build linux,!baremetal,!unknown_wasm package os diff --git a/src/os/file_anyos.go b/src/os/file_anyos.go index 4b9fbb3143..968df7d7c3 100644 --- a/src/os/file_anyos.go +++ b/src/os/file_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknow_wasm -// +build !baremetal,!js,!unknow_wasm +//go:build !baremetal && !js && !unknown_wasm +// +build !baremetal,!js,!unknown_wasm // Portions copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/file_anyos_test.go b/src/os/file_anyos_test.go index 1d3bb270c8..df95eeb722 100644 --- a/src/os/file_anyos_test.go +++ b/src/os/file_anyos_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknow_wasm -// +build !baremetal,!js,!unknow_wasm +//go:build !baremetal && !js && !unknown_wasm +// +build !baremetal,!js,!unknown_wasm package os_test diff --git a/src/os/file_other.go b/src/os/file_other.go index 73464dde05..0f822edf23 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknow_wasm || (wasm && !wasi) -// +build baremetal unknow_wasm wasm,!wasi +//go:build baremetal || unknown_wasm || (wasm && !wasi) +// +build baremetal unknown_wasm wasm,!wasi package os diff --git a/src/os/file_unix.go b/src/os/file_unix.go index 017d2f37eb..df9c8914f3 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknow_wasm) -// +build darwin linux,!baremetal,!unknow_wasm +//go:build darwin || (linux && !baremetal && !unknown_wasm) +// +build darwin linux,!baremetal,!unknown_wasm // 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 0a9959f89d..e6b32b69eb 100644 --- a/src/os/getpagesize_test.go +++ b/src/os/getpagesize_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !unknow_wasm) -// +build windows darwin linux,!baremetal,!unknow_wasm +//go:build windows || darwin || (linux && !baremetal && !unknown_wasm) +// +build windows darwin linux,!baremetal,!unknown_wasm package os_test diff --git a/src/os/os_anyos_test.go b/src/os/os_anyos_test.go index 8743a05fbf..285ed2eb67 100644 --- a/src/os/os_anyos_test.go +++ b/src/os/os_anyos_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !unknow_wasm) -// +build windows darwin linux,!baremetal,!unknow_wasm +//go:build windows || darwin || (linux && !baremetal && !unknown_wasm) +// +build windows darwin linux,!baremetal,!unknown_wasm package os_test diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go index 679638250a..abadac2938 100644 --- a/src/os/os_chmod_test.go +++ b/src/os/os_chmod_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknow_wasm -// +build !baremetal,!js,!wasi,!unknow_wasm +//go:build !baremetal && !js && !wasi && !unknown_wasm +// +build !baremetal,!js,!wasi,!unknown_wasm // 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 7f4bacd6f9..931f3bb034 100644 --- a/src/os/os_symlink_test.go +++ b/src/os/os_symlink_test.go @@ -1,5 +1,5 @@ -//go:build !windows && !baremetal && !js && !wasi && !unknow_wasm -// +build !windows,!baremetal,!js,!wasi,!unknow_wasm +//go:build !windows && !baremetal && !js && !wasi && !unknown_wasm +// +build !windows,!baremetal,!js,!wasi,!unknown_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go index 5e6e05cee5..f6b77ac4fe 100644 --- a/src/os/pipe_test.go +++ b/src/os/pipe_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !wasi && !unknow_wasm) -// +build windows darwin linux,!baremetal,!wasi,!unknow_wasm +//go:build windows || darwin || (linux && !baremetal && !wasi && !unknown_wasm) +// +build windows darwin linux,!baremetal,!wasi,!unknown_wasm // Copyright 2021 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 36061bb17a..68ea825949 100644 --- a/src/os/read_test.go +++ b/src/os/read_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknow_wasm -// +build !baremetal,!js,!wasi,!unknow_wasm +//go:build !baremetal && !js && !wasi && !unknown_wasm +// +build !baremetal,!js,!wasi,!unknown_wasm // 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 4c746a3fd2..b687af1731 100644 --- a/src/os/removeall_noat.go +++ b/src/os/removeall_noat.go @@ -2,8 +2,8 @@ // 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 && !unknow_wasm -// +build !baremetal,!js,!wasi,!unknow_wasm +//go:build !baremetal && !js && !wasi && !unknown_wasm +// +build !baremetal,!js,!wasi,!unknown_wasm package os diff --git a/src/os/removeall_other.go b/src/os/removeall_other.go index cf20e83565..7f501308fb 100644 --- a/src/os/removeall_other.go +++ b/src/os/removeall_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknow_wasm || js || wasi -// +build baremetal unknow_wasm js wasi +//go:build baremetal || unknown_wasm || js || wasi +// +build baremetal unknown_wasm js wasi // 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_test.go b/src/os/removeall_test.go index e985f96bf0..1e82c272b1 100644 --- a/src/os/removeall_test.go +++ b/src/os/removeall_test.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !js && !wasi && !unknow_wasm) -// +build darwin linux,!baremetal,!js,!wasi,!unknow_wasm +//go:build darwin || (linux && !baremetal && !js && !wasi && !unknown_wasm) +// +build darwin linux,!baremetal,!js,!wasi,!unknown_wasm // TODO: implement ReadDir on windows diff --git a/src/os/seek_unix_bad.go b/src/os/seek_unix_bad.go index f5d9b7d630..f863a27974 100644 --- a/src/os/seek_unix_bad.go +++ b/src/os/seek_unix_bad.go @@ -1,5 +1,5 @@ -//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi && !unknow_wasm) -// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi,!unknow_wasm +//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi && !unknown_wasm) +// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi,!unknown_wasm package os diff --git a/src/os/stat_other.go b/src/os/stat_other.go index 29fb5905bd..d4e13f837d 100644 --- a/src/os/stat_other.go +++ b/src/os/stat_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknow_wasm || (wasm && !wasi) -// +build baremetal unknow_wasm wasm,!wasi +//go:build baremetal || unknown_wasm || (wasm && !wasi) +// +build baremetal unknown_wasm wasm,!wasi // 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 b2e80dd2ce..3e90ddd122 100644 --- a/src/os/stat_unix.go +++ b/src/os/stat_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknow_wasm) -// +build darwin linux,!baremetal,!unknow_wasm +//go:build darwin || (linux && !baremetal && !unknown_wasm) +// +build darwin linux,!baremetal,!unknown_wasm // 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.go b/src/os/tempfile.go index 16fcada004..f744f0273d 100644 --- a/src/os/tempfile.go +++ b/src/os/tempfile.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !unknow_wasm -// +build !unknow_wasm +//go:build !unknown_wasm +// +build !unknown_wasm package os diff --git a/src/os/tempfile_test.go b/src/os/tempfile_test.go index 240b0db8e7..4d3eb2ce05 100644 --- a/src/os/tempfile_test.go +++ b/src/os/tempfile_test.go @@ -2,8 +2,8 @@ // 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 && !unknow_wasm -// +build !baremetal,!js,!wasi,!unknow_wasm +//go:build !baremetal && !js && !wasi && !unknown_wasm +// +build !baremetal,!js,!wasi,!unknown_wasm package os_test diff --git a/src/os/types_anyos.go b/src/os/types_anyos.go index c2fd21efc7..41fee8db12 100644 --- a/src/os/types_anyos.go +++ b/src/os/types_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknow_wasm -// +build !baremetal,!js,!unknow_wasm +//go:build !baremetal && !js && !unknown_wasm +// +build !baremetal,!js,!unknown_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/types_unix.go b/src/os/types_unix.go index 857b32cd01..50534a80bb 100644 --- a/src/os/types_unix.go +++ b/src/os/types_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknow_wasm) -// +build darwin linux,!baremetal,!unknow_wasm +//go:build darwin || (linux && !baremetal && !unknown_wasm) +// +build darwin linux,!baremetal,!unknown_wasm // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 50ddaa3bbc..7c51f484a3 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -1,5 +1,5 @@ -//go:build linux && !baremetal && !nintendoswitch && !wasi && !unknow_wasm -// +build linux,!baremetal,!nintendoswitch,!wasi,!unknow_wasm +//go:build linux && !baremetal && !nintendoswitch && !wasi && !unknown_wasm +// +build linux,!baremetal,!nintendoswitch,!wasi,!unknown_wasm package runtime diff --git a/src/runtime/os_other.go b/src/runtime/os_other.go index b71fc63e98..e0d375cb30 100644 --- a/src/runtime/os_other.go +++ b/src/runtime/os_other.go @@ -1,6 +1,6 @@ -//go:build linux && (baremetal || nintendoswitch || wasi || unknow_wasm) +//go:build linux && (baremetal || nintendoswitch || wasi || unknown_wasm) // +build linux -// +build baremetal nintendoswitch wasi unknow_wasm +// +build baremetal nintendoswitch wasi unknown_wasm // Other systems that aren't operating systems supported by the Go toolchain // need to pretend to be an existing operating system. Linux seems like a good diff --git a/src/runtime/runtime_tinygowasm.go b/src/runtime/runtime_tinygowasm.go index b854e5cf63..da3305a943 100644 --- a/src/runtime/runtime_tinygowasm.go +++ b/src/runtime/runtime_tinygowasm.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm && !unknow_wasm -// +build tinygo.wasm,!unknow_wasm +//go:build tinygo.wasm && !unknown_wasm +// +build tinygo.wasm,!unknown_wasm package runtime diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go index 1506a06e54..6063959e25 100644 --- a/src/runtime/runtime_unix.go +++ b/src/runtime/runtime_unix.go @@ -1,5 +1,5 @@ -//go:build (darwin || (linux && !baremetal && !wasi && !unknow_wasm)) && !nintendoswitch -// +build darwin linux,!baremetal,!wasi,!unknow_wasm +//go:build (darwin || (linux && !baremetal && !wasi && !unknown_wasm)) && !nintendoswitch +// +build darwin linux,!baremetal,!wasi,!unknown_wasm // +build !nintendoswitch package runtime diff --git a/src/runtime/runtime_wasm_js.go b/src/runtime/runtime_wasm_js.go index 58e61f5516..1f7bf5a2b3 100644 --- a/src/runtime/runtime_wasm_js.go +++ b/src/runtime/runtime_wasm_js.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi && !unknow_wasm -// +build wasm,!wasi,!unknow_wasm +//go:build wasm && !wasi && !unknown_wasm +// +build wasm,!wasi,!unknown_wasm package runtime diff --git a/src/runtime/runtime_wasm_js_scheduler.go b/src/runtime/runtime_wasm_js_scheduler.go index b2a0658757..534f673bd2 100644 --- a/src/runtime/runtime_wasm_js_scheduler.go +++ b/src/runtime/runtime_wasm_js_scheduler.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi && !unknow_wasm && !scheduler.none -// +build wasm,!wasi,!unknow_wasm,!scheduler.none +//go:build wasm && !wasi && !unknown_wasm && !scheduler.none +// +build wasm,!wasi,!unknown_wasm,!scheduler.none package runtime diff --git a/src/runtime/runtime_wasm_unknow.go b/src/runtime/runtime_wasm_unknown.go similarity index 96% rename from src/runtime/runtime_wasm_unknow.go rename to src/runtime/runtime_wasm_unknown.go index 2eb1eb927c..69d8a9a7f2 100644 --- a/src/runtime/runtime_wasm_unknow.go +++ b/src/runtime/runtime_wasm_unknown.go @@ -1,5 +1,5 @@ -//go:build unknow_wasm -// +build unknow_wasm +//go:build unknown_wasm +// +build unknown_wasm package runtime diff --git a/src/runtime/runtime_wasm_wasi.go b/src/runtime/runtime_wasm_wasi.go index ebe42c925b..1ecae905fd 100644 --- a/src/runtime/runtime_wasm_wasi.go +++ b/src/runtime/runtime_wasm_wasi.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm && wasi && !unknow_wasm -// +build tinygo.wasm,wasi,!unknow_wasm +//go:build tinygo.wasm && wasi && !unknown_wasm +// +build tinygo.wasm,wasi,!unknown_wasm package runtime diff --git a/src/syscall/file_emulated.go b/src/syscall/file_emulated.go index e91b00abd5..3687e8dd57 100644 --- a/src/syscall/file_emulated.go +++ b/src/syscall/file_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasm || unknow_wasm -// +build baremetal wasm unknow_wasm +//go:build baremetal || wasm || unknown_wasm +// +build baremetal wasm unknown_wasm // 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 c6415aa752..e980deb7bd 100644 --- a/src/syscall/file_hosted.go +++ b/src/syscall/file_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasm && !unknow_wasm -// +build !baremetal,!wasm,!unknow_wasm +//go:build !baremetal && !wasm && !unknown_wasm +// +build !baremetal,!wasm,!unknown_wasm // 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 28e0d55fc8..0176d337d0 100644 --- a/src/syscall/proc_emulated.go +++ b/src/syscall/proc_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasi || wasm || unknow_wasm -// +build baremetal wasi wasm unknow_wasm +//go:build baremetal || wasi || wasm || unknown_wasm +// +build baremetal wasi wasm unknown_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 04cedc3f9d..4e386d039d 100644 --- a/src/syscall/proc_hosted.go +++ b/src/syscall/proc_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasi && !wasm && !unknow_wasm -// +build !baremetal,!wasi,!wasm,!unknow_wasm +//go:build !baremetal && !wasi && !wasm && !unknown_wasm +// +build !baremetal,!wasi,!wasm,!unknown_wasm // This file assumes there is a libc available that runs on a real operating // system. diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index a02da50fc6..b35e122d4e 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || unknow_wasm -// +build baremetal js unknow_wasm +//go:build baremetal || js || unknown_wasm +// +build baremetal js unknown_wasm package syscall diff --git a/src/syscall/tables_nonhosted.go b/src/syscall/tables_nonhosted.go index b47412f49d..1a7173144f 100644 --- a/src/syscall/tables_nonhosted.go +++ b/src/syscall/tables_nonhosted.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build baremetal || nintendoswitch || js || unknow_wasm -// +build baremetal nintendoswitch js unknow_wasm +//go:build baremetal || nintendoswitch || js || unknown_wasm +// +build baremetal nintendoswitch js unknown_wasm package syscall diff --git a/targets/unknow_wasm.json b/targets/unknown_wasm.json similarity index 87% rename from targets/unknow_wasm.json rename to targets/unknown_wasm.json index 3e7997229f..a53cbf9901 100644 --- a/targets/unknow_wasm.json +++ b/targets/unknown_wasm.json @@ -2,7 +2,7 @@ "llvm-target": "wasm32-unknown-unknown", "cpu": "generic", "features": "+bulk-memory,+nontrapping-fptoint,+sign-ext", - "build-tags": ["tinygo.wasm", "unknow_wasm", "runtime_memhash_leveldb"], + "build-tags": ["tinygo.wasm", "unknown_wasm", "runtime_memhash_leveldb"], "goos": "linux", "goarch": "arm", "linker": "wasm-ld", From 6ebfdc16810c7dc01b6b1e8faabf1b7ee2d615c2 Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Mon, 29 Aug 2022 09:53:14 +0800 Subject: [PATCH 3/6] fix: change name to freestanding --- src/os/dir_other.go | 4 ++-- src/os/dir_unix.go | 4 ++-- src/os/dirent_linux.go | 4 ++-- src/os/env_unix_test.go | 4 ++-- src/os/exec_posix.go | 4 ++-- src/os/executable_other.go | 4 ++-- src/os/executable_procfs.go | 4 ++-- src/os/file_anyos.go | 4 ++-- src/os/file_anyos_test.go | 4 ++-- src/os/file_other.go | 4 ++-- src/os/file_unix.go | 4 ++-- src/os/getpagesize_test.go | 4 ++-- src/os/os_anyos_test.go | 4 ++-- src/os/os_chmod_test.go | 4 ++-- src/os/os_symlink_test.go | 4 ++-- src/os/pipe_test.go | 4 ++-- src/os/read_test.go | 4 ++-- src/os/removeall_noat.go | 4 ++-- src/os/removeall_other.go | 4 ++-- src/os/removeall_test.go | 4 ++-- src/os/seek_unix_bad.go | 4 ++-- src/os/stat_other.go | 4 ++-- src/os/stat_unix.go | 4 ++-- src/os/tempfile.go | 4 ++-- src/os/tempfile_test.go | 4 ++-- src/os/types_anyos.go | 4 ++-- src/os/types_unix.go | 4 ++-- src/runtime/os_linux.go | 4 ++-- src/runtime/os_other.go | 4 ++-- src/runtime/runtime_tinygowasm.go | 4 ++-- src/runtime/runtime_unix.go | 4 ++-- .../{runtime_wasm_unknown.go => runtime_wasm_freestanding.go} | 4 ++-- src/runtime/runtime_wasm_js.go | 4 ++-- src/runtime/runtime_wasm_js_scheduler.go | 4 ++-- src/runtime/runtime_wasm_wasi.go | 4 ++-- src/syscall/file_emulated.go | 4 ++-- src/syscall/file_hosted.go | 4 ++-- src/syscall/proc_emulated.go | 4 ++-- src/syscall/proc_hosted.go | 4 ++-- src/syscall/syscall_nonhosted.go | 4 ++-- src/syscall/tables_nonhosted.go | 4 ++-- targets/{unknown_wasm.json => wasm-freestanding.json} | 0 42 files changed, 82 insertions(+), 82 deletions(-) rename src/runtime/{runtime_wasm_unknown.go => runtime_wasm_freestanding.go} (95%) rename targets/{unknown_wasm.json => wasm-freestanding.json} (100%) diff --git a/src/os/dir_other.go b/src/os/dir_other.go index 832bd897fe..b169bca467 100644 --- a/src/os/dir_other.go +++ b/src/os/dir_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || wasi || windows || unknown_wasm -// +build baremetal js wasi windows unknown_wasm +//go:build baremetal || js || wasi || windows || wasm_freestanding +// +build baremetal js wasi windows wasm_freestanding // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/dir_unix.go b/src/os/dir_unix.go index 91e6065fa3..3ab5f73486 100644 --- a/src/os/dir_unix.go +++ b/src/os/dir_unix.go @@ -2,8 +2,8 @@ // 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 && !unknown_wasm -// +build linux,!baremetal,!wasi,!unknown_wasm +//go:build linux && !baremetal && !wasi && !wasm_freestanding +// +build linux,!baremetal,!wasi,!wasm_freestanding package os diff --git a/src/os/dirent_linux.go b/src/os/dirent_linux.go index bda4550364..355f92da2c 100644 --- a/src/os/dirent_linux.go +++ b/src/os/dirent_linux.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknown_wasm -// +build !baremetal,!js,!wasi,!unknown_wasm +//go:build !baremetal && !js && !wasi && !wasm_freestanding +// +build !baremetal,!js,!wasi,!wasm_freestanding // Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/env_unix_test.go b/src/os/env_unix_test.go index fff8dce2bc..8118a2c3da 100644 --- a/src/os/env_unix_test.go +++ b/src/os/env_unix_test.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build darwin || (linux && !unknown_wasm) -// +build darwin linux,!unknown_wasm +//go:build darwin || (linux && !wasm_freestanding) +// +build darwin linux,!wasm_freestanding package os_test diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go index 83f1b952aa..cd64dc4ff0 100644 --- a/src/os/exec_posix.go +++ b/src/os/exec_posix.go @@ -2,8 +2,8 @@ // 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 && !unknown_wasm) || netbsd || openbsd || solaris || windows -// +build aix darwin dragonfly freebsd js,wasm linux,!unknown_wasm netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || (linux && !wasm_freestanding) || netbsd || openbsd || solaris || windows +// +build aix darwin dragonfly freebsd js,wasm linux,!wasm_freestanding netbsd openbsd solaris windows package os diff --git a/src/os/executable_other.go b/src/os/executable_other.go index 2c509b788b..97757d47db 100644 --- a/src/os/executable_other.go +++ b/src/os/executable_other.go @@ -1,5 +1,5 @@ -//go:build !linux || baremetal || unknown_wasm -// +build !linux baremetal unknown_wasm +//go:build !linux || baremetal || wasm_freestanding +// +build !linux baremetal wasm_freestanding package os diff --git a/src/os/executable_procfs.go b/src/os/executable_procfs.go index 82f9a39307..47b15c5633 100644 --- a/src/os/executable_procfs.go +++ b/src/os/executable_procfs.go @@ -4,8 +4,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !baremetal && !unknown_wasm -// +build linux,!baremetal,!unknown_wasm +//go:build linux && !baremetal && !wasm_freestanding +// +build linux,!baremetal,!wasm_freestanding package os diff --git a/src/os/file_anyos.go b/src/os/file_anyos.go index 968df7d7c3..29077591c8 100644 --- a/src/os/file_anyos.go +++ b/src/os/file_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknown_wasm -// +build !baremetal,!js,!unknown_wasm +//go:build !baremetal && !js && !wasm_freestanding +// +build !baremetal,!js,!wasm_freestanding // Portions copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/file_anyos_test.go b/src/os/file_anyos_test.go index df95eeb722..953f6f399e 100644 --- a/src/os/file_anyos_test.go +++ b/src/os/file_anyos_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknown_wasm -// +build !baremetal,!js,!unknown_wasm +//go:build !baremetal && !js && !wasm_freestanding +// +build !baremetal,!js,!wasm_freestanding package os_test diff --git a/src/os/file_other.go b/src/os/file_other.go index 0f822edf23..3c5318e5b0 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknown_wasm || (wasm && !wasi) -// +build baremetal unknown_wasm wasm,!wasi +//go:build baremetal || wasm_freestanding || (wasm && !wasi) +// +build baremetal wasm_freestanding wasm,!wasi package os diff --git a/src/os/file_unix.go b/src/os/file_unix.go index df9c8914f3..441d627fdc 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknown_wasm) -// +build darwin linux,!baremetal,!unknown_wasm +//go:build darwin || (linux && !baremetal && !wasm_freestanding) +// +build darwin linux,!baremetal,!wasm_freestanding // 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 e6b32b69eb..6f513c8794 100644 --- a/src/os/getpagesize_test.go +++ b/src/os/getpagesize_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !unknown_wasm) -// +build windows darwin linux,!baremetal,!unknown_wasm +//go:build windows || darwin || (linux && !baremetal && !wasm_freestanding) +// +build windows darwin linux,!baremetal,!wasm_freestanding package os_test diff --git a/src/os/os_anyos_test.go b/src/os/os_anyos_test.go index 285ed2eb67..653a96a9c0 100644 --- a/src/os/os_anyos_test.go +++ b/src/os/os_anyos_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !unknown_wasm) -// +build windows darwin linux,!baremetal,!unknown_wasm +//go:build windows || darwin || (linux && !baremetal && !wasm_freestanding) +// +build windows darwin linux,!baremetal,!wasm_freestanding package os_test diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go index abadac2938..9163d10328 100644 --- a/src/os/os_chmod_test.go +++ b/src/os/os_chmod_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknown_wasm -// +build !baremetal,!js,!wasi,!unknown_wasm +//go:build !baremetal && !js && !wasi && !wasm_freestanding +// +build !baremetal,!js,!wasi,!wasm_freestanding // 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 931f3bb034..407f64a9da 100644 --- a/src/os/os_symlink_test.go +++ b/src/os/os_symlink_test.go @@ -1,5 +1,5 @@ -//go:build !windows && !baremetal && !js && !wasi && !unknown_wasm -// +build !windows,!baremetal,!js,!wasi,!unknown_wasm +//go:build !windows && !baremetal && !js && !wasi && !wasm_freestanding +// +build !windows,!baremetal,!js,!wasi,!wasm_freestanding // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go index f6b77ac4fe..0895b85f7a 100644 --- a/src/os/pipe_test.go +++ b/src/os/pipe_test.go @@ -1,5 +1,5 @@ -//go:build windows || darwin || (linux && !baremetal && !wasi && !unknown_wasm) -// +build windows darwin linux,!baremetal,!wasi,!unknown_wasm +//go:build windows || darwin || (linux && !baremetal && !wasi && !wasm_freestanding) +// +build windows darwin linux,!baremetal,!wasi,!wasm_freestanding // Copyright 2021 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 68ea825949..745b93559a 100644 --- a/src/os/read_test.go +++ b/src/os/read_test.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !wasi && !unknown_wasm -// +build !baremetal,!js,!wasi,!unknown_wasm +//go:build !baremetal && !js && !wasi && !wasm_freestanding +// +build !baremetal,!js,!wasi,!wasm_freestanding // 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 b687af1731..7110dd3d16 100644 --- a/src/os/removeall_noat.go +++ b/src/os/removeall_noat.go @@ -2,8 +2,8 @@ // 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 && !unknown_wasm -// +build !baremetal,!js,!wasi,!unknown_wasm +//go:build !baremetal && !js && !wasi && !wasm_freestanding +// +build !baremetal,!js,!wasi,!wasm_freestanding package os diff --git a/src/os/removeall_other.go b/src/os/removeall_other.go index 7f501308fb..fc35a6cc94 100644 --- a/src/os/removeall_other.go +++ b/src/os/removeall_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknown_wasm || js || wasi -// +build baremetal unknown_wasm js wasi +//go:build baremetal || wasm_freestanding || js || wasi +// +build baremetal wasm_freestanding js wasi // 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_test.go b/src/os/removeall_test.go index 1e82c272b1..3dd2e642ef 100644 --- a/src/os/removeall_test.go +++ b/src/os/removeall_test.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !js && !wasi && !unknown_wasm) -// +build darwin linux,!baremetal,!js,!wasi,!unknown_wasm +//go:build darwin || (linux && !baremetal && !js && !wasi && !wasm_freestanding) +// +build darwin linux,!baremetal,!js,!wasi,!wasm_freestanding // TODO: implement ReadDir on windows diff --git a/src/os/seek_unix_bad.go b/src/os/seek_unix_bad.go index f863a27974..625fd55055 100644 --- a/src/os/seek_unix_bad.go +++ b/src/os/seek_unix_bad.go @@ -1,5 +1,5 @@ -//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi && !unknown_wasm) -// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi,!unknown_wasm +//go:build (linux && !baremetal && 386) || (linux && !baremetal && arm && !wasi && !wasm_freestanding) +// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi,!wasm_freestanding package os diff --git a/src/os/stat_other.go b/src/os/stat_other.go index d4e13f837d..2aec486291 100644 --- a/src/os/stat_other.go +++ b/src/os/stat_other.go @@ -1,5 +1,5 @@ -//go:build baremetal || unknown_wasm || (wasm && !wasi) -// +build baremetal unknown_wasm wasm,!wasi +//go:build baremetal || wasm_freestanding || (wasm && !wasi) +// +build baremetal wasm_freestanding wasm,!wasi // 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 3e90ddd122..9d3794ae83 100644 --- a/src/os/stat_unix.go +++ b/src/os/stat_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknown_wasm) -// +build darwin linux,!baremetal,!unknown_wasm +//go:build darwin || (linux && !baremetal && !wasm_freestanding) +// +build darwin linux,!baremetal,!wasm_freestanding // 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.go b/src/os/tempfile.go index f744f0273d..6343cfb64a 100644 --- a/src/os/tempfile.go +++ b/src/os/tempfile.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !unknown_wasm -// +build !unknown_wasm +//go:build !wasm_freestanding +// +build !wasm_freestanding package os diff --git a/src/os/tempfile_test.go b/src/os/tempfile_test.go index 4d3eb2ce05..cd200d9eec 100644 --- a/src/os/tempfile_test.go +++ b/src/os/tempfile_test.go @@ -2,8 +2,8 @@ // 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 && !unknown_wasm -// +build !baremetal,!js,!wasi,!unknown_wasm +//go:build !baremetal && !js && !wasi && !wasm_freestanding +// +build !baremetal,!js,!wasi,!wasm_freestanding package os_test diff --git a/src/os/types_anyos.go b/src/os/types_anyos.go index 41fee8db12..19f87d68af 100644 --- a/src/os/types_anyos.go +++ b/src/os/types_anyos.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !js && !unknown_wasm -// +build !baremetal,!js,!unknown_wasm +//go:build !baremetal && !js && !wasm_freestanding +// +build !baremetal,!js,!wasm_freestanding // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/os/types_unix.go b/src/os/types_unix.go index 50534a80bb..050eb4358b 100644 --- a/src/os/types_unix.go +++ b/src/os/types_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || (linux && !baremetal && !unknown_wasm) -// +build darwin linux,!baremetal,!unknown_wasm +//go:build darwin || (linux && !baremetal && !wasm_freestanding) +// +build darwin linux,!baremetal,!wasm_freestanding // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 7c51f484a3..ca0d8feed7 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -1,5 +1,5 @@ -//go:build linux && !baremetal && !nintendoswitch && !wasi && !unknown_wasm -// +build linux,!baremetal,!nintendoswitch,!wasi,!unknown_wasm +//go:build linux && !baremetal && !nintendoswitch && !wasi && !wasm_freestanding +// +build linux,!baremetal,!nintendoswitch,!wasi,!wasm_freestanding package runtime diff --git a/src/runtime/os_other.go b/src/runtime/os_other.go index e0d375cb30..e1f7e5111d 100644 --- a/src/runtime/os_other.go +++ b/src/runtime/os_other.go @@ -1,6 +1,6 @@ -//go:build linux && (baremetal || nintendoswitch || wasi || unknown_wasm) +//go:build linux && (baremetal || nintendoswitch || wasi || wasm_freestanding) // +build linux -// +build baremetal nintendoswitch wasi unknown_wasm +// +build baremetal nintendoswitch wasi wasm_freestanding // Other systems that aren't operating systems supported by the Go toolchain // need to pretend to be an existing operating system. Linux seems like a good diff --git a/src/runtime/runtime_tinygowasm.go b/src/runtime/runtime_tinygowasm.go index da3305a943..efba1b8995 100644 --- a/src/runtime/runtime_tinygowasm.go +++ b/src/runtime/runtime_tinygowasm.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm && !unknown_wasm -// +build tinygo.wasm,!unknown_wasm +//go:build tinygo.wasm && !wasm_freestanding +// +build tinygo.wasm,!wasm_freestanding package runtime diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go index 6063959e25..1a4f7523f3 100644 --- a/src/runtime/runtime_unix.go +++ b/src/runtime/runtime_unix.go @@ -1,5 +1,5 @@ -//go:build (darwin || (linux && !baremetal && !wasi && !unknown_wasm)) && !nintendoswitch -// +build darwin linux,!baremetal,!wasi,!unknown_wasm +//go:build (darwin || (linux && !baremetal && !wasi && !wasm_freestanding)) && !nintendoswitch +// +build darwin linux,!baremetal,!wasi,!wasm_freestanding // +build !nintendoswitch package runtime diff --git a/src/runtime/runtime_wasm_unknown.go b/src/runtime/runtime_wasm_freestanding.go similarity index 95% rename from src/runtime/runtime_wasm_unknown.go rename to src/runtime/runtime_wasm_freestanding.go index 69d8a9a7f2..37ffe6965b 100644 --- a/src/runtime/runtime_wasm_unknown.go +++ b/src/runtime/runtime_wasm_freestanding.go @@ -1,5 +1,5 @@ -//go:build unknown_wasm -// +build unknown_wasm +//go:build wasm_freestanding +// +build wasm_freestanding package runtime diff --git a/src/runtime/runtime_wasm_js.go b/src/runtime/runtime_wasm_js.go index 1f7bf5a2b3..47368c9806 100644 --- a/src/runtime/runtime_wasm_js.go +++ b/src/runtime/runtime_wasm_js.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi && !unknown_wasm -// +build wasm,!wasi,!unknown_wasm +//go:build wasm && !wasi && !wasm_freestanding +// +build wasm,!wasi,!wasm_freestanding package runtime diff --git a/src/runtime/runtime_wasm_js_scheduler.go b/src/runtime/runtime_wasm_js_scheduler.go index 534f673bd2..2826718450 100644 --- a/src/runtime/runtime_wasm_js_scheduler.go +++ b/src/runtime/runtime_wasm_js_scheduler.go @@ -1,5 +1,5 @@ -//go:build wasm && !wasi && !unknown_wasm && !scheduler.none -// +build wasm,!wasi,!unknown_wasm,!scheduler.none +//go:build wasm && !wasi && !wasm_freestanding && !scheduler.none +// +build wasm,!wasi,!wasm_freestanding,!scheduler.none package runtime diff --git a/src/runtime/runtime_wasm_wasi.go b/src/runtime/runtime_wasm_wasi.go index 1ecae905fd..c25d0bc5bb 100644 --- a/src/runtime/runtime_wasm_wasi.go +++ b/src/runtime/runtime_wasm_wasi.go @@ -1,5 +1,5 @@ -//go:build tinygo.wasm && wasi && !unknown_wasm -// +build tinygo.wasm,wasi,!unknown_wasm +//go:build tinygo.wasm && wasi && !wasm_freestanding +// +build tinygo.wasm,wasi,!wasm_freestanding package runtime diff --git a/src/syscall/file_emulated.go b/src/syscall/file_emulated.go index 3687e8dd57..992516850b 100644 --- a/src/syscall/file_emulated.go +++ b/src/syscall/file_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasm || unknown_wasm -// +build baremetal wasm unknown_wasm +//go:build baremetal || wasm || wasm_freestanding +// +build baremetal wasm wasm_freestanding // 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 e980deb7bd..bdcaa9808c 100644 --- a/src/syscall/file_hosted.go +++ b/src/syscall/file_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasm && !unknown_wasm -// +build !baremetal,!wasm,!unknown_wasm +//go:build !baremetal && !wasm && !wasm_freestanding +// +build !baremetal,!wasm,!wasm_freestanding // 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 0176d337d0..9bf1530150 100644 --- a/src/syscall/proc_emulated.go +++ b/src/syscall/proc_emulated.go @@ -1,5 +1,5 @@ -//go:build baremetal || wasi || wasm || unknown_wasm -// +build baremetal wasi wasm unknown_wasm +//go:build baremetal || wasi || wasm || wasm_freestanding +// +build baremetal wasi wasm wasm_freestanding // 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 4e386d039d..e0aa4f8c05 100644 --- a/src/syscall/proc_hosted.go +++ b/src/syscall/proc_hosted.go @@ -1,5 +1,5 @@ -//go:build !baremetal && !wasi && !wasm && !unknown_wasm -// +build !baremetal,!wasi,!wasm,!unknown_wasm +//go:build !baremetal && !wasi && !wasm && !wasm_freestanding +// +build !baremetal,!wasi,!wasm,!wasm_freestanding // This file assumes there is a libc available that runs on a real operating // system. diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index b35e122d4e..315d2fa5ae 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || unknown_wasm -// +build baremetal js unknown_wasm +//go:build baremetal || js || wasm_freestanding +// +build baremetal js wasm_freestanding package syscall diff --git a/src/syscall/tables_nonhosted.go b/src/syscall/tables_nonhosted.go index 1a7173144f..49b1a7dd8d 100644 --- a/src/syscall/tables_nonhosted.go +++ b/src/syscall/tables_nonhosted.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build baremetal || nintendoswitch || js || unknown_wasm -// +build baremetal nintendoswitch js unknown_wasm +//go:build baremetal || nintendoswitch || js || wasm_freestanding +// +build baremetal nintendoswitch js wasm_freestanding package syscall diff --git a/targets/unknown_wasm.json b/targets/wasm-freestanding.json similarity index 100% rename from targets/unknown_wasm.json rename to targets/wasm-freestanding.json From c2235d39dbbb9de4e5593d5c43e3029ab08f5d7a Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Mon, 29 Aug 2022 11:03:43 +0800 Subject: [PATCH 4/6] feat: make std read return EOF for wasm freestanding --- src/os/file_other.go | 5 +++++ src/runtime/runtime_wasm_freestanding.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/os/file_other.go b/src/os/file_other.go index 3c5318e5b0..35746a5823 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -4,6 +4,7 @@ package os import ( + "io" _ "unsafe" ) @@ -46,6 +47,10 @@ func (f stdioFileHandle) Read(b []byte) (n int, err error) { } size := buffered() + if size < 0 { + return 0, io.EOF + } + for size == 0 { gosched() size = buffered() diff --git a/src/runtime/runtime_wasm_freestanding.go b/src/runtime/runtime_wasm_freestanding.go index 37ffe6965b..8e02300728 100644 --- a/src/runtime/runtime_wasm_freestanding.go +++ b/src/runtime/runtime_wasm_freestanding.go @@ -38,7 +38,7 @@ func getchar() byte { } func buffered() int { - return 0 + return -1 } type timeUnit int64 From 136adc3e791a595583410fdfafc6e3185df75615 Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Mon, 29 Aug 2022 11:21:43 +0800 Subject: [PATCH 5/6] feat: remove Singal in wasm freestanding --- src/os/file_other.go | 4 ++++ src/syscall/syscall_nonhosted.go | 4 ++-- src/syscall/tables_nonhosted.go | 4 ++-- targets/wasm-freestanding.json | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/os/file_other.go b/src/os/file_other.go index 35746a5823..288c4b9954 100644 --- a/src/os/file_other.go +++ b/src/os/file_other.go @@ -42,6 +42,10 @@ func NewFile(fd uintptr, name string) *File { // Read reads up to len(b) bytes from machine.Serial. // It returns the number of bytes read and any error encountered. func (f stdioFileHandle) Read(b []byte) (n int, err error) { + if f != 0 { + return 0, ErrUnsupported + } + if len(b) == 0 { return 0, nil } diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index 315d2fa5ae..399e97428b 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -1,5 +1,5 @@ -//go:build baremetal || js || wasm_freestanding -// +build baremetal js wasm_freestanding +//go:build baremetal || js +// +build baremetal js package syscall diff --git a/src/syscall/tables_nonhosted.go b/src/syscall/tables_nonhosted.go index 49b1a7dd8d..ae0c7cc573 100644 --- a/src/syscall/tables_nonhosted.go +++ b/src/syscall/tables_nonhosted.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build baremetal || nintendoswitch || js || wasm_freestanding -// +build baremetal nintendoswitch js wasm_freestanding +//go:build baremetal || nintendoswitch || js +// +build baremetal nintendoswitch js package syscall diff --git a/targets/wasm-freestanding.json b/targets/wasm-freestanding.json index a53cbf9901..f5017affe0 100644 --- a/targets/wasm-freestanding.json +++ b/targets/wasm-freestanding.json @@ -2,7 +2,7 @@ "llvm-target": "wasm32-unknown-unknown", "cpu": "generic", "features": "+bulk-memory,+nontrapping-fptoint,+sign-ext", - "build-tags": ["tinygo.wasm", "unknown_wasm", "runtime_memhash_leveldb"], + "build-tags": ["tinygo.wasm", "wasm_freestanding", "runtime_memhash_leveldb"], "goos": "linux", "goarch": "arm", "linker": "wasm-ld", From c0b37f4f2ec77989fd8c19e0eb143b78b3820d61 Mon Sep 17 00:00:00 2001 From: hunjixin <1084400399@qq.com> Date: Thu, 29 Sep 2022 20:37:41 +0800 Subject: [PATCH 6/6] fix wrong wasm directive --- src/os/stat_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/stat_linux.go b/src/os/stat_linux.go index 0d981834e0..1c657a9264 100644 --- a/src/os/stat_linux.go +++ b/src/os/stat_linux.go @@ -1,5 +1,5 @@ -//go:build linux && !baremetal && !unknow_wasm -// +build linux,!baremetal,!unknow_wasm +//go:build linux && !baremetal && !wasm_freestanding +// +build linux,!baremetal,!wasm_freestanding // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style