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

net/linux #4460

Closed
wants to merge 5 commits into from
Closed

net/linux #4460

wants to merge 5 commits into from

Conversation

leongross
Copy link
Contributor

@leongross leongross commented Sep 10, 2024

Add basic Linux networking support to the runtime by selectively overwriting/linking runtime functions, mostly in the polling logic.
This PR incorporates cherry-picked features that @scottfeldman introduced to the runtime.
Currently, there is no handling/re-implementation of non-Linux networking as in the original PR #4273, although this is the final goal of the net rework.

Over time I will expand a list of tested functionalities of the net package and their constraints, maybe also some more systematic testing.

Atm, I could confirm that a simple net.Dial as well as a con.Write() succeed.
It is necessary to use the -tags netgo tag.

goroot

Since there have been some reproducibility and build issues on other systems, this is how my current goroot/src/net looks like (and at least works for me):

click
net
├── addrselect.go -> /usr/local/go/src/net/addrselect.go
├── addrselect_test.go -> /usr/local/go/src/net/addrselect_test.go
├── cgo_aix.go -> /usr/local/go/src/net/cgo_aix.go
├── cgo_android.go -> /usr/local/go/src/net/cgo_android.go
├── cgo_bsd.go -> /usr/local/go/src/net/cgo_bsd.go
├── cgo_darwin.go -> /usr/local/go/src/net/cgo_darwin.go
├── cgo_linux.go -> /usr/local/go/src/net/cgo_linux.go
├── cgo_netbsd.go -> /usr/local/go/src/net/cgo_netbsd.go
├── cgo_openbsd.go -> /usr/local/go/src/net/cgo_openbsd.go
├── cgo_resnew.go -> /usr/local/go/src/net/cgo_resnew.go
├── cgo_resold.go -> /usr/local/go/src/net/cgo_resold.go
├── cgo_socknew.go -> /usr/local/go/src/net/cgo_socknew.go
├── cgo_sockold.go -> /usr/local/go/src/net/cgo_sockold.go
├── cgo_solaris.go -> /usr/local/go/src/net/cgo_solaris.go
├── cgo_stub.go -> /usr/local/go/src/net/cgo_stub.go
├── cgo_unix_cgo.go -> /usr/local/go/src/net/cgo_unix_cgo.go
├── cgo_unix_cgo_res.go -> /usr/local/go/src/net/cgo_unix_cgo_res.go
├── cgo_unix_cgo_resn.go -> /usr/local/go/src/net/cgo_unix_cgo_resn.go
├── cgo_unix.go -> /usr/local/go/src/net/cgo_unix.go
├── cgo_unix_syscall.go -> /usr/local/go/src/net/cgo_unix_syscall.go
├── cgo_unix_test.go -> /usr/local/go/src/net/cgo_unix_test.go
├── conf.go -> /usr/local/go/src/net/conf.go
├── conf_test.go -> /usr/local/go/src/net/conf_test.go
├── conn_test.go -> /usr/local/go/src/net/conn_test.go
├── dial.go -> /usr/local/go/src/net/dial.go
├── dial_test.go -> /usr/local/go/src/net/dial_test.go
├── dial_unix_test.go -> /usr/local/go/src/net/dial_unix_test.go
├── dnsclient.go -> /usr/local/go/src/net/dnsclient.go
├── dnsclient_test.go -> /usr/local/go/src/net/dnsclient_test.go
├── dnsclient_unix.go -> /usr/local/go/src/net/dnsclient_unix.go
├── dnsclient_unix_test.go -> /usr/local/go/src/net/dnsclient_unix_test.go
├── dnsconfig.go -> /usr/local/go/src/net/dnsconfig.go
├── dnsconfig_unix.go -> /usr/local/go/src/net/dnsconfig_unix.go
├── dnsconfig_unix_test.go -> /usr/local/go/src/net/dnsconfig_unix_test.go
├── dnsconfig_windows.go -> /usr/local/go/src/net/dnsconfig_windows.go
├── dnsname_test.go -> /usr/local/go/src/net/dnsname_test.go
├── error_plan9.go -> /usr/local/go/src/net/error_plan9.go
├── error_plan9_test.go -> /usr/local/go/src/net/error_plan9_test.go
├── error_posix.go -> /usr/local/go/src/net/error_posix.go
├── error_posix_test.go -> /usr/local/go/src/net/error_posix_test.go
├── error_test.go -> /usr/local/go/src/net/error_test.go
├── error_unix.go -> /usr/local/go/src/net/error_unix.go
├── error_unix_test.go -> /usr/local/go/src/net/error_unix_test.go
├── error_windows.go -> /usr/local/go/src/net/error_windows.go
├── error_windows_test.go -> /usr/local/go/src/net/error_windows_test.go
├── example_test.go -> /usr/local/go/src/net/example_test.go
├── external_test.go -> /usr/local/go/src/net/external_test.go
├── fd_fake.go -> /usr/local/go/src/net/fd_fake.go
├── fd_js.go -> /usr/local/go/src/net/fd_js.go
├── fd_plan9.go -> /usr/local/go/src/net/fd_plan9.go
├── fd_posix.go -> /usr/local/go/src/net/fd_posix.go
├── fd_unix.go -> /usr/local/go/src/net/fd_unix.go
├── fd_wasip1.go -> /usr/local/go/src/net/fd_wasip1.go
├── fd_windows.go -> /usr/local/go/src/net/fd_windows.go
├── file.go -> /usr/local/go/src/net/file.go
├── file_plan9.go -> /usr/local/go/src/net/file_plan9.go
├── file_stub.go -> /usr/local/go/src/net/file_stub.go
├── file_test.go -> /usr/local/go/src/net/file_test.go
├── file_unix.go -> /usr/local/go/src/net/file_unix.go
├── file_unix_test.go -> /usr/local/go/src/net/file_unix_test.go
├── file_wasip1.go -> /usr/local/go/src/net/file_wasip1.go
├── file_wasip1_test.go -> /usr/local/go/src/net/file_wasip1_test.go
├── file_windows.go -> /usr/local/go/src/net/file_windows.go
├── hook.go -> /usr/local/go/src/net/hook.go
├── hook_plan9.go -> /usr/local/go/src/net/hook_plan9.go
├── hook_unix.go -> /usr/local/go/src/net/hook_unix.go
├── hook_windows.go -> /usr/local/go/src/net/hook_windows.go
├── hosts.go -> /usr/local/go/src/net/hosts.go
├── hosts_test.go -> /usr/local/go/src/net/hosts_test.go
├── http -> /home/user/tinygo/src/net/http (red, invalid!)
├── interface_aix.go -> /usr/local/go/src/net/interface_aix.go
├── interface_bsd.go -> /usr/local/go/src/net/interface_bsd.go
├── interface_bsd_test.go -> /usr/local/go/src/net/interface_bsd_test.go
├── interface_bsdvar.go -> /usr/local/go/src/net/interface_bsdvar.go
├── interface_darwin.go -> /usr/local/go/src/net/interface_darwin.go
├── interface_freebsd.go -> /usr/local/go/src/net/interface_freebsd.go
├── interface.go -> /usr/local/go/src/net/interface.go
├── interface_linux.go -> /usr/local/go/src/net/interface_linux.go
├── interface_linux_test.go -> /usr/local/go/src/net/interface_linux_test.go
├── interface_plan9.go -> /usr/local/go/src/net/interface_plan9.go
├── interface_solaris.go -> /usr/local/go/src/net/interface_solaris.go
├── interface_stub.go -> /usr/local/go/src/net/interface_stub.go
├── interface_test.go -> /usr/local/go/src/net/interface_test.go
├── interface_unix_test.go -> /usr/local/go/src/net/interface_unix_test.go
├── interface_windows.go -> /usr/local/go/src/net/interface_windows.go
├── internal -> /usr/local/go/src/net/internal
├── ip.go -> /usr/local/go/src/net/ip.go
├── iprawsock.go -> /usr/local/go/src/net/iprawsock.go
├── iprawsock_plan9.go -> /usr/local/go/src/net/iprawsock_plan9.go
├── iprawsock_posix.go -> /usr/local/go/src/net/iprawsock_posix.go
├── iprawsock_test.go -> /usr/local/go/src/net/iprawsock_test.go
├── ipsock.go -> /usr/local/go/src/net/ipsock.go
├── ipsock_plan9.go -> /usr/local/go/src/net/ipsock_plan9.go
├── ipsock_plan9_test.go -> /usr/local/go/src/net/ipsock_plan9_test.go
├── ipsock_posix.go -> /usr/local/go/src/net/ipsock_posix.go
├── ipsock_test.go -> /usr/local/go/src/net/ipsock_test.go
├── ip_test.go -> /usr/local/go/src/net/ip_test.go
├── listen_test.go -> /usr/local/go/src/net/listen_test.go
├── lookup.go -> /usr/local/go/src/net/lookup.go
├── lookup_plan9.go -> /usr/local/go/src/net/lookup_plan9.go
├── lookup_test.go -> /usr/local/go/src/net/lookup_test.go
├── lookup_unix.go -> /usr/local/go/src/net/lookup_unix.go
├── lookup_windows.go -> /usr/local/go/src/net/lookup_windows.go
├── lookup_windows_test.go -> /usr/local/go/src/net/lookup_windows_test.go
├── mac.go -> /usr/local/go/src/net/mac.go
├── mac_test.go -> /usr/local/go/src/net/mac_test.go
├── mail -> /usr/local/go/src/net/mail
├── main_cloexec_test.go -> /usr/local/go/src/net/main_cloexec_test.go
├── main_conf_test.go -> /usr/local/go/src/net/main_conf_test.go
├── main_plan9_test.go -> /usr/local/go/src/net/main_plan9_test.go
├── main_posix_test.go -> /usr/local/go/src/net/main_posix_test.go
├── main_test.go -> /usr/local/go/src/net/main_test.go
├── main_unix_test.go -> /usr/local/go/src/net/main_unix_test.go
├── main_wasm_test.go -> /usr/local/go/src/net/main_wasm_test.go
├── main_windows_test.go -> /usr/local/go/src/net/main_windows_test.go
├── mockserver_test.go -> /usr/local/go/src/net/mockserver_test.go
├── mptcpsock_linux.go -> /usr/local/go/src/net/mptcpsock_linux.go
├── mptcpsock_linux_test.go -> /usr/local/go/src/net/mptcpsock_linux_test.go
├── mptcpsock_stub.go -> /usr/local/go/src/net/mptcpsock_stub.go
├── netcgo_off.go -> /usr/local/go/src/net/netcgo_off.go
├── netcgo_on.go -> /usr/local/go/src/net/netcgo_on.go
├── net_fake.go -> /usr/local/go/src/net/net_fake.go
├── net_fake_test.go -> /usr/local/go/src/net/net_fake_test.go
├── net.go -> /usr/local/go/src/net/net.go
├── netgo_netcgo.go -> /usr/local/go/src/net/netgo_netcgo.go
├── netgo_off.go -> /usr/local/go/src/net/netgo_off.go
├── netgo_on.go -> /usr/local/go/src/net/netgo_on.go
├── netip -> /usr/local/go/src/net/netip
├── net_test.go -> /usr/local/go/src/net/net_test.go
├── net_windows_test.go -> /usr/local/go/src/net/net_windows_test.go
├── nss.go -> /usr/local/go/src/net/nss.go
├── nss_test.go -> /usr/local/go/src/net/nss_test.go
├── packetconn_test.go -> /usr/local/go/src/net/packetconn_test.go
├── parse.go -> /usr/local/go/src/net/parse.go
├── parse_test.go -> /usr/local/go/src/net/parse_test.go
├── pipe.go -> /usr/local/go/src/net/pipe.go
├── pipe_test.go -> /usr/local/go/src/net/pipe_test.go
├── platform_test.go -> /usr/local/go/src/net/platform_test.go
├── port.go -> /usr/local/go/src/net/port.go
├── port_test.go -> /usr/local/go/src/net/port_test.go
├── port_unix.go -> /usr/local/go/src/net/port_unix.go
├── protoconn_test.go -> /usr/local/go/src/net/protoconn_test.go
├── rawconn.go -> /usr/local/go/src/net/rawconn.go
├── rawconn_stub_test.go -> /usr/local/go/src/net/rawconn_stub_test.go
├── rawconn_test.go -> /usr/local/go/src/net/rawconn_test.go
├── rawconn_unix_test.go -> /usr/local/go/src/net/rawconn_unix_test.go
├── rawconn_windows_test.go -> /usr/local/go/src/net/rawconn_windows_test.go
├── resolverdialfunc_test.go -> /usr/local/go/src/net/resolverdialfunc_test.go
├── rlimit_js.go -> /usr/local/go/src/net/rlimit_js.go
├── rlimit_unix.go -> /usr/local/go/src/net/rlimit_unix.go
├── rpc -> /usr/local/go/src/net/rpc
├── sendfile_linux.go -> /usr/local/go/src/net/sendfile_linux.go
├── sendfile_stub.go -> /usr/local/go/src/net/sendfile_stub.go
├── sendfile_test.go -> /usr/local/go/src/net/sendfile_test.go
├── sendfile_unix_alt.go -> /usr/local/go/src/net/sendfile_unix_alt.go
├── sendfile_windows.go -> /usr/local/go/src/net/sendfile_windows.go
├── server_test.go -> /usr/local/go/src/net/server_test.go
├── smtp -> /usr/local/go/src/net/smtp
├── sockaddr_posix.go -> /usr/local/go/src/net/sockaddr_posix.go
├── sock_bsd.go -> /usr/local/go/src/net/sock_bsd.go
├── sock_cloexec.go -> /usr/local/go/src/net/sock_cloexec.go
├── sock_cloexec_solaris.go -> /usr/local/go/src/net/sock_cloexec_solaris.go
├── sock_linux.go -> /usr/local/go/src/net/sock_linux.go
├── sock_linux_test.go -> /usr/local/go/src/net/sock_linux_test.go
├── sockopt_aix.go -> /usr/local/go/src/net/sockopt_aix.go
├── sockopt_bsd.go -> /usr/local/go/src/net/sockopt_bsd.go
├── sockopt_fake.go -> /usr/local/go/src/net/sockopt_fake.go
├── sockoptip_bsdvar.go -> /usr/local/go/src/net/sockoptip_bsdvar.go
├── sockoptip_linux.go -> /usr/local/go/src/net/sockoptip_linux.go
├── sockoptip_posix.go -> /usr/local/go/src/net/sockoptip_posix.go
├── sockoptip_stub.go -> /usr/local/go/src/net/sockoptip_stub.go
├── sockoptip_windows.go -> /usr/local/go/src/net/sockoptip_windows.go
├── sockopt_linux.go -> /usr/local/go/src/net/sockopt_linux.go
├── sockopt_plan9.go -> /usr/local/go/src/net/sockopt_plan9.go
├── sockopt_posix.go -> /usr/local/go/src/net/sockopt_posix.go
├── sockopt_solaris.go -> /usr/local/go/src/net/sockopt_solaris.go
├── sockopt_windows.go -> /usr/local/go/src/net/sockopt_windows.go
├── sock_plan9.go -> /usr/local/go/src/net/sock_plan9.go
├── sock_posix.go -> /usr/local/go/src/net/sock_posix.go
├── sock_stub.go -> /usr/local/go/src/net/sock_stub.go
├── sock_windows.go -> /usr/local/go/src/net/sock_windows.go
├── splice_linux.go -> /usr/local/go/src/net/splice_linux.go
├── splice_linux_test.go -> /usr/local/go/src/net/splice_linux_test.go
├── splice_stub.go -> /usr/local/go/src/net/splice_stub.go
├── sys_cloexec.go -> /usr/local/go/src/net/sys_cloexec.go
├── tcpconn_keepalive_conf_darwin_test.go -> /usr/local/go/src/net/tcpconn_keepalive_conf_darwin_test.go
├── tcpconn_keepalive_conf_posix_test.go -> /usr/local/go/src/net/tcpconn_keepalive_conf_posix_test.go
├── tcpconn_keepalive_conf_solaris_test.go -> /usr/local/go/src/net/tcpconn_keepalive_conf_solaris_test.go
├── tcpconn_keepalive_conf_unix_test.go -> /usr/local/go/src/net/tcpconn_keepalive_conf_unix_test.go
├── tcpconn_keepalive_conf_windows_test.go -> /usr/local/go/src/net/tcpconn_keepalive_conf_windows_test.go
├── tcpconn_keepalive_illumos_test.go -> /usr/local/go/src/net/tcpconn_keepalive_illumos_test.go
├── tcpconn_keepalive_posix_test.go -> /usr/local/go/src/net/tcpconn_keepalive_posix_test.go
├── tcpconn_keepalive_solaris_test.go -> /usr/local/go/src/net/tcpconn_keepalive_solaris_test.go
├── tcpconn_keepalive_test.go -> /usr/local/go/src/net/tcpconn_keepalive_test.go
├── tcpsock.go -> /usr/local/go/src/net/tcpsock.go
├── tcpsockopt_darwin.go -> /usr/local/go/src/net/tcpsockopt_darwin.go
├── tcpsockopt_openbsd.go -> /usr/local/go/src/net/tcpsockopt_openbsd.go
├── tcpsockopt_plan9.go -> /usr/local/go/src/net/tcpsockopt_plan9.go
├── tcpsockopt_posix.go -> /usr/local/go/src/net/tcpsockopt_posix.go
├── tcpsockopt_solaris.go -> /usr/local/go/src/net/tcpsockopt_solaris.go
├── tcpsockopt_stub.go -> /usr/local/go/src/net/tcpsockopt_stub.go
├── tcpsockopt_unix.go -> /usr/local/go/src/net/tcpsockopt_unix.go
├── tcpsockopt_windows.go -> /usr/local/go/src/net/tcpsockopt_windows.go
├── tcpsock_plan9.go -> /usr/local/go/src/net/tcpsock_plan9.go
├── tcpsock_posix.go -> /usr/local/go/src/net/tcpsock_posix.go
├── tcpsock_solaris.go -> /usr/local/go/src/net/tcpsock_solaris.go
├── tcpsock_test.go -> /usr/local/go/src/net/tcpsock_test.go
├── tcpsock_unix.go -> /usr/local/go/src/net/tcpsock_unix.go
├── tcpsock_unix_test.go -> /usr/local/go/src/net/tcpsock_unix_test.go
├── tcpsock_windows.go -> /usr/local/go/src/net/tcpsock_windows.go
├── testdata -> /usr/local/go/src/net/testdata
├── textproto -> /usr/local/go/src/net/textproto
├── timeout_test.go -> /usr/local/go/src/net/timeout_test.go
├── udpsock.go -> /usr/local/go/src/net/udpsock.go
├── udpsock_plan9.go -> /usr/local/go/src/net/udpsock_plan9.go
├── udpsock_plan9_test.go -> /usr/local/go/src/net/udpsock_plan9_test.go
├── udpsock_posix.go -> /usr/local/go/src/net/udpsock_posix.go
├── udpsock_test.go -> /usr/local/go/src/net/udpsock_test.go
├── unixsock.go -> /usr/local/go/src/net/unixsock.go
├── unixsock_linux_test.go -> /usr/local/go/src/net/unixsock_linux_test.go
├── unixsock_plan9.go -> /usr/local/go/src/net/unixsock_plan9.go
├── unixsock_posix.go -> /usr/local/go/src/net/unixsock_posix.go
├── unixsock_readmsg_cloexec.go -> /usr/local/go/src/net/unixsock_readmsg_cloexec.go
├── unixsock_readmsg_cmsg_cloexec.go -> /usr/local/go/src/net/unixsock_readmsg_cmsg_cloexec.go
├── unixsock_readmsg_other.go -> /usr/local/go/src/net/unixsock_readmsg_other.go
├── unixsock_readmsg_test.go -> /usr/local/go/src/net/unixsock_readmsg_test.go
├── unixsock_test.go -> /usr/local/go/src/net/unixsock_test.go
├── unixsock_windows_test.go -> /usr/local/go/src/net/unixsock_windows_test.go
├── url -> /usr/local/go/src/net/url
├── write_unix_test.go -> /usr/local/go/src/net/write_unix_test.go
├── writev_test.go -> /usr/local/go/src/net/writev_test.go
└── writev_unix.go -> /usr/local/go/src/net/writev_unix.go

9 directories, 224 files

if this does not work, do the folliwing steps:
1. remove net submodule
2. remove symlink in local ~/.cache/tinygo/goroot-<hash>/net
3. manual symlink yo local golang /usr/local/bin/src/net

Signed-off-by: leongross <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant