bazel-contrib / bazel-contrib/rules_go

In mixed programming language projects, cross-compile and use the same C++ toolchain

Open
#2,591 12 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Go
Stars
1.5k
Forks
762
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?
```
v0.23.6
```
### What version of gazelle are you using?
```
v0.21.1
```

### What version of Bazel are you using?
```
Build label: 3.3.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 30 15:09:23 2020 (1593529763)
Build timestamp: 1593529763
Build timestamp as int: 1593529763
```

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

Yes

### What operating system and processor architecture are you using?

```
$ echo $MACHTYPE
x86_64-pc-linux-gnu
```

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

- A local linux arm toolchain

### What did you do?

For a mixed project of `C++` and `Go`, I want to achieve cross compilation, and the two programming languages share the C++ cross compilation toolchain. Is there a way to use the following commands to achieve one-time compilation? eg:

Able to compile successfully in two steps, but not share a compiler:

```bash
# build cpp language
$ bazel build --platforms=//platforms:custom_platform //cpp
# build golang language
$ bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //golang
```

I want to compile successfully in one step, and use the same compiler:

```bash
$ bazel build --platforms=//platforms:custom_platform //...
```

Demo project: [https://github.com/yicm/BazelMixedLanguage/](https://github.com/yicm/BazelMixedLanguage/)

### What did you expect to see?

```
build all success
```

### What did you see instead?

```
ERROR: While resolving toolchains for target //golang/cmd/hello:hello: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
ERROR: Analysis of target '//golang/cmd/hello:hello' failed; build aborted: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked BazelMixedLanguage demo and reproduce the combined `bazel build --platforms=//platforms:custom_platform //...` command. Read the rules_go toolchain configuration and the custom platform definition, then compare them with the failing `@io_bazel_rules_go//go:toolchain` resolution. Done means the mixed C++ and Go build resolves successfully with the intended Linux ARM C++ toolchain.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, go
Domain
build-system
Issue type
Feature
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.