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

methods not declared by package os #2910

Open
etsai-stripe opened this issue Jun 15, 2022 · 5 comments
Open

methods not declared by package os #2910

etsai-stripe opened this issue Jun 15, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@etsai-stripe
Copy link

i am able to build my web assembly by

GOOS=js GOARCH=wasm go build -tags wasm -o main.wasm cmd/stripe/main_wasm.go

but when i ran tinygo build -o main.wasm -target wasm cmd/stripe/main_wasm.go

i got the following error

# github.com/spf13/afero
../../go/pkg/mod/github.com/spf13/afero@v1.6.0/os.go:83:12: Rename not declared by package os
../../go/pkg/mod/github.com/spf13/afero@v1.6.0/os.go:91:12: Chmod not declared by package os
../../go/pkg/mod/github.com/spf13/afero@v1.6.0/os.go:95:12: Chown not declared by package os
../../go/pkg/mod/github.com/spf13/afero@v1.6.0/os.go:99:12: Chtimes not declared by package os
../../go/pkg/mod/github.com/spf13/afero@v1.6.0/os.go:108:12: Symlink not declared by package os

go version: go version go1.17.2 darwin/amd64
tinygo version: tinygo version 0.23.0 darwin/amd64 (using go version go1.17.2 and LLVM version 14.0.0)

please advice
thanks!

@dkegel-fastly
Copy link
Contributor

What version of tinygo are you using? 0.23 should have Rename, Chmod, and Symlink.

Here's the pull request that added Rename:
#2481

You could contribute stubs for Chown and Chtimes, they're not that hard to write!
Here's an example of how to write a stub:

#2313

@etsai-stripe
Copy link
Author

thank you @dkegel-fastly !

@deadprogram deadprogram added the enhancement New feature or request label Jun 17, 2022
@mar1n3r0
Copy link

mar1n3r0 commented Oct 9, 2022

Symlink not declared in version 0.26 also in the example from @etsai-stripe which is 0.23 and supposed to have the implementation. What are we missing?

tinygo version 0.26.0 linux/amd64 (using go version go1.19.2 and LLVM version 14.0.0)

Seems like it's been implemented for unix only while the wasm target is not covered by file_other.go

Here is what happens if I copy the Symlink implementation from https://github.com/tinygo-org/tinygo/blob/release/src/os/file_unix.go

tinygo build -o web.wasm -target wasm main.go
undeclared name: ignoringEINTR
Symlink not declared by package syscall

And with WASI:

tinygo build -wasm-abi=generic -target=wasi -o web.wasm main.go
../../../../../usr/lib/go-1.19/src/os/user/cgo_lookup_unix.go:18:6: not implemented: build constraints in #cgo line
../../../../../usr/lib/go-1.19/src/os/user/cgo_lookup_unix.go:21:10: fatal: 'pwd.h' file not found
../../../../../usr/lib/go-1.19/src/os/user/getgrouplist_unix.go:12:10: fatal: 'grp.h' file not found

Depends on WASI: golang/go#31105

@dkegel-fastly
Copy link
Contributor

I haven't checked whether wasi really supports symlink, but I guess it could at least be a stub...

@mar1n3r0
Copy link

mar1n3r0 commented Oct 10, 2022

I haven't checked whether wasi really supports symlink, but I guess it could at least be a stub...

https://docs.rs/wasi/0.9.0+wasi-snapshot-preview1/wasi/fn.path_symlink.html

I can't see any of the os packages related to file that is targeting a wasi build though. I have seen the implementation in file_unix.go and noticed that file_other.go is targeting wasm but not wasi. Where should I look for that in tinygo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants