-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bazelrc
178 lines (147 loc) · 6.27 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
# Bazel configuration file.
#
# ----CONFIG OPTIONS----
# MacOSX options
# darwin_arm64:
#
# Compiler options:
# c++17: Build with C++17 options (links with libc++)
# c++17_gcc: Build with C++17 options (links with stdlibc++)
# avx_linux: Build with avx instruction set on linux.
# avx2_linux: Build with avx2 instruction set on linux.
# native_arch_linux: Build with instruction sets available to the host machine on linux
# avx_windows: Build with avx instruction set on windows
# avx2_windows: Build with avx2 instruction set on windows
#
# Other build options:
# short_logs: Only log errors during build, skip warnings.
# verbose_logs: Show all compiler warnings during build.
# libc++: Link against libc++ instead of stdlibc++
# asan: Build with the clang address sanitizer
# msan: Build with the clang memory sanitizer
# ubsan: Build with the clang undefined behavior sanitizer
# dbg: Build with debug info
#
#
# Release build options (for all operating systems)
# release_base: Common options for all builds on all operating systems.
# release_cpu_linux: Toolchain for Linux CPU builds.
# release_cpu_macos: Toolchain for MacOS CPU builds.
# release_cpu_windows: Toolchain for Windows CPU builds.
# 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=use_fast_cpp_protos=true
build --define=allow_oversize_protos=true
build --define=grpc_no_ares=true
build --enable_platform_specific_config
# Default options should come above this line.
# Settings for different C++ dialects
build:c++17 --cxxopt=-std=c++17
build:c++17_windows --cxxopt=/std:c++17
build:c++20 --cxxopt=-std=c++20
build:c++20_windows --cxxopt=/std:c++20
build:c++2a --cxxopt=-std=c++2a
build:c++2a_windows --cxxopt=/std:c++latest
# Allow builds using libc++ as a linker library
build:libc++ --action_env=CC
build:libc++ --action_env=CXX
build:libc++ --action_env=CXXFLAGS=-stdlib=libc++
build:libc++ --action_env=PATH
build:libc++ --define force_libcpp=enabled
build:libc++ --linkopt -fuse-ld=lld
build:libc++ --cxxopt=-stdlib=libc++
# 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
# Settings for MacOS on ARM CPUs.
build:macos_arm64 --cpu=darwin_arm64
# 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
build:windows --cxxopt=/Zc:__cplusplus
# 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
# On windows, we never cross compile
build:windows --distinct_host_configuration=false
# On linux, don't cross compile by default
build:linux --distinct_host_configuration=false
# 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(james): 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:avx2_linux --copt=-mavx2
build:native_arch_linux --copt=-march=native
build:avx_windows --copt=/arch:AVX
build:avx2_windows --copt=/arch:AVX2
# Config-specific options should come above this line.
# Load rc file with user-specific options.
try-import %workspace%/.bazelrc.user
# Here are bazelrc configs for release builds
build:release_base --distinct_host_configuration=false
test:release_base --test_size_filters=small,medium
build:release_cpu_linux --config=release_base
build:release_cpu_linux --config=avx2_linux
test:release_cpu_linux --test_env=LD_LIBRARY_PATH
build:release_cpu_macos --config=release_base
build:release_cpu_macos --config=avx2_linux
build:release_cpu_windows --config=release_base
build:release_cpu_windows --config=avx2_windows
build:release_cpu_windows --define=no_tensorflow_py_deps=true
# First available in VS 16.4. Speeds Windows compile times by a lot. See
# https://groups.google.com/a/tensorflow.org/d/topic/build/SsW98Eo7l3o/discussion
build:release_cpu_windows --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions
# Address sanitizer
# CC=clang bazel build --config asan
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -g
build:asan --copt -O3
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
# Memory sanitizer
# CC=clang bazel build --config msan
build:msan --strip=never
build:msan --copt -fsanitize=memory
build:msan --copt -DMEMORY_SANITIZER
build:msan --copt -g
build:msan --copt -O3
build:msan --copt -fno-omit-frame-pointer
build:msan --linkopt -fsanitize=memory
# Undefined Behavior Sanitizer
# CC=clang bazel build --config ubsan
build:ubsan --strip=never
build:ubsan --copt -fsanitize=undefined
build:ubsan --copt -DUNDEFINED_BEHAVIOR_SANITIZER
build:ubsan --copt -g
build:ubsan --copt -O3
build:ubsan --copt -fno-omit-frame-pointer
build:ubsan --linkopt -fsanitize=undefined
build:ubsan --linkopt -lubsan