bazel-contrib / bazel-contrib/rules_go
golang.org/x/net fails to build on darwin with undefined symbols
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
0.27.0
### What version of gazelle are you using?
0.23.0
### What version of Bazel are you using?
4.1.0
### Does this issue reproduce with the latest releases of all the above?
The above are the latest
### What operating system and processor architecture are you using?
darwin amd64 (macOS 10.15.7)
### What did you do?
Configure the following workspace:
**go.mod**
```
module golangsystest
go 1.16
require golang.org/x/net v0.0.0-20210525063256-abc453219eb5
```
**go.sum**
```
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
```
**main.go**
```go
package main
import (
"fmt"
"golang.org/x/net/ipv6"
)
func main() {
fmt.Println(ipv6.Version)
}
```
**WORKSPACE**
```bazel
workspace(name = "golangsystest")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(
go_version = "1.16.4",
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=",
version = "v0.0.0-20210525063256-abc453219eb5",
)
go_repository(
name = "org_golang_x_term",
importpath = "golang.org/x/term",
sum = "h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=",
version = "v0.0.0-20201126162022-7de9c90e9dd1",
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=",
version = "v0.3.6",
)
go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=",
version = "v0.0.0-20180917221912-90fa682c2a6e",
)
gazelle_dependencies()
go_repository(
name = "org_golang_x_sys",
build_file_name = "BUILD.bazel",
build_file_proto_mode = "disable",
importpath = "golang.org/x/sys",
sum = "h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=",
version = "v0.0.0-20210423082822-04245dca01da",
)
```
**BUILD.bazel**
```bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle_binary")
# gazelle:prefix golangsystest
gazelle_binary(
name = "gazelle",
languages = [
"@bazel_gazelle//language/go:go_default_library",
],
visibility = ["//visibility:public"],
)
go_library(
name = "golangsystest_lib",
srcs = ["main.go"],
importpath = "golangsystest",
visibility = ["//visibility:private"],
deps = ["@org_golang_x_net//ipv6"],
)
go_binary(
name = "golangsystest",
embed = [":golangsystest_lib"],
visibility = ["//visibility:public"],
)
```
(content of the above two files were mostly populated by `bazel run //:gazelle -- update-repos -from_file=go.mod` and `bazel run //:gazelle`)
On a Mac, run:
```
bazel build :golangsystest
```
### What did you expect to see?
That the build succeeds.
### What did you see instead?
```
$bazel build :golangsystest
INFO: Analyzed target //:golangsystest (42 packages loaded, 7771 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_atavakoli/685b18d319aacb531cc4899822843b03/external/org_golang_x_net/ipv6/BUILD.bazel:3:11: GoCompilePkg external/org_golang_x_net/ipv6/ipv6.a failed: (Exit 1): builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_amd64 -src external/org_golang_x_net/ipv6/batch.go -src external/org_golang_x_net/ipv6/control.go -src ... (remaining 161 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
external/org_golang_x_net/ipv6/control_rfc3542_unix.go:35:37: undefined: unix.IPV6_HOPLIMIT
external/org_golang_x_net/ipv6/control_rfc3542_unix.go:48:37: undefined: unix.IPV6_PKTINFO
external/org_golang_x_net/ipv6/sys_darwin.go:21:21: undefined: unix.IPV6_HOPLIMIT
external/org_golang_x_net/ipv6/sys_darwin.go:22:21: undefined: unix.IPV6_PKTINFO
external/org_golang_x_net/ipv6/sys_darwin.go:23:21: undefined: unix.IPV6_NEXTHOP
external/org_golang_x_net/ipv6/sys_darwin.go:24:21: undefined: unix.IPV6_PATHMTU
external/org_golang_x_net/ipv6/sys_darwin.go:34:82: undefined: unix.IPV6_RECVHOPLIMIT
external/org_golang_x_net/ipv6/sys_darwin.go:35:82: undefined: unix.IPV6_RECVPKTINFO
external/org_golang_x_net/ipv6/sys_darwin.go:36:82: undefined: unix.IPV6_RECVPATHMTU
external/org_golang_x_net/ipv6/sys_darwin.go:37:82: undefined: unix.IPV6_PATHMTU
external/org_golang_x_net/ipv6/control_rfc3542_unix.go:48:37: too many errors
compilepkg: error running subcommand external/go_sdk/pkg/tool/darwin_amd64/compile: exit status 2
Target //:golangsystest failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 6.423s, Critical Path: 2.60s
INFO: 12 processes: 5 internal, 7 darwin-sandbox.
FAILED: Build did NOT complete successfully
```
Contributor guide
Research direction
Reproduce the failure with `bazel build :golangsystest` using the supplied WORKSPACE, BUILD.bazel, go.mod, and Go sources. Start by inspecting the generated external `org_golang_x_net//ipv6` files named in the errors and the referenced `org_golang_x_sys` version. Done means the Darwin amd64 target builds successfully without the undefined symbol errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100