• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# bazelrc file
2
3# Bazel 7 begins to enable module by default which breaks gRPC build.
4# Therefore, this option is disabled until gRPC works with bzlmod.
5common --enable_bzlmod=false
6
7# for platform-appropriate cxxopts
8common --enable_platform_specific_config
9
10build:windows --cxxopt='/std:c++17'
11build:windows --host_cxxopt='/std:c++17'
12build:linux   --cxxopt='-std=c++17'
13build:linux   --host_cxxopt='-std=c++17'
14build:macos   --cxxopt='-std=c++17'
15build:macos   --host_cxxopt='-std=c++17'
16build:freebsd   --cxxopt='-std=c++17'
17build:freebsd   --host_cxxopt='-std=c++17'
18
19# TODO(veblush): Remove these once upb is upgraded to 25.x or later
20build:linux --copt=-Wno-typedef-redefinition
21build:linux --host_copt=-Wno-typedef-redefinition
22build:macos --copt=-Wno-typedef-redefinition
23build:macos --host_copt=-Wno-typedef-redefinition
24
25# Don't trigger --config=<host platform> when cross-compiling.
26build:android --noenable_platform_specific_config
27build:ios --noenable_platform_specific_config
28
29build --client_env=CC=clang
30build --copt=-DGRPC_BAZEL_BUILD
31build --host_copt=-DGRPC_BAZEL_BUILD
32build --action_env=GRPC_BAZEL_RUNTIME=1
33build --define=use_fast_cpp_protos=true
34
35build:opt --compilation_mode=opt
36build:opt --copt=-Wframe-larger-than=16384
37
38build:dbg --compilation_mode=dbg
39
40# Dynamic link cause issues like: `dyld: malformed mach-o: load commands size (59272) > 32768`
41# https://github.com/bazelbuild/bazel/issues/9190
42build:macos --dynamic_mode=off
43
44build:windows_opt --compilation_mode=opt
45build:windows_dbg --compilation_mode=dbg
46
47build:clang-cl --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
48build:clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
49build:clang-cl --incompatible_enable_cc_toolchain_resolution
50build:clang-cl --define=use_strict_warning_windows=true
51build:clang-cl --compiler=clang-cl
52
53build:asan --strip=never
54build:asan --copt=-fsanitize=address
55build:asan --copt=-O0
56build:asan --copt=-fno-omit-frame-pointer
57build:asan --copt=-DGPR_NO_DIRECT_SYSCALLS
58build:asan --copt=-DGRPC_ASAN
59build:asan --copt=-DADDRESS_SANITIZER  # used by absl
60build:asan --linkopt=-fsanitize=address
61build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always
62build:asan --action_env=LSAN_OPTIONS=suppressions=test/core/test_util/lsan_suppressions.txt:report_objects=1
63build:asan --action_env=ASAN_OPTIONS=detect_odr_violation=0  # https://github.com/google/sanitizers/issues/1017
64
65build:fuzzer_asan --strip=never
66build:fuzzer_asan --define=grpc_build_fuzzers=true
67build:fuzzer_asan --copt=-fsanitize=fuzzer,address
68build:fuzzer_asan --copt=-fsanitize-coverage=edge
69build:fuzzer_asan --copt=-fsanitize-coverage=trace-cmp
70build:fuzzer_asan --copt=-O0
71build:fuzzer_asan --copt=-fno-omit-frame-pointer
72build:fuzzer_asan --copt=-DGPR_NO_DIRECT_SYSCALLS
73build:fuzzer_asan --copt=-DGRPC_ASAN
74build:fuzzer_asan --copt=-DADDRESS_SANITIZER  # used by absl
75# add a macro that can be used to determine that we're running under a fuzzer
76# allowing different code paths to be substituted under fuzzing (say, additional
77# checks)
78build:fuzzer_asan --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
79build:fuzzer_asan --linkopt=-fsanitize=fuzzer,address
80build:fuzzer_asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always
81build:fuzzer_asan --action_env=LSAN_OPTIONS=suppressions=test/core/test_util/lsan_suppressions.txt:report_objects=1
82build:fuzzer_asan --action_env=ASAN_OPTIONS=detect_odr_violation=0  # https://github.com/google/sanitizers/issues/1017
83
84build:coverage --copt=-fprofile-instr-generate
85build:coverage --copt=-fcoverage-mapping
86build:coverage --linkopt=-fprofile-instr-generate
87
88build:fork_support --cxxopt=-DGRPC_ENABLE_FORK_SUPPORT=1
89build:fork_support --cxxopt=-DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1
90build:fork_support --action_env=GRPC_ENABLE_FORK_SUPPORT=1
91
92
93# We have a separate ASAN config for Mac OS to workaround a couple of bugs:
94# 1. https://github.com/bazelbuild/bazel/issues/6932
95#    _FORTIFY_SOURCE=1 is enabled by default on Mac OS, which breaks ASAN.
96#    We workaround it by setting _FORTIFY_SOURCE=0 and ignoring macro redefined
97#    warnings.
98# 2. https://github.com/google/sanitizers/issues/1026
99#    LSAN is not supported by the version of Clang that ships with Mac OS, so
100#    we disable it.
101build:asan_macos --strip=never
102build:asan_macos --copt=-fsanitize=address
103build:asan_macos --copt -Wno-macro-redefined
104build:asan_macos --copt -D_FORTIFY_SOURCE=0
105build:asan_macos --copt=-fsanitize=address
106build:asan_macos --copt=-O0
107build:asan_macos --copt=-fno-omit-frame-pointer
108build:asan_macos --copt=-DGPR_NO_DIRECT_SYSCALLS
109build:asan_macos --linkopt=-fsanitize=address
110build:asan_macos --action_env=ASAN_OPTIONS=detect_leaks=0
111build:asan_macos --action_env=ASAN_OPTIONS=detect_odr_violation=0  # https://github.com/google/sanitizers/issues/1017
112build:asan_macos --dynamic_mode=off
113
114build:msan --strip=never
115build:msan --copt=-fsanitize=memory
116build:msan --copt=-O0
117build:msan --copt=-fsanitize-memory-track-origins
118build:msan --copt=-fsanitize-memory-use-after-dtor
119build:msan --copt=-fno-omit-frame-pointer
120build:msan --copt=-DGPR_NO_DIRECT_SYSCALLS
121build:msan --linkopt=-fsanitize=memory
122build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1
123
124build:tsan --strip=never
125build:tsan --copt=-fsanitize=thread
126build:tsan --copt=-fno-omit-frame-pointer
127build:tsan --copt=-DGPR_NO_DIRECT_SYSCALLS
128build:tsan --copt=-DGRPC_TSAN
129build:tsan --linkopt=-fsanitize=thread
130build:tsan --action_env=TSAN_OPTIONS=suppressions=test/core/test_util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
131
132# a TSAN build that tries to create new threads whenever possible
133build:thready_tsan --strip=never
134build:thready_tsan --copt=-fsanitize=thread
135build:thready_tsan --copt=-fno-omit-frame-pointer
136build:thready_tsan --copt=-DGPR_NO_DIRECT_SYSCALLS
137build:thready_tsan --copt=-DGRPC_TSAN
138build:thready_tsan --copt=-DGRPC_MAXIMIZE_THREADYNESS
139build:thready_tsan --linkopt=-fsanitize=thread
140build:thready_tsan --action_env=TSAN_OPTIONS=suppressions=test/core/test_util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
141
142build:tsan_macos --strip=never
143build:tsan_macos --copt=-fsanitize=thread
144build:tsan_macos --copt=-fno-omit-frame-pointer
145build:tsan_macos --copt=-DGPR_NO_DIRECT_SYSCALLS
146build:tsan_macos --copt=-DGRPC_TSAN
147build:tsan_macos --linkopt=-fsanitize=thread
148build:tsan_macos --action_env=TSAN_OPTIONS=suppressions=test/core/test_util/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
149build:tsan_macos --dynamic_mode=off
150
151build:ubsan --strip=never
152build:ubsan --copt=-fsanitize=undefined
153build:ubsan --copt=-fsanitize-link-c++-runtime
154build:ubsan --copt=-fno-omit-frame-pointer
155build:ubsan --copt=-DGRPC_UBSAN
156build:ubsan --copt=-DNDEBUG
157build:ubsan --copt=-fno-sanitize=function,vptr
158build:ubsan --linkopt=-fsanitize=undefined
159# avoid ubsan build error with int128 by linking against libc++
160# see b/200667821
161build:ubsan --linkopt=-fsanitize-link-c++-runtime
162build:ubsan --linkopt=-lc++
163build:ubsan --linkopt=-lc++abi
164build:ubsan --linkopt=-lm
165build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1:suppressions=test/core/test_util/ubsan_suppressions.txt
166# if you want to run ubsan locally, uncomment following three lines
167# build:ubsan --linkopt=-lgcc_s
168# build:ubsan --linkopt=-lubsan
169# build:ubsan --linkopt=--rtlib=compiler-rt
170
171build:python_single_threaded_unary_stream --test_env="GRPC_SINGLE_THREADED_UNARY_STREAM=true"
172
173build:python_poller_engine --test_env="GRPC_ASYNCIO_ENGINE=poller"
174
175# Compile database generation config
176build:compdb --build_tag_filters=-nocompdb --features=-layering_check
177
178try-import %workspace%/tools/fuzztest.bazelrc
179
180# OpenTelemetry C++ needs this option to build with absl
181build --@io_opentelemetry_cpp//api:with_abseil
182
183# Bazel 7.4.1 needs this (https://github.com/bazelbuild/bazel/issues/24369)
184test --nozip_undeclared_test_outputs
185