-
Notifications
You must be signed in to change notification settings - Fork 13
/
.bazelrc
361 lines (303 loc) · 13.8 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# LiteRT Bazel configuration file.
# This file tries to group and simplify build options for LiteRT
#
# ----CONFIG OPTIONS----
# Android options:
# android:
# android_arm:
# android_arm64:
# android_x86:
# android_x86_64:
#
# iOS options:
# ios:
# ios_armv7:
# ios_arm64:
# ios_x86_64:
# ios_fat:
#
# Macosx options
# darwin_arm64:
#
# Compiler options:
# avx_linux: Build with avx instruction set on linux.
# avx_win: Build with avx instruction set on windows
#
# Other build options:
# short_logs: Only log errors during build, skip warnings.
# verbose_logs: Show all compiler warnings during build.
# monolithic: Build all TF C++ code into a single shared object.
# dynamic_kernels: Try to link all kernels dynamically (experimental).
# dbg: Build with debug info
#
# TF version options;
# v2: Build TF v2
#
# Embedded Linux options (experimental and only tested with TFLite build yet)
# elinux: General Embedded Linux options shared by all flavors.
# elinux_aarch64: Embedded Linux options for aarch64 (ARM64) CPU support.
# elinux_armhf: Embedded Linux options for armhf (ARMv7) CPU support.
#
# Default build options. These are applied first and unconditionally.
# For projects which use TensorFlow as part of a Bazel build process, putting
# nothing in a bazelrc will default to a monolithic build. The following line
# opts in to modular op registration support by default.
build --define framework_shared_object=true
build --define tsl_protobuf_header_only=true
build --define=use_fast_cpp_protos=true
build --define=allow_oversize_protos=true
build --spawn_strategy=standalone
build -c opt
# Make Bazel print out all options from rc files.
build --announce_rc
# TODO(mihaimaruseac): Document this option or remove if no longer needed
build --define=grpc_no_ares=true
# See https://github.com/bazelbuild/bazel/issues/7362 for information on what
# --incompatible_remove_legacy_whole_archive flag does.
# This flag is set to true in Bazel 1.0 and newer versions. We tried to migrate
# Tensorflow to the default, however test coverage wasn't enough to catch the
# errors.
# There is ongoing work on Bazel team's side to provide support for transitive
# shared libraries. As part of migrating to transitive shared libraries, we
# hope to provide a better mechanism for control over symbol exporting, and
# then tackle this issue again.
#
# TODO: Remove the following two lines once TF doesn't depend on Bazel wrapping
# all library archives in -whole_archive -no_whole_archive.
build --noincompatible_remove_legacy_whole_archive
build --features=-force_no_whole_archive
# TODO(mihaimaruseac): Document this option or remove if no longer needed
build --enable_platform_specific_config
# Enable XLA support by default.
build --define=with_xla_support=true
# TODO(mihaimaruseac): Document this option or remove if no longer needed
build --config=short_logs
# TF now has `cc_shared_library` targets, so it needs the experimental flag
# TODO(rostam): Remove when `cc_shared_library` is enabled by default
build --experimental_cc_shared_library
# cc_shared_library ensures no library is linked statically more than once.
build --experimental_link_static_libraries_once=false
# Prevent regressions on those two incompatible changes
# TODO: remove those flags when they are flipped in the default Bazel version TF uses.
build --incompatible_enforce_config_setting_visibility
# TODO: also enable this flag after fixing the visibility violations
# build --incompatible_config_setting_private_default_visibility
# Default options should come above this line.
# Android configs. Bazel needs to have --cpu and --fat_apk_cpu both set to the
# target CPU to build transient dependencies correctly. See
# https://docs.bazel.build/versions/master/user-manual.html#flag--fat_apk_cpu
build:android --crosstool_top=//external:android/crosstool
build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:android_arm --config=android
build:android_arm --cpu=armeabi-v7a
build:android_arm --fat_apk_cpu=armeabi-v7a
build:android_arm64 --config=android
build:android_arm64 --cpu=arm64-v8a
build:android_arm64 --fat_apk_cpu=arm64-v8a
build:android_x86 --config=android
build:android_x86 --cpu=x86
build:android_x86 --fat_apk_cpu=x86
build:android_x86_64 --config=android
build:android_x86_64 --cpu=x86_64
build:android_x86_64 --fat_apk_cpu=x86_64
# Build everything statically for Android since all static libs are later
# bundled together into a single .so for deployment.
build:android --dynamic_mode=off
# TODO(belitskiy): Remove once on Clang 20.
build:android --define=xnn_enable_avxvnniint8=false
# Sets the default Apple platform to macOS.
build:macos --apple_platform_type=macos
# gRPC on MacOS requires this #define
build:macos --copt=-DGRPC_BAZEL_BUILD
# Avoid hitting command line argument limit
build:macos --features=archive_param_file
# Settings for MacOS on ARM CPUs.
build:macos_arm64 --cpu=darwin_arm64
build:macos_arm64 --macos_minimum_os=11.0
# iOS configs for each architecture and the fat binary builds.
build:ios --apple_platform_type=ios
build:ios --apple_bitcode=embedded --copt=-fembed-bitcode
build:ios --copt=-Wno-c++11-narrowing
build:ios_armv7 --config=ios
build:ios_armv7 --cpu=ios_armv7
build:ios_arm64 --config=ios
build:ios_arm64 --cpu=ios_arm64
build:ios_arm64e --config=ios
build:ios_arm64e --cpu=ios_arm64e
build:ios_sim_arm64 --config=ios
build:ios_sim_arm64 --cpu=ios_sim_arm64
build:ios_x86_64 --config=ios
build:ios_x86_64 --cpu=ios_x86_64
build:ios_fat --config=ios
build:ios_fat --ios_multi_cpus=armv7,arm64,i386,x86_64
# Config to use a mostly-static build and disable modular op registration
# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
# By default, TensorFlow will build with a dependence on
# //tensorflow:libtensorflow_framework.so.
build:monolithic --define framework_shared_object=false
build:monolithic --define tsl_protobuf_header_only=false
build:monolithic --experimental_link_static_libraries_once=false # b/229868128
# Debug config
build:dbg -c dbg
# Only include debug info for files under tensorflow/, excluding kernels, to
# reduce the size of the debug info in the binary. This is because if the debug
# sections in the ELF binary are too large, errors can occur. See
# https://github.com/tensorflow/tensorflow/issues/48919.
# Users can still include debug info for a specific kernel, e.g. with:
# --config=dbg --per_file_copt=+tensorflow/core/kernels/identity_op.*@-g
# Since this .bazelrc file is synced between the tensorflow/tensorflow repo and
# the openxla/xla repo, also include debug info for files under xla/.
build:dbg --per_file_copt=+.*,-tensorflow.*,-xla.*@-g0
build:dbg --per_file_copt=+tensorflow/core/kernels.*@-g0
# for now, disable arm_neon. see: https://github.com/tensorflow/tensorflow/issues/33360
build:dbg --cxxopt -DTF_LITE_DISABLE_X86_NEON
# AWS SDK must be compiled in release mode. see: https://github.com/tensorflow/tensorflow/issues/37498
build:dbg --copt -DDEBUG_BUILD
# Options to disable default on features
build:nogcp --define=no_gcp_support=true
build:nonccl --define=no_nccl_support=true
# Modular TF build options
build:dynamic_kernels --define=dynamic_loaded_kernels=true
build:dynamic_kernels --copt=-DAUTOLOAD_DYNAMIC_KERNELS
# Don't trigger --config=<host platform> when cross-compiling.
build:android --noenable_platform_specific_config
build:ios --noenable_platform_specific_config
# Suppress all C++ compiler warnings, otherwise build logs become 10s of MBs.
build:android --copt=-w
build:ios --copt=-w
build:linux --host_copt=-w
build:macos --copt=-w
build:windows --copt=/W0
build:windows --host_copt=/W0
# Suppress most C++ compiler warnings to reduce log size but allow
# for specific warnings to still be present.
build:linux --copt="-Wno-all"
build:linux --copt="-Wno-extra"
build:linux --copt="-Wno-deprecated"
build:linux --copt="-Wno-deprecated-declarations"
build:linux --copt="-Wno-ignored-attributes"
build:linux --copt="-Wno-array-bounds"
# Add unused-result as an error on Linux.
build:linux --copt="-Wunused-result"
build:linux --copt="-Werror=unused-result"
# Add switch as an error on Linux.
build:linux --copt="-Wswitch"
build:linux --copt="-Werror=switch"
# Linux ARM64 specific options
build:linux_arm64 --copt="-mtune=generic" --copt="-march=armv8-a" --copt="-O3"
# On Windows, `__cplusplus` is wrongly defined without this switch
# See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
build:windows --copt=/Zc:__cplusplus
build:windows --host_copt=/Zc:__cplusplus
# Tensorflow uses M_* math constants that only get defined by MSVC headers if
# _USE_MATH_DEFINES is defined.
build:windows --copt=/D_USE_MATH_DEFINES
build:windows --host_copt=/D_USE_MATH_DEFINES
# Windows has a relatively short command line limit, which TF has begun to hit.
# See https://docs.bazel.build/versions/main/windows.html
build:windows --features=compiler_param_file
build:windows --features=archive_param_file
# Speed Windows compile times. Available in VS 16.4 (we are on 16.11). See
# https://groups.google.com/a/tensorflow.org/d/topic/build/SsW98Eo7l3o/discussion
build:windows --copt=/d2ReducedOptimizeHugeFunctions
build:windows --host_copt=/d2ReducedOptimizeHugeFunctions
# Before VS 2017 15.8, the member "type" would non-conformingly have an
# alignment of only alignof(max_align_t). VS 2017 15.8 was fixed to handle this
# correctly, but the fix inherently changes layout and breaks binary
# compatibility (*only* for uses of aligned_storage with extended alignments).
build:windows --copt=-D_ENABLE_EXTENDED_ALIGNED_STORAGE
build:windows --host_copt=-D_ENABLE_EXTENDED_ALIGNED_STORAGE
# Enable the runfiles symlink tree on Windows. This makes it possible to build
# the pip package on Windows without an intermediate data-file archive, as the
# build_pip_package script in its current form (as of Aug 2023) uses the
# runfiles symlink tree to decide what to put into the Python wheel.
startup --windows_enable_symlinks
build:windows --enable_runfiles
# Default paths for TF_SYSTEM_LIBS
build:linux --define=PREFIX=/usr
build:linux --define=LIBDIR=$(PREFIX)/lib
build:linux --define=INCLUDEDIR=$(PREFIX)/include
build:linux --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include
build:macos --define=PREFIX=/usr
build:macos --define=LIBDIR=$(PREFIX)/lib
build:macos --define=INCLUDEDIR=$(PREFIX)/include
build:macos --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include
# TF_SYSTEM_LIBS do not work on windows.
# By default, build TF in C++ 17 mode.
build:android --cxxopt=-std=c++17
build:android --host_cxxopt=-std=c++17
build:ios --cxxopt=-std=c++17
build:ios --host_cxxopt=-std=c++17
build:linux --cxxopt=-std=c++17
build:linux --host_cxxopt=-std=c++17
build:macos --cxxopt=-std=c++17
build:macos --host_cxxopt=-std=c++17
build:windows --cxxopt=/std:c++17
build:windows --host_cxxopt=/std:c++17
# On windows, we still link everything into a single DLL.
build:windows --config=monolithic
# On linux, we dynamically link small amount of kernels
build:linux --config=dynamic_kernels
# Make sure to include as little of windows.h as possible
build:windows --copt=-DWIN32_LEAN_AND_MEAN
build:windows --host_copt=-DWIN32_LEAN_AND_MEAN
build:windows --copt=-DNOGDI
build:windows --host_copt=-DNOGDI
# MSVC (Windows): Standards-conformant preprocessor mode
# See https://docs.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview
build:windows --copt=/Zc:preprocessor
build:windows --host_copt=/Zc:preprocessor
# Misc build options we need for windows.
build:windows --linkopt=/DEBUG
build:windows --host_linkopt=/DEBUG
build:windows --linkopt=/OPT:REF
build:windows --host_linkopt=/OPT:REF
build:windows --linkopt=/OPT:ICF
build:windows --host_linkopt=/OPT:ICF
# Verbose failure logs when something goes wrong
build:windows --verbose_failures
# Work around potential issues with large command lines on windows.
# See: https://github.com/bazelbuild/bazel/issues/5163
build:windows --features=compiler_param_file
# Do not risk cache corruption. See:
# https://github.com/bazelbuild/bazel/issues/3360
build:linux --experimental_guard_against_concurrent_changes
# Configure short or long logs
build:short_logs --output_filter=DONT_MATCH_ANYTHING
build:verbose_logs --output_filter=
# Instruction set optimizations
# TODO(gunan): Create a feature in toolchains for avx/avx2 to
# avoid having to define linux/win separately.
build:avx_linux --copt=-mavx
build:avx_linux --host_copt=-mavx
build:avx_win --copt=/arch:AVX
# Enable all targets in XLA
build:cpu_cross --define=with_cross_compiler_support=true
# Disable XLA on mobile.
build:xla --define=with_xla_support=true # TODO: remove, it's on by default.
build:android --define=with_xla_support=false
build:ios --define=with_xla_support=false
# Flag to enable remote config
common --experimental_repo_remote_exec
# TFLite build configs for generic embedded Linux
build:elinux --crosstool_top=@local_config_embedded_arm//:toolchain
build:elinux --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:elinux_aarch64 --config=elinux
build:elinux_aarch64 --cpu=aarch64
build:elinux_armhf --config=elinux
build:elinux_armhf --cpu=armhf
build:elinux_armhf --copt -mfp16-format=ieee
# Config-specific options should come above this line.
# Load rc file written by ./configure.
try-import %workspace%/.tf_configure.bazelrc
try-import %workspace%/xla_configure.bazelrc
# Load rc file with user-specific options.
try-import %workspace%/.bazelrc.user
# Try to load the XLA warnings config if available
try-import %workspace%/warnings.bazelrc
# Options to build TensorFlow 1.x or 2.x.
build:v2 --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
build --config=v2
# Options to filter filepath prefixes when generating python api's
build:litert_prefixes --define=litert_prefixes="external/org_tensorflow/"
build --config=litert_prefixes