Bazel configuration for RBE Necessary configuration to allow building IREE with RBE. This should eventually allow much faster continuous builds. With these changes, I am able to run: `bazel test --config=rbe -- //iree/... -//iree/hal/vulkan:dynamic_symbols_test -//iree/samples/rt:bytecode_module_api_test` and all tests pass. The two explicit excludes are tests that rely on vulkan (so are going to need a custom toolchain or GPU executors). For now I'm the only one actually authorized to do that, but auth improvements coming soon :-D I decided to unconditionally add the --experimental_guard_against_concurrent_changes and remove the advice to add it to user.bazelrc. I'm pretty sure this flag does nothing without some caching mechanism provided and is slated to be switched to default true anyway. Closes #181 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/181 from google:rbe e89ee3bd5b017827c5acf5dc58a3eebbae717dd9 PiperOrigin-RevId: 285026356
diff --git a/.bazelrc b/.bazelrc index 0705c33..3bd2caf 100644 --- a/.bazelrc +++ b/.bazelrc
@@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Required bazel flags for building IREE. - # Disable warnings we don't care about. build --copt=-Wno-unused-local-typedef @@ -31,6 +29,70 @@ # Enable some default cpu flags for x86 optimization. build:x86opt --copt=-mavx2 +############################################################################### + +# Not strictly required, but generally good flags. + +# Prevent invalid caching if input files are modified during a build. +build --experimental_guard_against_concurrent_changes + +############################################################################### + +# Configuration for building remotely using Remote Build Execution (RBE) +# https://cloud.google.com/remote-build-execution/ +# Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-1.0.0.bazelrc +# Currently in development only usable by CI. + +# Depending on how many machines are in the remote execution instance, setting +# this higher can make builds faster by allowing more jobs to run in parallel. +# Setting it too high can result in jobs that timeout, however, while waiting +# for a remote machine to execute them. +build:rbe --jobs=50 + +# Flags related to specifying the platform, toolchain and java properties. +# These flags must be adapted to work with toolchain containers other than rbe-ubuntu16-04 +# References to "rbe_default" matches rbe_autoconfig(name="rbe_default") in WORKSPACE +build:rbe --host_javabase=@rbe_default//java:jdk +build:rbe --javabase=@rbe_default//java:jdk +build:rbe --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:rbe --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:rbe --crosstool_top=@rbe_default//cc:toolchain +build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +# Platform flags: +# The toolchain container used for execution is defined in the target indicated +# by "extra_execution_platforms", "host_platform" and "platforms". +# More about platforms: https://docs.bazel.build/versions/master/platforms.html +build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain +build:rbe --extra_execution_platforms=@rbe_default//config:platform +build:rbe --host_platform=@rbe_default//config:platform +build:rbe --platforms=@rbe_default//config:platform + +build:rbe --define=EXECUTOR=remote + +# Enable remote execution so actions are performed on the remote systems. +build:rbe --remote_executor=grpcs://remotebuildexecution.googleapis.com + +# Enforce stricter environment rules, which eliminates some non-hermetic +# behavior and therefore improves both the remote cache hit rate and the +# correctness and repeatability of the build. +build:rbe --incompatible_strict_action_env=true + +# Set a higher timeout value, just in case. +build:rbe --remote_timeout=3600 + +# Enable authentication. This will pick up application default credentials by +# default. You can use --google_credentials=some_file.json to use a service +# account credential instead. +build:rbe --google_default_credentials=true + +# Local disk cache is incompatible with remote execution (for obvious reasons). +build:rbe --disk_cache="" + +# Point to the remote instance constructed in the iree-oss project +build:rbe --remote_instance_name=projects/iree-oss/instances/default_instance + +############################################################################### + # Experimental config for building on Windows via clang-cl. # As an aspiration, it may eventually not be required to manually # activate this config, but for now, it is a place to store the @@ -60,6 +122,7 @@ build:windows --experimental_enable_runfiles ############################################################################### + # Flags to make tensorflow build. # Some of these are also of general use and fine to enable globally for windows. build:windows --copt=/arch:AVX @@ -83,6 +146,7 @@ # See: http://clang-developers.42468.n3.nabble.com/Issue-with-Clang-on-Windows-and-compiler-rt-builtins-td4059230.html build:windows --linkopt=/DEFAULTLIB:clang_rt.builtins-x86_64.lib build:windows --linkopt=/DEFAULTLIB:ws2_32.lib + ############################################################################### # The user.bazelrc file is not checked in but available for local mods.
diff --git a/WORKSPACE b/WORKSPACE index 13a8c25..e36d56f 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -45,6 +45,24 @@ load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() + +############################################################################### + +############################################################################### +# bazel toolchains rules for remote execution (https://releases.bazel.build/bazel-toolchains.html). +http_archive( + name = "bazel_toolchains", + sha256 = "ca8aa49ceb47e9bee04dd67f0bec0b010032b37ebbe67147b535237e801d9a87", + strip_prefix = "bazel-toolchains-1.2.2", + urls = [ + "https://github.com/bazelbuild/bazel-toolchains/releases/download/1.2.2/bazel-toolchains-1.2.2.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.2.2.tar.gz", + ], +) + +load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") +rbe_autoconfig(name = "rbe_default") + ############################################################################### ###############################################################################
diff --git a/docs/getting_started_on_linux.md b/docs/getting_started_on_linux.md index b7992a1..78ebfdb 100644 --- a/docs/getting_started_on_linux.md +++ b/docs/getting_started_on_linux.md
@@ -108,7 +108,7 @@ replacements as needed): ``` -build --disk_cache=/REPLACE/WITH/CACHE/DIR --experimental_guard_against_concurrent_changes +build --disk_cache=/REPLACE/WITH/CACHE/DIR build:debug --compilation_mode=dbg --copt=-O2 --per_file_copt=iree@-O0 --strip=never ```
diff --git a/docs/getting_started_on_windows.md b/docs/getting_started_on_windows.md index c228326..80c7cfa 100644 --- a/docs/getting_started_on_windows.md +++ b/docs/getting_started_on_windows.md
@@ -205,7 +205,7 @@ ``` build --config=windows -build --disk_cache=c:/bazelcache --experimental_guard_against_concurrent_changes +build --disk_cache=c:/bazelcache build:debug --compilation_mode=dbg --copt=/O2 --per_file_copt=iree@/Od --strip=never ``` @@ -239,7 +239,7 @@ user.bazelrc: ``` -build --disk_cache=c:/bazelcache --experimental_guard_against_concurrent_changes +build --disk_cache=c:/bazelcache ``` ### Debugging