Anything with dependency on grpc built with goarch = "amd64" goos = "linux" on mac is failing to compile with the following error:
compile: missing strict dependencies:
/private/var/tmp/_bazel_user/661e387fcabd54e0fc68ec2cde13a5b9/sandbox/darwin-sandbox/5/execroot/poc/external/org_golang_google_grpc/internal/syscall/syscall_linux.go: import of "golang.org/x/sys/unix"
Known dependencies are:
google.golang.org/grpc/grpclog
Check that imports in Go sources match importpath attributes in deps.
This issue was reported as https://github.com/bazelbuild/rules_docker/issues/690, but looks like it belongs to rules_go
The recommended approach of using --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 does not work since local binary is not able to run anymore.
0.18.1
N/A
0.22.0-homebrew
0.23.2-homebrew
Yes
MacOS:
Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
git clone https://github.com/apesternikov/poc-bazel-690.git
cd poc-bazel-690
bazel build ...
Successful compilation of bazel-poc-690 and bazel-poc-690-linux binaries.
DEBUG: Rule 'com_google_protobuf' modified arguments {"shallow_since": "1551387314 -0800"}
INFO: Analysed 3 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets...
ERROR: /private/var/tmp/_bazel_pesterni/661e387fcabd54e0fc68ec2cde13a5b9/external/org_golang_google_grpc/internal/syscall/BUILD.bazel:3:1: GoCompile external/org_golang_google_grpc/internal/syscall/linux_amd64_pure_stripped/go_default_library%/google.golang.org/grpc/internal/syscall.a failed (Exit 1) builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compile -sdk external/go_sdk -installsuffix linux_amd64 -src external/org_golang_google_grpc/internal/syscall/syscall_linux.go -src ... (remaining 12 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
compile: missing strict dependencies:
/private/var/tmp/_bazel_pesterni/661e387fcabd54e0fc68ec2cde13a5b9/sandbox/darwin-sandbox/5/execroot/poc/external/org_golang_google_grpc/internal/syscall/syscall_linux.go: import of "golang.org/x/sys/unix"
Known dependencies are:
google.golang.org/grpc/grpclog
Check that imports in Go sources match importpath attributes in deps.
INFO: Elapsed time: 1.019s, Critical Path: 0.50s
INFO: 4 processes: 4 darwin-sandbox.
FAILED: Build did NOT complete successfully
Downgrading rules_go to 0.16.8 fixes the issue.
This is a known issue, described in Note on goos and goarch attributes. Please use --platforms for cross-compilation instead of these attributes.
The implementation of these attributes can be fixed after Bazel has fully implemented Starlark Build Configuration. We'll use configuration transitions instead of aspects, and that will work with select expressions.
golang.org/x/sys/unix on platforms where it's safe to do so. That may be an acceptable workaround.If I remember correctly, downgrading rules_go to 0.16.8 would fix this because the older version of gRPC provided there did not depend on golang.org/x/sys/unix.
I'll leave this issue open to verify goos and goarch work for this library after they're reimplemented.
@apesternikov I had the same issue (with grpc), and can confirm that using rules_go after #2009 unblocks your use-case.
Most helpful comment
@apesternikov I had the same issue (with grpc), and can confirm that using rules_go after #2009 unblocks your use-case.