Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined: os.Chdir when compiling to wasm. Golang WASM / WASI and Tinygo WAI works fine. #4675

Open
gedw99 opened this issue Dec 31, 2024 · 0 comments
Labels
wasm WebAssembly

Comments

@gedw99
Copy link

gedw99 commented Dec 31, 2024

Hey all,

Figured its worth raising this as an issue, because its almost works :)

Its only tinygo WASM that fails.

Golang WASM and WASI works
Tinygo WASI works.


Full reproduction:

go version
go version go1.23.4 darwin/arm64

tinygo version
tinygo version 0.35.0 darwin/arm64 (using go version go1.23.4 and LLVM version 18.1.2)

package main

var (
	sdir      = flag.String("dir", ".", "directory for stuff")
)

func main() {
	flag.Parse()
	somedir, err := filepath.Abs(*sdir)
	if err != nil {
		log.Fatal("Directory:", err)
	}
	err = os.Chdir(somedir)
	if err != nil {
		log.Fatal("Set Directory:", err)
	}
}
--- golang wasm ---
GOOS=js GOARCH=wasm go build -o gowasm.wasm .

--- golang wasi ---
GOOS=wasip1 GOARCH=wasm go build -o gowasm.wasi .

--- tinygo wasm ---
tinygo build -o tinygo.wasm  -target wasm .
main.go:: undefined: os.Chdir

--- tinygo wasi ---
tinygo build -o tinygo.wasi -target wasi .

@deadprogram deadprogram added the wasm WebAssembly label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasm WebAssembly
Projects
None yet
Development

No branches or pull requests

2 participants