Skip to content

Commit

Permalink
net: adjust build tags for darwin libc calls
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Dan Peterson <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
  • Loading branch information
danp authored and gopherbot committed Nov 7, 2022
1 parent 969bea8 commit e7422b0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/net/cgo_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build cgo && !netgo && (darwin || dragonfly || freebsd)
//go:build cgo && !netgo && (dragonfly || freebsd)

package net

Expand Down
9 changes: 9 additions & 0 deletions src/net/cgo_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package net

import "internal/syscall/unix"

const cgoAddrInfoFlags = (unix.AI_CANONNAME | unix.AI_V4MAPPED | unix.AI_ALL) & unix.AI_MASK
2 changes: 1 addition & 1 deletion src/net/cgo_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !cgo || netgo
//go:build (!cgo && !darwin) || netgo

package net

Expand Down
2 changes: 1 addition & 1 deletion src/net/cgo_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Instead of C.foo it uses _C_foo, which is defined in either
// cgo_unix_cgo.go or cgo_unix_syscall.go

//go:build cgo && !netgo && unix
//go:build !netgo && ((cgo && unix) || darwin)

package net

Expand Down
2 changes: 1 addition & 1 deletion src/net/cgo_unix_syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build cgo && !netgo && darwin
//go:build !netgo && darwin

package net

Expand Down
2 changes: 1 addition & 1 deletion src/net/cgo_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build cgo && !netgo && unix
//go:build (cgo || darwin) && !netgo && unix

package net

Expand Down
4 changes: 2 additions & 2 deletions src/net/netgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

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

//go:build netgo || (!cgo && !windows)
//go:build netgo || (!cgo && !darwin && !windows)

package net

Expand Down
2 changes: 1 addition & 1 deletion src/net/netgo_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

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

package net

Expand Down

0 comments on commit e7422b0

Please sign in to comment.