Skip to content

Commit e7422b0

Browse files
danpgopherbot
authored andcommitted
net: adjust build tags for darwin libc calls
Support for direct libc calls was added in CL 446178 but the build tags weren't quite activating it when cgo was not enabled. Adjust them and add a new supporting file for darwin. This should use the new direct libc calls with both CGO_ENABLED=0 and CGO_ENABLED=1 when building for darwin. Updates #12524 Change-Id: Ieee4b298dee13f389ed3a63c0a4a3a18c9180163 Reviewed-on: https://go-review.googlesource.com/c/go/+/448020 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dan Peterson <danp@danp.net> Auto-Submit: Ian Lance Taylor <iant@google.com>
1 parent 969bea8 commit e7422b0

8 files changed

+17
-8
lines changed

src/net/cgo_bsd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build cgo && !netgo && (darwin || dragonfly || freebsd)
5+
//go:build cgo && !netgo && (dragonfly || freebsd)
66

77
package net
88

src/net/cgo_darwin.go

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package net
6+
7+
import "internal/syscall/unix"
8+
9+
const cgoAddrInfoFlags = (unix.AI_CANONNAME | unix.AI_V4MAPPED | unix.AI_ALL) & unix.AI_MASK

src/net/cgo_stub.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !cgo || netgo
5+
//go:build (!cgo && !darwin) || netgo
66

77
package net
88

src/net/cgo_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Instead of C.foo it uses _C_foo, which is defined in either
88
// cgo_unix_cgo.go or cgo_unix_syscall.go
99

10-
//go:build cgo && !netgo && unix
10+
//go:build !netgo && ((cgo && unix) || darwin)
1111

1212
package net
1313

src/net/cgo_unix_syscall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build cgo && !netgo && darwin
5+
//go:build !netgo && darwin
66

77
package net
88

src/net/cgo_unix_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build cgo && !netgo && unix
5+
//go:build (cgo || darwin) && !netgo && unix
66

77
package net
88

src/net/netgo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
// Default netGo to true if the netgo build tag is being used, or the
66
// C library DNS routines are not available. Note that the C library
7-
// routines are always available on Windows.
7+
// routines are always available on Darwin and Windows.
88

9-
//go:build netgo || (!cgo && !windows)
9+
//go:build netgo || (!cgo && !darwin && !windows)
1010

1111
package net
1212

src/net/netgo_unix_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build (!cgo || netgo) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris)
5+
//go:build (!cgo || netgo) && (dragonfly || freebsd || linux || netbsd || openbsd || solaris)
66

77
package net
88

0 commit comments

Comments
 (0)