Skip to content

Setuid not declared by package syscall #3274

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

Closed
tachyonicbytes opened this issue Nov 6, 2022 · 3 comments
Closed

Setuid not declared by package syscall #3274

tachyonicbytes opened this issue Nov 6, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@tachyonicbytes
Copy link
Contributor

Hello! I am trying to port gau to wasm, using tinygo.

The package compiles fine to wasm with GOOS=js GOARCH=wasm, but I want to use tinygo, in order to get better wasi bindings and be able to use it as is with more wasm runtimes.

The package uses some libraries that are not yet usable with tinygo (fasthttp and json-iterator-go), but I was able to swap them for tinygo/drivers/net/http and encoding/json in my fork, so the compilation problems went away. The code still compiles and works with go, but I ran into tinygo -target=wasi compilation problems that I was not able to resolve.

The main problem now stands at:

tinygo build -o ./build/gau -target=wasi ./cmd/gau/main.go 
# golang.org/x/sys/unix
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1896:17: Setuid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1900:17: Setgid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1904:17: Setreuid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1908:17: Setregid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1912:17: Setresuid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:1916:17: Setresgid not declared by package syscall
go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:524:17: Exec not declared by package syscall

As the code does not use the syscall package directly, I am not sure exactly which is the problematic call, and how to solve it. I looked around in the tinygo github issues and it seems like these kinds of issues have some chance of being solved (#1286).

Is there anyway to make it work for now or it cannot be solved until tinygo supports more of golang? The main idea is that since tinygo/drivers/net/http is supported, and the package itself is basically a http client plus some processing and reporting, I am also not sure exactly which library uses the syscall package. Is there a way to identify this, barring looking into each package itself?

@dgryski
Copy link
Member

dgryski commented Nov 7, 2022

This should be easy to stub given that Setuid isn't supported in Go and just returns an error.

golang/go#1435

@tachyonicbytes
Copy link
Contributor Author

@dgryski The stubbing should be done at tinygo level, right? I found this github issue that seems to be very similar to this problem.

I could not find a file named syscall_unix.go in src/syscall/, so I don't really know where I could add the stubs.

Is there something I can do at my project level? Would adding a file that has package syscall at the top and implements the stubs be enough to continue compiling (until I hit the next error, or until everything compiles successfully)?

@deadprogram deadprogram added the enhancement New feature or request label Nov 12, 2022
@deadprogram deadprogram added the next-release Will be part of next release label Nov 16, 2022
@deadprogram
Copy link
Member

0.27.0 has now been released, so closing. Thanks!

@deadprogram deadprogram removed the next-release Will be part of next release label Feb 12, 2023
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

3 participants