pixie
/
.bazelrc
271 строка · 11.7 Кб
1# Global bazelrc file, see https://docs.bazel.build/versions/master/guide.html#bazelrc.
2
3# Use strict action env to prevent leaks of env vars.
4build --incompatible_strict_action_env
5
6# Only pass through GH_API_KEY for stamped builds.
7# This is still not ideal as it still busts the cache of stamped builds.
8build:stamp --stamp
9build:stamp --action_env=GH_API_KEY
10
11# Doesn't rely on a localjdk which is default. This removes the need for a JAVA_HOME
12# on the build machine and also makes JAVA builds hermetic.
13build --java_runtime_version=remotejdk_11
14test --java_runtime_version=remotejdk_11
15
16# https://github.com/bazelbuild/rules_jvm_external/issues/445
17common --repo_env=JAVA_HOME=../bazel_tools/jdk
18
19build --remote_download_minimal
20test --remote_download_minimal
21run --remote_download_outputs=all
22coverage --build_runfile_links
23
24# Needed by rules_meta.
25# Follow https://github.com/fmeum/rules_meta/issues/1#issuecomment-1255828109
26# for updates.
27common --incompatible_remove_rule_name_parameter=false
28
29# Get version information into the build.
30build --workspace_status_command=bazel/get_workspace_status.sh
31
32# We only have support for python3 on the Ubuntu 20.04 image.
33build --host_force_python=PY3
34
35# Limit memory for JVM to reduce runaway usage.
36startup --host_jvm_args=-Xmx1900m
37
38# For all builds, by default, exclude tests that require root or BPF privileges.
39# To run a test that was filtered out:
40# bazel test //path/to:test --test_tag_filter=
41# Which reset the filter to empty.
42build --test_tag_filters=-requires_root,-requires_bpf,-disabled
43
44# Sets the default Apple platform to macOS.
45build --apple_platform_type=macos
46
47# Keep debug symbols (required for go binaries).
48# Unfortunately, this affects C++ with -c fastbuild too.
49# Upgrading io_bazel_rules_go provides a better way to do this, but that upgrade is a tangled web.
50# TODO(oazizi): Remove after upgrading io_bazel_rules_go.
51build --strip=never
52
53# Give each sandbox its own tmp directory.
54# This is important for //src/stirling/utils:java_test, which otherwise creates conflicting writes
55# when multiple instances are running simultaneously.
56# It is also generally not a bad idea, since it improves heremeticity.
57# For more context, see: https://github.com/bazelbuild/bazel/issues/3236
58# We can't use this for qemu because it breaks the 9p fs. Since we can't
59# remove these flags we just set them for all our configs.
60test:tmp-sandbox --sandbox_tmpfs_path=/tmp
61
62# This flag prevents rules_docker from transitioning the platform for our images.
63# Since our target platform is the same as the containers we use,
64# it doesn't make sense to transition, and results in duplicate builds of targets.
65build --@io_bazel_rules_docker//transitions:enable=false
66
67# This flag is equivalent to --config=linux on a linux machine, and --config=macos on a macos machine.
68common --enable_platform_specific_config
69
70# Linux specific config
71# `bazel query` will try to auto-detect the toolchain without this.
72common:linux --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
73# --platforms is only set on linux, because we don't have a linux cross-compiling setup on macos.
74build:linux --platforms=//bazel/cc_toolchains:linux-x86_64
75# Likewise, we only have cc_toolchain definitions for our linux compilers, so we only enable toolchain resolution on linux.
76build:linux --incompatible_enable_cc_toolchain_resolution
77build:linux --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
78
79# Common options from clang.
80build:clang-base --//bazel/cc_toolchains:compiler=clang
81build:clang-base --//bazel/cc_toolchains:libc_version=glibc_host
82
83# We build our own chroot for the sysroot tests, which doesn't work well under bazel's sandbox.
84build:sysroot-base --//bazel/test_runners:test_runner=sysroot_chroot
85test:sysroot-base --strategy TestRunner=standalone
86test:sysroot-base --run_under="bazel/test_runners/sysroot_chroot/test_runner.sh"
87
88build:x86_64_sysroot --config=clang
89build:x86_64_sysroot --//bazel/cc_toolchains:libc_version=glibc2_36
90build:x86_64_sysroot --config=sysroot-base
91
92build:aarch64_sysroot --config=clang
93build:aarch64_sysroot --//bazel/cc_toolchains:libc_version=glibc2_36
94build:aarch64_sysroot --platforms=//bazel/cc_toolchains:linux-aarch64
95build:aarch64_sysroot --config=sysroot-base
96# Increase test timeouts for qemu (don't increase the slowest ones because those are already very long).
97test:aarch64_sysroot --test_timeout=180,600,1800,3600
98test:aarch64_sysroot --test_env=QEMU_STRACE
99test:aarch64_sysroot --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf,-disabled,-requires_full_qemu_emulation
100
101# Build for Clang using Libc++.
102build:clang --config=clang-base
103build:clang --//bazel:enable_libcpp
104build:clang --features=libc++ --features=-libstdc++
105build:clang --build_tag_filters=-no_libcpp
106build:clang --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf,-disabled
107test:clang --config=tmp-sandbox
108
109# Build for Clang with libstdc++:
110build:clang-libstdc++ --config=clang-base
111build:clang-libstdc++ --//bazel/cc_toolchains:compiler=clang
112build:clang-libstdc++ --//bazel/cc_toolchains:libc_version=gnu
113test:clang-libstdc++ --config=tmp-sandbox
114
115build:qemu-bpf --config=clang-base
116build:qemu-bpf --//bazel:enable_libcpp
117build:qemu-bpf --features=libc++ --features=-libstdc++
118build:qemu-bpf --build_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp
119build:qemu-bpf --test_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp,-disabled
120build:qemu-bpf --sandbox_fake_username
121build:qemu-bpf --//bazel/cc_toolchains:libc_version=glibc2_36
122build:qemu-bpf --//bazel/test_runners:test_runner=qemu_with_kernel
123build:qemu-bpf --run_under="bazel/test_runners/qemu_with_kernel/test_runner.sh"
124test:qemu-bpf --test_timeout=180,600,1800,3600
125
126# Build for GCC.
127# These are copts because they apply to both c++ and c files.
128# In particular, upb is has issues with this that will hopefully be
129# fixed upstream soon.
130build:gcc --copt -Wno-error=sign-compare
131build:gcc --copt -Wno-error=stringop-truncation
132build:gcc --copt -Wno-error=maybe-uninitialized
133build:gcc --build_tag_filters=-no_gcc,-qemu_interactive
134build:gcc --test_tag_filters=-no_gcc,-requires_root,-requires_bpf,-disabled,-qemu_interactive
135build:gcc --//bazel/cc_toolchains:compiler=gcc
136# TODO(#1462): Investigate why tcmalloc breaks linking of go binaries.
137build:gcc --define tcmalloc=disabled
138test:gcc --config=tmp-sandbox
139
140
141# bazel build --config asan ...
142build:asan --config=clang
143build:asan --//bazel:sanitizer=asan
144build:asan --features=asan
145build:asan --test_timeout="120,600,1800,3600"
146build:asan --define PL_CONFIG_ASAN=1
147build:asan --define tcmalloc=disabled
148build:asan --build_tag_filters=-no_asan
149build:asan --test_tag_filters=-no_asan,-requires_root,-requires_bpf,-disabled
150build:asan --define signal_trace=disabled
151build:asan --test_env=ASAN_SYMBOLIZER_PATH
152build:asan --test_env=ASAN_OPTIONS=handle_abort=1:allow_addr2line=true
153build:asan --test_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1
154build:asan --define tcmalloc=disabled
155#test:asan --test_env=ASAN_OPTIONS=detect_container_overflow=0
156
157# bazel build --config msan
158build:msan --config=clang
159build:msan --define PL_CONFIG_MSAN=1
160build:msan --//bazel:sanitizer=msan
161build:msan --define tcmalloc=disabled
162build:msan --build_tag_filters=-no_msan
163build:msan --test_tag_filters=-no_msan,-requires_root,-requires_bpf,-disabled
164build:msan --features=msan
165
166# bazel build --config tsan
167build:tsan --config=clang
168build:tsan --//bazel:sanitizer=tsan
169build:tsan --define PL_CONFIG_TSAN=1
170build:tsan --define tcmalloc=disabled
171build:tsan --build_tag_filters=-no_tsan
172build:tsan --test_tag_filters=-no_tsan,-requires_root,-requires_bpf,-disabled
173build:tsan --define tcmalloc=disabled
174# This is needed to address false positive problem with abseil.
175# https://github.com/google/sanitizers/issues/953
176build:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0
177build:tsan --features=tsan
178test:tsan --test_timeout=180,600,1800,3600
179
180# Note that we are lumping tests that require root into the BPF tests below
181# to minimize number of configs.
182# If there are ever a lot of tests with requires_root, a new config is warranted.
183# See also ci/bazel_build_deps.sh
184
185# Note 2: BPF tests are limited to --jobs=4, because otherwise the parallel tests
186# cause a lot of flakiness. In particular, many of the BPF tests deploy containers,
187# and the sudden deployment of too many containers causes some containers to get
188# stuck for minutes without actually running.
189
190# bazel build --config bpf
191build:bpf --config=clang
192build:bpf --build_tag_filters=requires_bpf,requires_root
193build:bpf --test_tag_filters=requires_bpf,requires_root,-disabled
194test:bpf --strategy=TestRunner=standalone
195
196# bazel build --config bpf_asan
197# Need to repeat the negative build_tag_filters from config=asan,
198# because the positive build_tag_filters here can re-enable such tests.
199build:bpf_asan --config=asan
200build:bpf_asan --build_tag_filters=requires_bpf,requires_root,-no_asan
201build:bpf_asan --test_tag_filters=requires_bpf,requires_root,-no_asan,-disabled
202test:bpf_asan --jobs=4 --strategy=TestRunner=standalone
203
204# bazel build --config bpf_tsan
205# Need to repeat the negative build_tag_filters from config=tsan,
206# because the positive build_tag_filters here can re-enable such tests.
207build:bpf_tsan --config=tsan
208build:bpf_tsan --build_tag_filters=requires_bpf,requires_root,-no_tsan
209build:bpf_tsan --test_tag_filters=requires_bpf,requires_root,-no_tsan,-disabled
210test:bpf_tsan --jobs=4 --strategy=TestRunner=standalone
211
212# bazel build --config go_race
213build:go_race --config=clang
214build:go_race --define tcmalloc=disabled
215build:go_race --@io_bazel_rules_go//go/config:race
216test:go_race --define tcmalloc=disabled
217test:go_race --@io_bazel_rules_go//go/config:race
218run:go_race --define tcmalloc=disabled
219run:go_race --@io_bazel_rules_go//go/config:race
220
221
222coverage --config=gcc
223coverage --cxxopt -fprofile-arcs
224coverage --cxxopt -ftest-coverage
225coverage --instrument_test_targets
226coverage --define PL_COVERAGE=true
227coverage --copt -DPL_COVERAGE
228coverage --test_tag_filters=-requires_root,-requires_bpf,-no_coverage,-disabled,-no_gcc
229coverage --action_env=COVERAGE_GCOV_OPTIONS=-b
230
231
232try-import %workspace%/bes.bazelrc
233# jenkins.bazelrc is copied from ci/jenkins.bazelrc by Jenkins workers during the build.
234# The intention is to avoid polluting configurations of bazel for developers.
235try-import %workspace%/jenkins.bazelrc
236# github.bazelrc is copied from ci/github/bazelrc by the github action workers during the build.
237try-import %workspace%/github.bazelrc
238
239# Import a machine specific bazelrc. This can be used to enable caching.
240try-import /etc/bazelrc
241
242# Put your own configurations into user.bazelrc, which is ignored by git.
243try-import %workspace%/user.bazelrc
244
245# Tensorflow requires this option
246common --experimental_repo_remote_exec
247
248# Try Stirling flakes more than the default 3 times.
249test --flaky_test_attempts=//src/stirling/source_connectors/socket_tracer/.*bpf_test@5
250
251# Disable XNNPACK for tensorflow lite. There's currently an ASAN issue with XNNPACK, so disable for now.
252build --define=tflite_with_xnnpack=false
253
254build:remote --remote_executor=grpcs://remote.buildbuddy.io
255build:remote --host_platform=//bazel:remote_exec_platform
256build:remote --extra_execution_platforms=//bazel:remote_exec_platform
257build:remote --bes_results_url=https://app.buildbuddy.io/invocation/
258build:remote --bes_backend=grpcs://remote.buildbuddy.io
259build:remote --remote_cache=grpcs://remote.buildbuddy.io
260build:remote --experimental_remote_downloader=grpcs://remote.buildbuddy.io
261build:remote --remote_timeout=1h
262build:remote --remote_retries=5
263build:remote --spawn_strategy=remote,local
264build:remote --experimental_remote_cache_compression
265build:remote --jobs=100
266test:remote --jobs=100
267build:remote --nolegacy_important_outputs
268build:remote --build_metadata=VISIBILITY=PUBLIC
269coverage:remote --strategy=CoverageReport=local,remote
270coverage:remote --experimental_fetch_all_coverage_outputs
271coverage:remote --experimental_split_coverage_postprocessing
272