rules_go: Gazelle generated cgo library unable to resolve mac libraries
CGo libraries fail to link frameworks. Given // #cgo LDFLAGS: -framework IOKit
the following error is generated:
ERROR: /project/vendor/github.com/shirou/gopsutil/host/BUILD.bazel:3:1: in linkopts attribute of cc_library rule //vendor/github.com/shirou/gopsutil/host:cgo_default_library.cgo_c_lib: could not resolve label 'IOKit'. Since this rule was created by the macro 'cgo_library', the error might have been caused by the macro implementation in /private/var/tmp/_bazel_edward/ad32b996cb424fa4cc44a5c86220cb2f/external/io_bazel_rules_go/go/private/cgo.bzl:402:18.
cgo_library(
name = "cgo_default_library",
srcs = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": [
"host_darwin_cgo.go",
],
"//conditions:default": [],
}),
clinkopts = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": [
"-framework",
"IOKit",
],
"//conditions:default": [],
}),
visibility = ["//visibility:private"],
)```
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (9 by maintainers)
Commits related to this issue
- Gazelle: represent lists of cgo options as single strings This allows groups of options like "-framework IOKit" to be passed to Bazel in the same string. Bazel applies Bourne shell tokenization and l... — committed to jayconrod/rules_go by deleted user 7 years ago
- Gazelle: represent lists of cgo options as single strings (#652) This allows groups of options like "-framework IOKit" to be passed to Bazel in the same string. Bazel applies Bourne shell tokenizati... — committed to bazelbuild/rules_go by jayconrod 7 years ago
- Gazelle: don't treat -framework options as paths Fixes #646 — committed to jayconrod/rules_go by deleted user 7 years ago
- Gazelle: don't treat -framework options as paths (#756) Fixes #646 — committed to bazelbuild/rules_go by jayconrod 7 years ago
- Apply Bourne shell tokenization in cgo builder Bazel's cc_library and cc_binary automatically apply Bourne shell tokenization to copts and linkopts. We keep groups of flags such as "-framework CoreFo... — committed to jayconrod/rules_go by deleted user 7 years ago
- Apply Bourne shell tokenization in cgo builder (#798) Bazel's cc_library and cc_binary automatically apply Bourne shell tokenization to copts and linkopts. We keep groups of flags such as "-framewo... — committed to bazelbuild/rules_go by jayconrod 7 years ago
Hey @jayconrod bumping into this issue when trying to build https://github.com/shirou/gopsutil on OSX as a vendored dependency with Bazel.
Current error log looks like
Generated BUILD file in our vendor directory is