Skip to content

Commit fae0402

Browse files
committed
wasm-unknown: make sure the os package can be imported
See: #4314 The os package isn't particularly useful on wasm-unknown, but just like on baremetal systems it's imported by a lot of packages so it should at least be possible to import this package.
1 parent 4517a0c commit fae0402

16 files changed

+18
-16
lines changed

src/examples/hello-wasm-unknown/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// tinygo build -size short -o hello-unknown.wasm -target wasm-unknown -gc=leaking -no-debug ./src/examples/hello-wasm-unknown/
44
package main
55

6+
// Smoke test: make sure the fmt package can be imported (even if it isn't
7+
// really useful for wasm-unknown).
8+
import _ "os"
9+
610
var x int32
711

812
//go:wasmimport hosted echo_i32

src/os/dir_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build baremetal || js || windows
1+
//go:build baremetal || js || windows || wasm_unknown
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/dir_unix.go

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

5-
//go:build linux && !baremetal && !wasip1
5+
//go:build linux && !baremetal && !wasip1 && !wasm_unknown
66

77
package os
88

src/os/dirent_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !baremetal && !js && !wasip1
1+
//go:build !baremetal && !js && !wasip1 && !wasm_unknown
22

33
// Copyright 2020 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/file_anyos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !baremetal && !js
1+
//go:build !baremetal && !js && !wasm_unknown
22

33
// Portions copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/file_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build baremetal || (wasm && !wasip1)
1+
//go:build baremetal || (tinygo.wasm && !wasip1)
22

33
package os
44

src/os/file_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || (linux && !baremetal) || wasip1
1+
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1
22

33
// target wasi sets GOOS=linux and thus the +linux build tag,
44
// even though it doesn't show up in "tinygo info target -wasi"

src/os/removeall_noat.go

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

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

77
package os
88

src/os/removeall_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build baremetal || js || wasi || wasip1
1+
//go:build baremetal || js || wasi || wasip1 || wasm_unknown
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/stat_linuxlike.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build (linux && !baremetal) || wasip1
1+
//go:build (linux && !baremetal && !wasm_unknown) || wasip1
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/stat_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build baremetal || (wasm && !wasip1)
1+
//go:build baremetal || (tinygo.wasm && !wasip1)
22

33
// Copyright 2016 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/stat_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || (linux && !baremetal) || wasip1
1+
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1
22

33
// Copyright 2016 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/types_anyos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !baremetal && !js
1+
//go:build !baremetal && !js && !wasm_unknown
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/os/types_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build darwin || (linux && !baremetal) || wasip1
1+
//go:build darwin || (linux && !baremetal && !wasm_unknown) || wasip1
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

src/runtime/nonhosted.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build baremetal || js
1+
//go:build baremetal || js || wasm_unknown
22

33
package runtime
44

src/runtime/runtime_wasm_unknown.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ func init() {
2323
__wasm_call_ctors()
2424
}
2525

26-
var args []string
27-
2826
func ticksToNanoseconds(ticks timeUnit) int64 {
2927
return int64(ticks)
3028
}

0 commit comments

Comments
 (0)