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: CGO_ENABLED=1 but go build -tags netgo doesn't enable netgo resolver #6582

Closed
mikioh opened this issue Oct 14, 2013 · 6 comments
Closed
Milestone

Comments

@mikioh
Copy link
Contributor

mikioh commented Oct 14, 2013

I was a bit confused, but now I'm guessing that original designers thought that:
                w/ netgo  w/o netgo
CGO_ENABLED=0   builtin   builtin
CGO_ENABLED=1   builtin   external
builtin: use netgo resolver, external: use cgo resolver
@mikioh
Copy link
Contributor Author

mikioh commented Oct 14, 2013

Comment 1:

https://golang.org/cl/14638043/

@minux
Copy link
Member

minux commented Oct 14, 2013

Comment 3:

are you suggesting that setting netgo build tag won't enable the Go DNS resolver?
but the code could resolve DNS names, and the binary is indeed statically linked,
so i'm not sure what's the problem.

@mikioh
Copy link
Contributor Author

mikioh commented Oct 14, 2013

Comment 4:

> are you suggesting that setting netgo build tag won't enable the Go DNS resolver?
Yup.
> but the code could resolve DNS names,
See net/lookup_unix.go.
func lookupIP(host string) (addrs []IP, err error) {
        addrs, err, ok := cgoLookupIP(host)
        if !ok {
                addrs, err = goLookupIP(host)
        }
        return
}
> and the binary is indeed statically linked,
It doesn't matter in this case.
> so i'm not sure what's the problem.
Hm, probably I'm wrong. Please try to build and run "CGO_ENABLED=1 && -tags netgo"
image. Hope syscall trace tool will show something something.

@mikioh
Copy link
Contributor Author

mikioh commented Oct 14, 2013

Comment 5:

> Hope syscall trace tool will show something something.
If you see the image does some IP-layer reachability tests to the records in query
response messages, that might be the signature of more powerful external DNS resolver
because our netgo resolver doesn't implement such kind of feature so far.

@minux
Copy link
Member

minux commented Oct 14, 2013

Comment 6:

i write a simple program, and use -tag netgo to build it, it can resolve www.google.com
and strace(1) verifies that it did connect to 8.8.8.8 to resolve the DNS.
the most important thing is: it is statically linked, so it couldn't possibly use the cgo
lookup code (which by definition means the binary must be dynamically linked to use
libc)
and I also verified with ltrace(1) that if i remove the netgo build tag, and rebuild the
stdlib and the program, it will call getaddrinfo(3).

@mikioh
Copy link
Contributor Author

mikioh commented Oct 14, 2013

Comment 7:

Thanks for the confirmation.
> and rebuild the stdlib and the program
Hm, seems I forgot to rebuild stdlib, will try later.

Status changed to Invalid.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants