]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix res_search uses on alpine, android, dragonfly
authorRuss Cox <rsc@golang.org>
Tue, 8 Nov 2022 19:21:27 +0000 (14:21 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 8 Nov 2022 20:59:42 +0000 (20:59 +0000)
On Android and Dragonfly, don't use -lresolv. It doesn't exist there.

On Linux, use res_search instead of res_nsearch.
glibc makes res_search thread-safe by having a per-thread __res.
It still also provides res_nsearch.
musl makes res_search thread-safe by ignoring __res completely.
It does not provide res_nsearch at all.
Changing to res_search on Linux will fix builds on musl-based systems
while keeping glibc-based systems working.

Fixes #56657.
Fixes #56660.

Change-Id: Id87dde6c8bbf6c0d34543c09782f3871489c8712
Reviewed-on: https://go-review.googlesource.com/c/go/+/448797
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/net/cgo_unix_cgo_res.go
src/net/cgo_unix_cgo_resn.go

index b9bdebadf65bd214f32d619fc9171c71913f5e46..37bbc9a762d8ae288ea256aa1fd538f8d0b9fabf 100644 (file)
@@ -4,7 +4,7 @@
 
 // res_search, for cgo systems where that is thread-safe.
 
-//go:build cgo && !netgo && (android || openbsd)
+//go:build cgo && !netgo && (linux || openbsd)
 
 package net
 
@@ -18,7 +18,7 @@ package net
 #include <arpa/nameser.h>
 #include <resolv.h>
 
-#cgo !openbsd LDFLAGS: -lresolv
+#cgo !android,!openbsd LDFLAGS: -lresolv
 */
 import "C"
 
index 5c2d7cdf47d8c0f23e0b1bbf0278f43688db8acc..4a5ff165dfae238b72270e0d69d0aa82984df11a 100644 (file)
@@ -4,7 +4,7 @@
 
 // res_nsearch, for cgo systems where that's available.
 
-//go:build cgo && !netgo && unix && !(android || darwin || openbsd)
+//go:build cgo && !netgo && unix && !(darwin || linux || openbsd)
 
 package net
 
@@ -18,7 +18,7 @@ package net
 #include <arpa/nameser.h>
 #include <resolv.h>
 
-#cgo !aix,!freebsd LDFLAGS: -lresolv
+#cgo !aix,!dragonfly,!freebsd LDFLAGS: -lresolv
 */
 import "C"