1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:20:01 -07:00

net: fix res_search uses on alpine, android, dragonfly

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>
This commit is contained in:
Russ Cox 2022-11-08 14:21:27 -05:00
parent 12ab0ac184
commit a7538d7821
2 changed files with 4 additions and 4 deletions

View 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"

View 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"