bazel-contrib / bazel-contrib/rules_go

Issue compiling linux binary on MacOS

Open
#2,014 3 comments 0 reactions 0 assignees View on GitHub
bug cross-compilation
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

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.

### What version of rules_go are you using?
0.18.1

### What version of gazelle are you using?
N/A

### What version of Bazel are you using?
0.22.0-homebrew
0.23.2-homebrew

### Does this issue reproduce with the latest releases of all the above?
Yes

### What operating system and processor architecture are you using?
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

### Any other potentially useful information about your toolchain?

### What did you do?
git clone https://github.com/apesternikov/poc-bazel-690.git
cd poc-bazel-690
bazel build ...

### What did you expect to see?
Successful compilation of bazel-poc-690 and bazel-poc-690-linux binaries.

### What did you see instead?
```
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
```

Contributor guide

Open the contributing guide

Research direction

Clone apesternikov/poc-bazel-690 and start by running `bazel build ...` on macOS with the listed rules_go and Bazel versions. Inspect external/org_golang_google_grpc/internal/syscall/BUILD.bazel and syscall_linux.go around the reported strict-dependency failure. Done means both bazel-poc-690 and bazel-poc-690-linux compile successfully.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.