prysm-pulse/tools/cross-toolchain
Preston Van Loon aa86c94a91
Update bazel to 5.0.0 (#10352)
* Update to bazel 5

* Add new bazel 5 experimental flags to improve remote caching

* regen cross compile for bazel 5

* gazelle

* remove some old flags

* use heremtic builds sandbox

* minimal downloads for better disk usage

* Restore manual tags for darwin builds
2022-03-14 15:05:08 +00:00
..
configs Update bazel to 5.0.0 (#10352) 2022-03-14 15:05:08 +00:00
BUILD.bazel First cut at multi-arch cross compiling toolchain (#4945) 2020-03-05 16:59:56 +00:00
cc_toolchain_config_linux_arm64.bzl.tpl First cut at multi-arch cross compiling toolchain (#4945) 2020-03-05 16:59:56 +00:00
cc_toolchain_config_osx.bzl.tpl Update rules_go (#7202) 2020-11-10 03:01:56 +00:00
cc_toolchain_config_windows.bzl.tpl Fix Windows Builds For Blst (#7803) 2020-11-13 07:17:39 +00:00
cc_toolchain.BUILD.bazel.tpl Experimental prototype of Apple M1 processor support (#10192) 2022-02-19 18:17:08 +00:00
common_osxcross.sh Remove bazel-go-ethereum fork, use upstream go-ethereum (#9725) 2021-10-19 00:00:22 +00:00
Dockerfile Updating from buster to bullseye (#10025) 2022-01-10 15:48:43 +00:00
empty.bzl First cut at multi-arch cross compiling toolchain (#4945) 2020-03-05 16:59:56 +00:00
install_clang_cross10.sh Fix All Deep Source Shell Issues and Go Issues (#8661) 2021-03-24 19:57:27 +00:00
install_osxcross.sh Remove bazel-go-ethereum fork, use upstream go-ethereum (#9725) 2021-10-19 00:00:22 +00:00
link_osxcross.sh Remove bazel-go-ethereum fork, use upstream go-ethereum (#9725) 2021-10-19 00:00:22 +00:00
prysm_toolchains.bzl First cut at multi-arch cross compiling toolchain (#4945) 2020-03-05 16:59:56 +00:00
rbe_toolchains_config.bzl Remove bazel-go-ethereum fork, use upstream go-ethereum (#9725) 2021-10-19 00:00:22 +00:00
README.md Remove Kafka from Prysm (#9470) 2021-08-26 23:59:00 +00:00
regenerate.sh Update rules_go (#7202) 2020-11-10 03:01:56 +00:00

Multiarch Cross Compiling Toolchain

Toolchain suite

This package declares a c++ toolchain suite with cross compilers for targeting four platforms:

  • linux_amd64
  • linux_arm64
  • osx_amd64
  • windows_amd64

This toolchain suite describes cross compile configuration with a Dockerfile with the appropriate host dependencies. These toolchains can be used locally (see caveats), Remote Build Execution (RBE), and in a docker sandbox (like RBE, but local).

Cross compile target support

target linux_amd64 linux_arm64 osx_amd64 windows_amd64
//beacon-chain ✔️ docker-sandbox and RBE, supported locally only ✔️ docker-sandbox and RBE ✔️ docker-sandbox ✔️ docker-sandbox
//validator ✔️ docker-sandbox and RBE ✔️ docker-sandbox and RBE ✔️ docker-sandbox ✔️

The configurations above are enforced via pull request presubmit checks.

Bazel config flag values

Use these values with --config=<flag>, multiple times if more than one value is defined in the table. Example: bazel build //beacon-chain --config=windows_amd64_docker to build windows binary in a docker sandbox.

Config linux_amd64 linux_arm64 osx_amd64 windows_amd64
Local run linux_amd64 linux_arm64 osx_amd64 windows_amd64
Docker sandbox linux_amd64_docker linux_arm64_docker osx_amd64_docker windows_amd64_docker
RBE (See Caveats) linux_amd64 and remote linux_arm64 and remote osx_amd64 and remote windows_amd64 and remote

Caveats

There are a few caveats to each of these strategies.

  • Local runs require clang compiler and the appropriate cross compilers installed. These runs should only be considered for a power user or user with specific build requirements. See the Dockerfile setup scripts to understand what dependencies must be installed and where.
  • Docker sandbox is slow. Like really slow! The purpose of the docker sandbox is to test RBE builds without deploying a full RBE system. Each build action is executed in its own container. Given the large number of small targets in this project, the overhead of creating docker containers makes this strategy the slowest of all, but requires zero additional setup.
  • Remote Build Execution is by far the fastest, if you have a RBE backend available. This is another advanced use case which will require two config flags above as well as additional flags to specify the --remote_executor. Some of these flags are present in the project .bazelrc with example values, but commented out.