From a7538d78214920b798a1914a2a789ae833d6f1e1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 8 Nov 2022 14:21:27 -0500 Subject: [PATCH] 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 Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- src/net/cgo_unix_cgo_res.go | 4 ++-- src/net/cgo_unix_cgo_resn.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net/cgo_unix_cgo_res.go b/src/net/cgo_unix_cgo_res.go index b9bdebadf6..37bbc9a762 100644 --- a/src/net/cgo_unix_cgo_res.go +++ b/src/net/cgo_unix_cgo_res.go @@ -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 #include -#cgo !openbsd LDFLAGS: -lresolv +#cgo !android,!openbsd LDFLAGS: -lresolv */ import "C" diff --git a/src/net/cgo_unix_cgo_resn.go b/src/net/cgo_unix_cgo_resn.go index 5c2d7cdf47..4a5ff165df 100644 --- a/src/net/cgo_unix_cgo_resn.go +++ b/src/net/cgo_unix_cgo_resn.go @@ -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 #include -#cgo !aix,!freebsd LDFLAGS: -lresolv +#cgo !aix,!dragonfly,!freebsd LDFLAGS: -lresolv */ import "C" -- 2.50.0