forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bazelrc
243 lines (205 loc) · 11.2 KB
/
.bazelrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# 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.
###############################################################################
# Common flags that apply to all configurations.
# Use sparingly for things common to all compilers and platforms.
###############################################################################
# Prevent invalid caching if input files are modified during a build.
build --experimental_guard_against_concurrent_changes
# Default to optimized builds
# Override via: "-c dbg" or --compilation_mode=dbg
build --compilation_mode=opt
# Used in TensorFlow, so we have to enable it here as well.
common --experimental_repo_remote_exec
# Actually printing output on errors is... a useful default
test --test_output=errors
# TODO: Transition to the explicit init_py mechanism. See #2405
# This is commented out while considering transition path but left as a
# breadcrumb.
# build --incompatible_default_to_explicit_init_py
# TensorFlow always sets these in OSS which makes it impossible to build TF
# without them...
build --define open_source_build=true
###############################################################################
# Options for "generic_clang" builds: these options should generally apply to
# either clang or gcc and are curated based on need.
###############################################################################
# Treat warnings in-workspace as errors.
build:generic_clang --per_file_copt=-external/.*-Werror
# ...and silence them outside of the workspace.
build:generic_clang --per_file_copt=external/.*@-w
# Disable warnings we don't care about.
build:generic_clang --copt=-Wno-unused-local-typedef
build:generic_clang --copt=-Wno-unused-private-field
build:generic_clang --copt=-Wno-unused-const-variable
# Matches upstream. Cannot impact due to extern C inclusion method.
build:generic_clang --copt=-Wno-extern-c-compat
# Technically UB but needed for intrusive ptrs
build:generic_clang --copt=-Wno-invalid-offsetof
build:generic_clang --copt=-Wno-unused-function
# Enable warnings we do care about.
build:generic_clang --copt=-Wimplicit-fallthrough
build:generic_clang --copt=-Wthread-safety-analysis
build:generic_clang --copt=-Wunused-variable
# C++14 standard version is required.
build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
# Default to adding back asserts in optimized builds.
# This is a good compromise between runtime and debugability.
build:generic_clang --copt=-UNDEBUG
###############################################################################
# Options for building with address sanitizer.
# https://github.com/google/sanitizers/wiki/AddressSanitizer
###############################################################################
# Turn on asan. Some toolchains make use of the asan feature and we'll directly
# set the appropriate opts.
build:asan --features=asan
build:asan --copt=-fsanitize=address
build:asan --linkopt=-fsanitize=address
# Don't strip debug info
build:asan --strip=never
# Ignore settings of `linkopts = ["-static"]` which can screw up the sanitizer.
# We don't use this in IREE (that's what linkstatic is for), but it could show
# up in dependencies.
build:asan --force_ignore_dash_static
# asan tests tend to take longer, so increase the timeouts
build:asan --test_timeout=120,600,1800,-1
# Make the outputs easy to find
build:asan --cc_output_directory_tag=asan
# Get better stack traces
build:asan --copt=-fno-omit-frame-pointer
# This macro define is used by absl
build:asan --copt=-DADDRESS_SANITIZER
###############################################################################
# Architecture specific options
###############################################################################
# Enable some default cpu flags for x86 optimization.
build:x86opt --copt=-mavx2
###############################################################################
# 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.
###############################################################################
# Options for connecting to the IREE GCP remote build project. These are
# repeated separately in each config to avoid warnings about configs being
# expanded more than once.
# 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
# Point to the remote instance constructed in the iree-oss project
build:rbe --remote_instance_name=projects/iree-oss/instances/default_instance
# 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.
###############################################################################
# Options for connecting to the IREE GCP remote build project. These are
# repeated separately in each config to avoid warnings about configs being
# expanded more than once.
# 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:rs --google_default_credentials=true
# Point to the remote instance constructed in the iree-oss project
build:rs --remote_instance_name=projects/iree-oss/instances/default_instance
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
###############################################################################
# Windows specific flags for building with VC.
###############################################################################
build:windows --define=iree_is_msvc=true
build:windows --copt=/wd4624 # destructor was implicitly defined as deleted
build:windows --copt=/wd4244 # possible loss of data
build:windows --copt=/wd4005 # macro redefinition
build:windows --copt=/wd4267 # initializing: possible loss of data
build:windows --copt=/wd4141 # inline used more than once
build:windows --per_file_copt=mkl_dnn@/wd4551 # missing argument list
build:windows --per_file_copt=mkl_dnn@/wd4068 # unknown pragma
build:windows --per_file_copt=farmhash@/wd4319 # zero extending to T of greater size
build:windows --linkopt=/IGNORE:4217 # mismatch import/export declspec
# 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
build:windows --per_file_copt=protobuf@-w
# 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
# Necessary for M_* math constants.
build:windows --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES
# Workaround WinGDI.h defining `ERROR`, which conflicts with logging macros.
# Note that IREE and TensorFlow both `#undef ERROR` and define their own
# separate logging constants with the same name, but IREE needs the Windows
# "graphics device interface" (GDI) for certain GUI sample projects.
build:windows --per_file_copt=tensorflow@-DNOGDI
# Disables TensorFlow eigen bloat and reduces compile times.
build:windows --define=override_eigen_strong_inline=true
# Another TensorFlow flag from their config script.
build:windows --define with_default_optimizations=true
###############################################################################
# Run the configure_bazel.py script to generate.
try-import %workspace%/configured.bazelrc
# 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