syscall,runtime/cgo: use cgo_ldflag to link against -lsocket and -lxnet on Solaris

The -lsocket and -lxnet flags are needed for accept4 syscall on Solaris.
The runtime/cgo package doens't use them, so it doesn't make sense for
it to explicitly link against those libraries.

Instead, use the //go:cgo_ldflag in the syscall package.

Cq-Include-Trybots: luci.golang.try:gotip-solaris-amd64
Change-Id: I10db524ebf1c720a460515d8c1f362b0070bd771
Reviewed-on: https://go-review.googlesource.com/c/go/+/751760
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
This commit is contained in:
qmuntal
2026-03-05 12:19:20 +01:00
committed by Quim Muntal
parent d3651c5888
commit e30e65f7a8
2 changed files with 3 additions and 2 deletions

View File

@@ -20,8 +20,6 @@ package cgo
#cgo netbsd LDFLAGS: -lpthread
#cgo openbsd LDFLAGS: -lpthread
#cgo aix LDFLAGS: -Wl,-berok
#cgo solaris LDFLAGS: -lxnet
#cgo solaris LDFLAGS: -lsocket
// Use -fno-stack-protector to avoid problems locating the
// proper support functions. See issues #52919, #54313, #58385.

View File

@@ -71,6 +71,9 @@ func Pipe2(p []int, flags int) error {
return err
}
//go:cgo_ldflag "-lxnet"
//go:cgo_ldflag "-lsocket"
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
func Accept4(fd int, flags int) (int, Sockaddr, error) {