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

Add support for golang.org/x/net/internal/socket #14

Open
scottfeldman opened this issue Dec 8, 2023 · 5 comments
Open

Add support for golang.org/x/net/internal/socket #14

scottfeldman opened this issue Dec 8, 2023 · 5 comments

Comments

@scottfeldman
Copy link
Contributor

Damian Gryski wrote:

Will any of the netdev stuff help with stubbing out the net package, so that things like

golang.org/x/net/internal/socket

../../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:27:17: cannot use (*net.TCPConn)(nil) (value of type *net.TCPConn) as tcpConn value in variable declaration: *net.TCPConn does not implement tcpConn (missing method SetLinger)
../../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:36:23: undefined: net.UDPConn
../../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:45:22: undefined: net.IPConn

Need to port/stub out the missing pieces.

@scottfeldman
Copy link
Contributor Author

Also reported by Randy Reddig on Slack. He gave this this test to repo issue:

sfeldma@nuc:~/work$ git clone https://github.com/domainr/dnsr.git
Cloning into 'dnsr'...
remote: Enumerating objects: 1724, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (131/131), done.
remote: Total 1724 (delta 309), reused 254 (delta 245), pack-reused 1348
Receiving objects: 100% (1724/1724), 316.26 KiB | 1.76 MiB/s, done.
Resolving deltas: 100% (1052/1052), done.
sfeldma@nuc:~/work$ cd dnsr
sfeldma@nuc:~/work/dnsr$ go work use .
sfeldma@nuc:~/work/dnsr$ tinygo test
go: downloading github.com/miekg/dns v1.1.57
go: downloading golang.org/x/net v0.19.0
go: downloading golang.org/x/sys v0.15.0
go: downloading github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32
FAIL    github.com/domainr/dnsr 0.000s
# golang.org/x/net/internal/socket
../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:27:17: cannot use (*net.TCPConn)(nil) (value of type *net.TCPConn) as tcpConn value in variable declaration: *net.TCPConn does not implement tcpConn (missing method SetLinger)
../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:36:17: cannot use (*net.UDPConn)(nil) (value of type *net.UDPConn) as udpConn value in variable declaration: *net.UDPConn does not implement udpConn (missing method ReadMsgUDP)
../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/rawconn.go:45:22: undefined: net.IPConn
../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/sys_posix.go:127:43: undefined: net.Interface
../../go/pkg/mod/golang.org/x/[email protected]/internal/socket/sys_posix.go:137:21: undefined: net.Interfaces

@scottfeldman
Copy link
Contributor Author

Ok, I've stubbed out a lot of stuff in src/net and src/crypto so dnsr tinygo test compiles, but now getting undefined symbols on link:

sfeldma@nuc:~/work/dnsr$ tinygo test
ld.lld-16: error: undefined symbol: crypto/subtle.xorBytes
>>> referenced by xor.go:22 (/usr/local/go/src/crypto/subtle/xor.go:22)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((crypto/cipher.StreamReader).Read)

ld.lld-16: error: undefined symbol: crypto/aes.encryptBlockAsm
>>> referenced by cipher_asm.go:81 (/usr/local/go/src/crypto/aes/cipher_asm.go:81)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/aes.aesCipherAsm).Encrypt)

ld.lld-16: error: undefined symbol: crypto/internal/edwards25519/field.feSquare
>>> referenced by fe.go:309 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:309)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced by fe.go:309 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:309)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced by fe.go:309 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:309)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced 21 more times

ld.lld-16: error: undefined symbol: crypto/internal/edwards25519/field.feMul
>>> referenced by fe.go:303 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:303)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced by fe.go:303 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:303)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced by fe.go:303 (/usr/local/go/src/crypto/internal/edwards25519/field/fe.go:303)
>>>               /home/sfeldma/.cache/tinygo/thinlto/llvmcache-42E97D33C4936406C74B6B10925F4C503BF6B817:((*crypto/internal/edwards25519.Point).SetBytes)
>>> referenced 17 more times
FAIL    github.com/domainr/dnsr 0.000s
error: failed to link /tmp/tinygo1198081133/main: exit status 1

Not sure how to resolve these at the moment...

@scottfeldman
Copy link
Contributor Author

I've create two PRs to capture the work on this Issue so far:

tinygo-org/tinygo/pull/4035 (the crypto/tls changes)
/pull/16 (the src/net changes)

@scottfeldman
Copy link
Contributor Author

Closing those PRs until we can figure out to get passed the link failures above

@scottfeldman
Copy link
Contributor Author

Ok, Damian Gryski gave me the hint to get past the link failure above.

sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi
error: could not find wasm-opt, set the WASMOPT environment variable to override

I'll re-submit PRs for tinygo and tinygo/net.

scottfeldman added a commit to scottfeldman/tinygo-net that referenced this issue Dec 10, 2023
…l/socket

These are changes need to compile github.com/domainr/dnsr/ with TinyGo. See issue tinygo-org#14.

These change are mostly to fix missing symbols in src/net. Missing types and functions are cut-and-pasted from go1.21.4. Functions are stubbed out returning errors.New("not implemented").

DNRS is compiled by running tinygo test:

   sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi

With this patch, and a corresponding patch for tinygo/ to fixup crypto/tls, you should get a clean compile.
deadprogram pushed a commit that referenced this issue Dec 17, 2023
…l/socket (#17)

* stub out more types/funcs to compile against golang.org/x/net/internal/socket

These are changes need to compile github.com/domainr/dnsr/ with TinyGo. See issue #14.

These change are mostly to fix missing symbols in src/net. Missing types and functions are cut-and-pasted from go1.21.4. Functions are stubbed out returning errors.New("not implemented").

DNRS is compiled by running tinygo test:

   sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi

With this patch, and a corresponding patch for tinygo/ to fixup crypto/tls, you should get a clean compile.
deadprogram pushed a commit to tinygo-org/tinygo that referenced this issue Dec 17, 2023
…l/socket (#4037)

* stub out more types/funcs to compile against golang.org/x/net/internal/socket

These are changes need to compile github.com/domainr/dnsr/ with TinyGo.
See issue tinygo-org/net#14.

These change are mostly to fix missing symbols in src/crypto/tls and
src/net.  Missing types and functions are cut-and-pasted from go1.21.4.
Functions are stubbed out returning errors.New("not implemented").

DNRS is compiled by running tinygo test:

   sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi

With this patch, and a corresponding patch for tinygo-org/net to fixup
src/net, you should get a clean compile.
crypto-smoke pushed a commit to meshnet-gophers/tinygo that referenced this issue Feb 14, 2024
…l/socket (tinygo-org#4037)

* stub out more types/funcs to compile against golang.org/x/net/internal/socket

These are changes need to compile github.com/domainr/dnsr/ with TinyGo.
See issue tinygo-org/net#14.

These change are mostly to fix missing symbols in src/crypto/tls and
src/net.  Missing types and functions are cut-and-pasted from go1.21.4.
Functions are stubbed out returning errors.New("not implemented").

DNRS is compiled by running tinygo test:

   sfeldma@nuc:~/work/dnsr$ tinygo test -target=wasi

With this patch, and a corresponding patch for tinygo-org/net to fixup
src/net, you should get a clean compile.
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

No branches or pull requests

1 participant