# bazelrc file
-# bazel >= 0.18 looks for %workspace%/.bazelrc (which redirects here)
-# Older bazel versions look for %workspace%/tools/bazel.rc (this file)
-# See https://github.com/bazelbuild/bazel/issues/6319
build --client_env=CC=clang
build --copt=-DGRPC_BAZEL_BUILD
+build --action_env=GRPC_BAZEL_RUNTIME=1
+build --define=use_fast_cpp_protos=true
build:opt --compilation_mode=opt
build:opt --copt=-Wframe-larger-than=16384
build:dbg --compilation_mode=dbg
+build:windows_opt --compilation_mode=opt
+build:windows_dbg --compilation_mode=dbg
+
build:asan --strip=never
build:asan --copt=-fsanitize=address
build:asan --copt=-O0
build:asan --copt=-fno-omit-frame-pointer
build:asan --copt=-DGPR_NO_DIRECT_SYSCALLS
+build:asan --copt=-DGRPC_ASAN
build:asan --copt=-DADDRESS_SANITIZER # used by absl
build:asan --linkopt=-fsanitize=address
build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always
build:asan --action_env=LSAN_OPTIONS=suppressions=test/core/util/lsan_suppressions.txt:report_objects=1
+# We have a separate ASAN config for Mac OS to workaround a couple of bugs:
+# 1. https://github.com/bazelbuild/bazel/issues/6932
+# _FORTIFY_SOURCE=1 is enabled by default on Mac OS, which breaks ASAN.
+# We workaround it by setting _FORTIFY_SOURCE=0 and ignoring macro redefined
+# warnings.
+# 2. https://github.com/google/sanitizers/issues/1026
+# LSAN is not supported by the version of Clang that ships with Mac OS, so
+# we disable it.
+build:asan_macos --strip=never
+build:asan_macos --copt=-fsanitize=address
+build:asan_macos --copt -Wno-macro-redefined
+build:asan_macos --copt -D_FORTIFY_SOURCE=0
+build:asan_macos --copt=-fsanitize=address
+build:asan_macos --copt=-O0
+build:asan_macos --copt=-fno-omit-frame-pointer
+build:asan_macos --copt=-DGPR_NO_DIRECT_SYSCALLS
+build:asan_macos --linkopt=-fsanitize=address
+build:asan_macos --action_env=ASAN_OPTIONS=detect_leaks=0
+
build:msan --strip=never
build:msan --copt=-fsanitize=memory
build:msan --copt=-O0
build:msan --copt=-fsanitize-memory-use-after-dtor
build:msan --copt=-fno-omit-frame-pointer
build:msan --copt=-DGPR_NO_DIRECT_SYSCALLS
-build:msan --copt=-DMEMORY_SANITIZER # used by absl
build:msan --linkopt=-fsanitize=memory
build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1
build:tsan --copt=-fno-omit-frame-pointer
build:tsan --copt=-DGPR_NO_DIRECT_SYSCALLS
build:tsan --copt=-DGRPC_TSAN
-# TODO(jtattermusch): ideally we would set --copt=-DTHREAD_SANITIZER (used by absl)
-# but it seems to do more harm than good and triggers #17175
build:tsan --linkopt=-fsanitize=thread
+# This is needed to address false positive problem with abseil.
+# https://github.com/google/sanitizers/issues/953
+build:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0
build:tsan --action_env=TSAN_OPTIONS=suppressions=test/core/util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
build:ubsan --strip=never
build:ubsan --copt=-fno-omit-frame-pointer
build:ubsan --copt=-DGRPC_UBSAN
build:ubsan --copt=-DNDEBUG
-build:ubsan --copt=-DUNDEFINED_BEHAVIOR_SANITIZER # used by absl
build:ubsan --copt=-fno-sanitize=function,vptr
build:ubsan --linkopt=-fsanitize=undefined
build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=test/core/util/ubsan_suppressions.txt
+# For some reasons, these two stopped being propagated, so, redeclaring them here.
+# That's a hack that needs to be removed once we understand what's going on.
+build:ubsan --copt=-DGRPC_PORT_ISOLATED_RUNTIME=1
build:basicprof --strip=never
build:basicprof --copt=-DNDEBUG
build:basicprof --copt=-DGRPC_BASIC_PROFILER
build:basicprof --copt=-DGRPC_TIMERS_RDTSC
-build:python3 --python_path=python3
-build:python3 --force_python=PY3
-build:python3 --action_env=PYTHON_BIN_PATH=python3
+build:python_single_threaded_unary_stream --test_env="GRPC_SINGLE_THREADED_UNARY_STREAM=true"
+
+build:python_poller_engine --test_env="GRPC_ASYNCIO_ENGINE=poller"
+
+# "counters" config is based on a legacy config provided by the Makefile (see definition in build_handwritten.yaml).
+# It is only used in microbenchmarks.
+# TODO(jtattermusch): get rid of the "counters" config when possible
+build:counters --compilation_mode=opt
+build:counters --copt=-Wframe-larger-than=16384
+build:counters --copt=-DGPR_LOW_LEVEL_COUNTERS
+
+# "mutrace" config is based on a legacy config provided by the Makefile (see definition in build_handwritten.yaml).
+# It is only used in microbenchmarks (see tools/run_tests/run_microbenchmark.py)
+# TODO(jtattermusch): get rid of the "mutrace" config when possible
+build:mutrace --copt=-O3
+build:mutrace --copt=-fno-omit-frame-pointer
+build:mutrace --copt=-DNDEBUG
+build:mutrace --linkopt=-rdynamic
+
+# Compile database generation config
+build:compdb --build_tag_filters=-nocompdb