forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bazelrc
258 lines (209 loc) · 11 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
##
## Workarounds for bugs and temporary things
##
try-import .bazelrc.local
startup --host_jvm_args=-Xmx3072m # we need at least 3G to reliably build, the default is to use 1/4 of memory, which makes flaky on 8G boxes
common --incompatible_package_name_is_a_function=false # https://github.com/protocolbuffers/protobuf/issues/5547
# enable https://github.com/google/googletest/pull/1653
common:build --define absl=1
common:test --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1
##
## Custom toolchain.
##
build --crosstool_top=@llvm_toolchain//:toolchain
test --crosstool_top=@llvm_toolchain//:toolchain
##
## Common build options across all build configurations
##
# C / C++ Options
# Don't depend on system compiler
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
# Developer laptops run skylake, devboxes run skylake-avx512
# however some AWS instances in our fleet still run Sandy Bridge (Skylake predecessor)
build --copt=-march=sandybridge
build --cxxopt=-march=sandybridge
build --copt=-fno-omit-frame-pointer
build --cxxopt=-fno-omit-frame-pointer
build --copt=-fstack-protector
build --cxxopt=-fstack-protector
build --copt=-Werror --copt=-Wimplicit-fallthrough
build --cxxopt=-Werror --cxxopt=-Wimplicit-fallthrough
build --host_cxxopt=-O1
build --host_copt=-O1
build --host_cxxopt=-DFORCE_DEBUG
build --host_copt=-DFORCE_DEBUG
build --host_cxxopt=-Wno-unused-variable --host_cxxopt=-Wno-overloaded-virtual --host_cxxopt=-Wno-unused-const-variable # ragel violates those and we want a silent build
build --host_cxxopt=-Wno-pass-failed # host build doesn't have enough optimizations enabled for clang to vectorize this loop reliably
# The MacOS CROSSTOOL in bazel defines _FORTIFY_SOURCE both on
# <command line>:1:9: and <built-in>:355:9: so sadly we turn them all off
build --copt=-Wno-macro-redefined
build --cxxopt=-Wno-macro-redefined
##
## debug configuration
##
build:dbg --copt=-O0
build:dbg --cxxopt=-O0
build:dbg --compilation_mode=dbg
build:dbg --config=debugsymbols
build:coverage --config=forcedebug
build:coverage --cxxopt=-Wno-pass-failed # coverage build fails vectorization
test:coverage --spawn_strategy=standalone
build --define=versioned=false
build:versioned --workspace_status_command=tools/buildstamp/get_workspace_status --stamp --define=versioned=true
##
## Configurations used for releases
##
# release version: optimized, with debug symbols and version information
build:release-common --define release=true
build:release-common --define jemalloc=true
build:release-common --compilation_mode=opt
build:release-common --config=debugsymbols
build:release-common --config=static-libs
build:release-common --config=versioned
# harden: mark relocation sections read-only
build:release-linux --linkopt=-Wl,-z,relro,-z,now
build:release-linux --config=lto-linux --config=release-common
build:release-mac --config=release-common
build:release-debug-linux --config=release-linux
build:release-debug-linux --config=forcedebug
build:release-debug-linux --config=dbg
build:release-debug-mac --config=release-mac
build:release-debug-mac --config=forcedebug
build:release-debug-mac --config=dbg
build:release-sanitized-linux --copt=-O2 --cxxopt=-O2
build:release-sanitized-linux --config=sanitize-linux
build:release-sanitized-linux --define jemalloc=false
build:release-sanitized-linux --config=debugsymbols
build:release-sanitized-linux --config=forcedebug
build:release-sanitized-mac --copt=-O2 --cxxopt=-O2
build:release-sanitized-mac --config=forcedebug
build:release-sanitized-mac --config=debugsymbols
build:release-sanitized-mac --config=sanitize-mac
build:release-sanitized-mac --define jemalloc=false
##
## Configuration used to to as much testing as possible in CI
##
build:test-sanitized-linux --config=release-sanitized-linux --config=dbg --nostamp --define release=false
test:test-sanitized-linux --config=release-sanitized-linux --config=dbg --nostamp --define release=false
test:test-sanitized-linux --test_env="UBSAN_OPTIONS=print_stacktrace=1"
test:test-sanitized-linux --test_env="ASAN_OPTIONS=detect_leaks=0"
build:test-sanitized-mac --config=release-sanitized-mac --config=dbg --nostamp --define release=false
test:test-sanitized-mac --config=release-sanitized-mac --config=dbg --nostamp --define release=false
test:test-sanitized-mac --test_env="UBSAN_OPTIONS=print_stacktrace=1"
build:reduce-intermediate-file-size --copt=-g0 --linkopt=-g0 --cxxopt=-g0 # used by buildfarm to have less debug information on disk
build:reduce-intermediate-file-size --copt=-Os --linkopt=-Os --cxxopt=-Os
build:reduce-intermediate-file-size --strip=always
build:reduce-intermediate-file-size --copt=-fno-standalone-debug --linkopt=-fno-standalone-debug --cxxopt=-fno-standalone-debug # used by buildfarm to have less debug information on disk
build:reduce-intermediate-file-size --config=shared-libs
build:buildfarm --curses=no --config=reduce-intermediate-file-size
test:buildfarm --curses=no --config=reduce-intermediate-file-size
test:buildfarm --test_output=errors
build:buildfarm-sanitized-linux --config=test-sanitized-linux --config=buildfarm
test:buildfarm-sanitized-linux --config=test-sanitized-linux --config=buildfarm
build:buildfarm-sanitized-mac --config=test-sanitized-mac --config=buildfarm
test:buildfarm-sanitized-mac --config=test-sanitized-mac --config=buildfarm
build:travis --config=test-sanitized-linux
build:travis --curses=no
test:travis --ram_utilization_factor=10
test:travis --test_strategy=standalone
test:travis --curses=no
test:travis --test_output=errors
##
## Shared fragments of configuration
##
# DEBUG_MODE is set by default for all builds except --config=release.
# Use this flag to set DEBUG_MODE even for --config=release.
build:forcedebug --copt=-DFORCE_DEBUG
build:forcedebug --cxxopt=-DFORCE_DEBUG
# LTO build. Much longer compilation time. Smaller size and better perf.
build:lto --copt=-flto=thin
build:lto --cxxopt=-flto=thin
build:lto --linkopt=-flto=thin
build:lto --config=static-libs
## flags that substantially increase Clang&LLVMs ability to devirtualize calls
build:lto-linux --linkopt=-Wl,--icf=all
build:lto-linux --config=lto
# By default, we make static builds, but we can also use dynamic linking if asked to.
# Note that dynamic linking is not fully supported by some of our toolchains and thus it may not always work.
build --define=linkshared=false
build:shared-libs --define=linkshared=true --cxxopt=-fPIC --copt=-fPIC --linkopt=-fPIC
# By default, we make dynamicly linked builds, while release builds are statically linked.
# Note that dynamic linking is not fully supported by some of our toolchains and thus it may not always work.
# Still, we try to use it by default as it has lower iteration time in dev
build --define=linkshared=true --cxxopt=-fPIC --copt=-fPIC --linkopt=-fPIC
build:static-libs --define=linkshared=false --cxxopt=-fno-PIC --copt=-fno-PIC --linkopt=-fno-PIC
build:static-libs --linkopt=-fno-pie --copt=-fno-pie --cxxopt=-fno-pie
# It's useful to be able to write `config_setting` rules for "this is
# an unsanitized build", but we can't express "copt does not contain
# -fsanitize". So we set this `--define` and unset it if we're using a
# sanitizer.
build --define unsanitized=true
# sanitize build: run with ASAN and UBSAN. Catches most memory and
# undefined-behavior errors, substantially larger and slower binary.
build:sanitize --config=asan --config=ubsan
build:asan --copt=-fsanitize=address --copt=-fsanitize-address-use-after-scope
build:asan --cxxopt=-fsanitize=address --cxxopt=-fsanitize-address-use-after-scope
build:asan --linkopt=-fsanitize=address --linkopt=-fsanitize-address-use-after-scope
build:asan --cxxopt=-DADDRESS_SANITIZER # used by abseil
build:asan --cxxopt=-DHAS_SANITIZER
build:asan --define unsanitized=false
build:ubsan --copt=-fsanitize=undefined --copt=-fno-sanitize-recover=undefined
build:ubsan --cxxopt=-fsanitize=undefined --copt=-fno-sanitize-recover=undefined
build:ubsan --linkopt=-fsanitize=undefined --copt=-fno-sanitize-recover=undefined
build:ubsan --define unsanitized=false
build:ubsan --cxxopt=-DHAS_SANITIZER
# Bazel links C++ files with $CC, not $CXX, this breaks UBSan
build:sanitize-linux --linkopt=external/llvm_toolchain/lib/clang/8.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
test:sanitize-linux --linkopt=external/llvm_toolchain/lib/clang/8.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
build:sanitize-linux --linkopt=external/llvm_toolchain/lib/clang/8.0.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a
build:sanitize-linux --linkopt=external/llvm_toolchain/lib/clang/8.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a
build:sanitize-linux --config=sanitize
test:sanitize-linux --config=sanitize
build:sanitize-mac --config=sanitize
test:sanitize-mac --config=sanitize
build:tsan --copt=-fsanitize=thread
build:tsan --cxxopt=-fsanitize=thread
build:tsan --linkopt=-fsanitize=thread
# Build optimized for executable size. Can be faster if size of executable code is a bottleneck.
build:size --linkopt=-Os --config=lto
build:size --copt=-Os --config=lto
### Debug symbols on OS X. ###
# From https://github.com/RobotLocomotion/drake/blob/master/tools/cc_toolchain/bazel.rc
# See https://github.com/bazelbuild/bazel/issues/2537
build:debugsymbols --copt=-g3 --copt=-fstandalone-debug --copt=-DDEBUG_SYMBOLS --copt=-glldb
build:debugsymbols --cxxopt=-g3 --cxxopt=-fstandalone-debug --cxxopt=-DDEBUG_SYMBOLS --cxxopt=-glldb
build:debugsymbols --linkopt=-g3 --linkopt=-fstandalone-debug --linkopt=-DDEBUG_SYMBOLS --linkopt=-glldb
build:debugsymbols --spawn_strategy=standalone
build:debugsymbols --genrule_strategy=standalone
build --strip=never
# Enable nice UIs. Taken from bazel.rc of Bazel itself.
common --experimental_ui --experimental_ui_actions_shown 8
common --show_progress_rate_limit=0.25
##
## Fuzzing
##
build:fuzz --copt=-fsanitize=fuzzer --cxxopt=-fsanitize=fuzzer --linkopt=-fsanitize=fuzzer --config=asan
build:fuzz --config=forcedebug --config=debugsymbols
build:fuzz --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION --cxxopt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
##
## Webasm config. Please use either of those depending on your platform
##
build:webasm-linux --crosstool_top=//tools/toolchain/webasm-linux --config=webasm
build:webasm-darwin --crosstool_top=//tools/toolchain/webasm-darwin --config=webasm
# common webasm config
# Use --cpu as a differentiator.
build:webasm --cpu=webasm --spawn_strategy=standalone --genrule_strategy=standalone --copt=-Oz --cxxopt=-Oz --linkopt=-Oz --copt=-DMDB_USE_ROBUST=0 --cxxopt=-DMDB_USE_ROBUST=0
build:webasm --define release=true
build:webasm --config=versioned
build:webasm --compilation_mode=opt
build:webasm --copt=-DNDEBUG --cxxopt=-DNDEBUG --linkopt=-DNDEBUG # for some reason emscripten doesn't pass those when -O2\-Oz are specified
build:webasm --copt=--llvm-lto --copt=3 --cxxopt=--llvm-lto --cxxopt=3 --linkopt=--llvm-lto --linkopt=3
# Specify a "sane" C++ toolchain for the host platform.
build:webasm --host_crosstool_top=@llvm_toolchain//:toolchain
##
## Stripe's ci passes --config=ci, we need it to exist
##
common:stripeci --config=ci
common:ci --color yes
# enables a lot of features in mac instruments profiler
build:instruments --linkopt=-framework --linkopt=CoreFoundation