Skip to content

net: GODEBUG=netdns=cgo does not take priority over netgo build tag #69680

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

Closed
rittneje opened this issue Sep 27, 2024 · 9 comments
Closed

net: GODEBUG=netdns=cgo does not take priority over netgo build tag #69680

rittneje opened this issue Sep 27, 2024 · 9 comments
Assignees
Labels
Documentation Issues describing a change to documentation. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.

Comments

@rittneje
Copy link
Contributor

rittneje commented Sep 27, 2024

Go version

go version go1.22.7 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/tmp/.gocache'
GOENV='/Users/rittneje/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/rittneje/test/pkg/mod'
GONOPROXY='[REDACTED]'
GONOSUMDB='[REDACTED]'
GOOS='darwin'
GOPATH='/Users/rittneje/test'
GOPRIVATE='[REDACTED]'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/rittneje/go1.22.7'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/rittneje/go1.22.7/pkg/tool/darwin_amd64'
GOVCS='[REDACTED]'
GOVERSION='go1.22.7'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/rittneje/test/src/dialtest/go.mod'
GOWORK='/Users/rittneje/test/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/kf/kr7_s3xx0l12zbj3jrn082hmzy5gvy/T/go-build3261540356=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I ran a program as follows:

GODEBUG=netdns=cgo+1 go run -tags=netgo main.go

What did you see happen?

go package net: built with netgo build tag; using Go's DNS resolver

What did you expect to see?

go package net: GODEBUG setting forcing use of cgo's resolver


It should be noted that GODEBUG takes priority in the reverse situation.

GODEBUG=netdns=go+1 go run -tags=netcgo main.go

go package net: GODEBUG setting forcing use of Go's resolver

@mateusz834
Copy link
Member

It works as expected -tags netgo causes the net package to be build entirely without cgo, whereas -tags netcgo sets a preference on the cgo resolver, but the go is still in the binary, so we can run it.

@rittneje
Copy link
Contributor Author

@mateusz834 I don't think the docs currently mention that. https://pkg.go.dev/net#hdr-Name_Resolution

That also seems like something the debug log should directly state, instead of seemingly ignoring the GODEBUG setting entirely.

@mateusz834
Copy link
Member

@rittneje I agree, will send a CL to mention that in the docs.

@mateusz834
Copy link
Member

That also seems like something the debug log should directly state, instead of seemingly ignoring the GODEBUG setting entirely.

@ianlancetaylor any thoughts on this? We can mention that in the GODEBUG=netdns=1 mode, but not sure whether this is really that useful. Panic would be better, but i am not sure whether we can do this at this point.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/616262 mentions this issue: net: improve documentation of netgo/netcgo build tags

@mateusz834 mateusz834 added Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Sep 27, 2024
@mateusz834 mateusz834 self-assigned this Sep 27, 2024
@ianlancetaylor
Copy link
Contributor

For the case of GODEBUG=netdns=cgo go run -tags=netgo I don't think we should panic. I don't think that serves anybody. For GODEBUG=netdns=cgo+1 I think it would be OK to log something like "ignoring GODEBUG=netdns=cgo as -tags=netgo forces netdns=go".

@mateusz834
Copy link
Member

Also the same issue exists for CGO_ENABLED=0.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/616263 mentions this issue: net: improve GODEBUG=netdns=1 debug messages

gopherbot pushed a commit that referenced this issue Sep 30, 2024
Updates #69680

Change-Id: If80d43da493cb035164ede4a2cadcbec5831feaf
GitHub-Last-Rev: b3853e9
GitHub-Pull-Request: #69682
Reviewed-on: https://go-review.googlesource.com/c/go/+/616262
Auto-Submit: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants