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

Comments

Projects
None yet
4 participants
@mikioh
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Oct 14, 2013

@minux

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

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.

@mikioh mikioh added invalid labels Oct 14, 2013

@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.
You can’t perform that action at this time.