blob: 01400dd0fb8cdba0201de6f1627d0eb10e693b7c [file] [log] [blame]
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Disable warnings we don't care about.
build --copt=-Wno-unused-local-typedef
# C++14 standard version is required.
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
# Default to an optimized build.
# Override via: "-c dbg" or --compilation_mode=dbg
build --compilation_mode=opt
# Disable visibility checks (works around some private deps in TensorFlow that
# are being unbundled soon anyway).
build --nocheck_visibility
# 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
###############################################################################
# Options for connecting to the IREE GCP remote build project.
# 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:gcp --google_default_credentials=true
# Point to the remote instance constructed in the iree-oss project
build:gcp --remote_instance_name=projects/iree-oss/instances/default_instance
###############################################################################
# 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.
# Set up connections to GCP project.
build:rbe --config=gcp
# 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
# Local disk cache is incompatible with remote execution (for obvious reasons).
build:rbe --disk_cache=""
###############################################################################
# Configuration for uploading build results to Result Store UI
# https://cloud.google.com/remote-build-execution/docs/results-ui/getting-started-results-ui
# Can be used either with or without --config=rbe.
build:rs --config=gcp
build:rs --bes_backend="buildeventservice.googleapis.com"
build:rs --bes_results_url="https://source.cloud.google.com/results/invocations/"
build:rs --project_id=iree-oss
###############################################################################
# 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
# set of flags and tweaks needed to get the Windows build working.
# Note that this is intended to work with clang-cl, not the Visual
# Studio compiler. The following must be performed prior to invoking
# Bazel:
# * Install Visual Studio Build Tools
# * export USE_CLANG_CL=1
# * export BAZEL_LLVM=C:/Users/$USER/scoop/apps/llvm/current
# (or actual LLVM install location)
# Then one can build with:
# bazel build --config=windows {targets...}
# Works around __TIME__ __DATE__, etc redefinitions and -std=c++14
# warnings.
build:windows --copt=-Wno-builtin-macro-redefined --host_copt=-Wno-builtin-macro-redefined
build:windows --copt=-Wno-unknown-argument --host_copt=-Wno-unknown-argument
# Avoid warnings for WIN32_LEAN_AND_MEAN being defined multiple times.
build:windows --copt=-Wno-macro-redefined
# Enables unix-style runfiles link trees (requires symlink permission).
# See: https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
# Generally: Enable Developer Mode in the Developer Settings page of the
# system settings.
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
# Host and target are the same in windows so don't waste time building both.
build:windows --distinct_host_configuration=false
# Avoids incompatible versions of winsock and other badness.
build:windows --copt=/DWIN32_LEAN_AND_MEAN --host_copt=/DWIN32_LEAN_AND_MEAN
# That is one way to have less warnings :(
build:windows --per_file_copt=tensorflow@-w
# This is used a lot and shouldn't be an error.
build:windows --per_file_copt=tensorflow@-Wno-microsoft-unqualified-friend
# Why are min/max macros? No one knows.
build:windows --copt=/DNOMINMAX --host_copt=/DNOMINMAX
# Yay for security warnings. Boo for non-standard.
build:windows --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
# TensorFlow requires the "monolithic" build mode for now on Windows.
build:windows --define framework_shared_object=false
# TODO(laurenzo): Clang uses runtime functions for 128bit math that require the
# rt library and there is not a convenient way to link it. Figure out how to
# do the following:
# 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.
# Always keep this at the end of the file so that user flags override.
try-import %workspace%/user.bazelrc