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

tinygo cgo compile error #3044

Open
halfrost opened this issue Aug 3, 2022 · 5 comments
Open

tinygo cgo compile error #3044

halfrost opened this issue Aug 3, 2022 · 5 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request reflection Needs further work on reflection

Comments

@halfrost
Copy link

halfrost commented Aug 3, 2022

hen I use tinygo to compile wasm plugin:

$ tinygo build -o main.wasm -scheduler=none -target=wasi main.go

compile error. The error log is:

# os/user
../../../../opt/Cellar/go/1.17.2/libexec/src/os/user/cgo_lookup_unix.go:21:6: not implemented: build constraints in #cgo line
../../../../opt/Cellar/go/1.17.2/libexec/src/os/user/cgo_lookup_unix.go:24:10: fatal: 'pwd.h' file not found
../../../../opt/Cellar/go/1.17.2/libexec/src/os/user/getgrouplist_unix.go:15:10: fatal: 'grp.h' file not found

Once I disabled the cgo compile parameters,

$ CGO_ENABLED=0 tinygo build -o main.wasm -scheduler=none -target=wasi main.go

The error log is:

# github.com/cespare/xxhash/v2
../../pkg/mod/github.com/cespare/xxhash/[email protected]/xxhash_unsafe.go:32:11: cannot use len(s) (value of type int) as uintptr value in assignment
../../pkg/mod/github.com/cespare/xxhash/[email protected]/xxhash_unsafe.go:33:11: cannot use len(s) (value of type int) as uintptr value in assignment
../../pkg/mod/github.com/cespare/xxhash/[email protected]/xxhash_unsafe.go:43:11: cannot use len(s) (value of type int) as uintptr value in assignment
../../pkg/mod/github.com/cespare/xxhash/[email protected]/xxhash_unsafe.go:44:11: cannot use len(s) (value of type int) as uintptr value in assignment

My dependencies include prometheus and etcd. Both of their dependencies include xxhash. Is there any good idea?

@dgryski
Copy link
Member

dgryski commented Aug 3, 2022

Try building with -tags=appengine to get a safe version of xxhash.

@halfrost
Copy link
Author

halfrost commented Aug 3, 2022

@dgryski I try this command:

CGO_ENABLED=0 tinygo build -o main.wasm -scheduler=none -tags=appengine -target=wasi main.go

But still error:

# github.com/golang/protobuf/proto
../../pkg/mod/github.com/golang/[email protected]/proto/registry.go:230:16: MapOf not declared by package reflect

@dgryski
Copy link
Member

dgryski commented Aug 3, 2022

Yup, that's a current limitation of the reflect package. There are patches in progress to fix that, but otherwise no timeline for getting them merged.

@halfrost
Copy link
Author

halfrost commented Aug 3, 2022

OK, I'll keep an eye on your patch. You can add a tag to this issue with the patch you mentioned.

@deadprogram deadprogram added duplicate This issue or pull request already exists enhancement New feature or request reflection Needs further work on reflection labels Aug 4, 2022
@cross-hello
Copy link

@dgryski same problem here.
image
XTLS/Xray-core#1473 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request reflection Needs further work on reflection
Projects
None yet
Development

No branches or pull requests

4 participants