tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
14.72k stars 858 forks source link

add support for unix.Syscall* invocations #4310

Closed leongross closed 5 days ago

leongross commented 1 week ago

In linux userland applications, the following error (and similar ones for Syscall6 and RawSyscall)occurred, when building applications that use the unix.Syscall package:

ld.lld: error: undefined symbol: golang.org/x/sys/unix.Syscall
>>> referenced by zsyscall_linux.go:1490 (.../golang.org/x/sys/unix/zsyscall_linux.go:1490)
error: failed to link /tmp/tinygo3353455449/main: exit status 1

This patch adds the functionality to use tinygo's syscalls for any linux userland application for the architectures that tinygo supports.

P.S: For me this was the easiest solution, although this might not be super clean. I would be happy to discuss with anyone interested in the tinygo compiler development if we can improve this in any way, but for now it seems to do the job. Also I'm not quite sure how to test this in a good way, maybe someone has any good ideas on that as well.

leongross commented 1 week ago

@aykevl @deadprogram @rminnich

aykevl commented 5 days ago

Thank you for fixing this!

leongross commented 5 days ago

Thanks for the fast review and merge!