add signal stubs to runtime
Linux applications might ignore a certain set of received signals.
For that the tinygo runtime has to expose said signals.
Since the tinygo runtime only has limited linux signal support, this PR adds stubs to the runtime and the os package.
Package to build with this PR: https://github.com/u-root/u-root/tree/main/cmds/exp/vmboot
The waspi2 test seem to fail due to
/opt/hostedtoolcache/go/1.22.5/x64/src/internal/testpty/pty_cgo.go:11:10: fatal: 'fcntl.h' file not found
Building for non-wasm seems to work as expected (testes on x86_64 linux) @deadprogram @aykevl does someone have an idea why that occurs / how to fix that?
@leongross can you please rebase this PR against the latest dev to see if it still fails CI?
Running the a local build results in symbols not being found. Also it looks like the wrong single library is used?
ld.lld: error: undefined symbol: os/signal.signal_recv
>>> referenced by signal_unix.go:23 (/usr/lib/golang/src/os/signal/signal_unix.go:23)
>>> /tmp/tinygo2823474359/main.lto.main.o:(os/signal.loop)
ld.lld: error: undefined symbol: os/signal.signal_enable
>>> referenced by signal_unix.go:49 (/usr/lib/golang/src/os/signal/signal_unix.go:49)
>>> /tmp/tinygo2823474359/main.lto.main.o:(os/signal.Notify)
Searching for the strings in the binary yields the linking symbols
$ nm build/tinygo | grep "os/signal.signal_recv"
0000000000585d20 t os/signal.signal_recv
The lubmusl error can be traced down to this include in muslbic that seems to miss fcnt.h in x86_64.
@dgryski any ideas why this might fail? I saw you worked on the runtime before.
The os/signal entry in goroot.go is still commented out. I think that needs to be set to false since we have our own complete implementation of that package now. Without that it's trying to run the Big Go os/signal tests which fail because our syscall packages are different.
@leongross I looked at how difficult it would be to support signals (instead of just stubbing them out), and got it working on Linux: https://github.com/tinygo-org/tinygo/pull/4378 What do you think?
(Note: if you try this, make sure to run tinygo clean so that musl is rebuilt. Otherwise signals will just result in a hang or crash.)
This PR is superseded by https://github.com/tinygo-org/tinygo/pull/4378.