blob: 5428506ced3d1fc24d3ccc522ce0399b7887a8e5 [file] [log] [blame]
Tim Windelschmidt6c851e22024-01-11 15:23:48 +01001# Import Aspect bazelrc presets
2import %workspace%/third_party/bazelrc/aspect/bazel7.bazelrc
3import %workspace%/third_party/bazelrc/aspect/convenience.bazelrc
4import %workspace%/third_party/bazelrc/aspect/correctness.bazelrc
5import %workspace%/third_party/bazelrc/aspect/performance.bazelrc
6
7# Allow empty globs as there are a lot until we replace our rust toolchain and
8# qemu BUILD files.
9common --noincompatible_disallow_empty_glob
10
11# Don't warn about too high test timeout as these can vary a lot.
12test --notest_verbose_timeout_warnings
13
Lorenz Brun65702192023-08-31 16:27:38 +020014# Set compilation mode (-c) to debug when running with --config debug.
15build:dbg --compilation_mode=dbg
16
Leopoldbc93c2b2023-01-14 13:12:23 +010017# Run all spawns in our own hermetic sandbox sysroot.
Leopold Schabel9508b122023-07-14 17:54:17 +020018build --experimental_use_hermetic_linux_sandbox
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010019build --sandbox_fake_hostname
20build --sandbox_fake_username
Leopold7fbf1042023-01-06 19:57:37 +010021build --action_env=MONOGON_SANDBOX_DIGEST
22import %workspace%/.bazelrc.sandbox
23
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010024# Enable revised output directory hash suffix computation
25build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline
26build --experimental_exec_configuration_distinguisher=off
27
Leopold Schabel9508b122023-07-14 17:54:17 +020028# Hardwire all action envs to just use /usr/bin from the above sandbox. This is
29# necessary on NixOS Bazel builds, as they really like to inject /nix/store/*
30# paths otherwise. We also explicitly set it to /usr/bin only (no /bin) as
31# otherwise calling gcc from /bin/gcc breaks its own resolution of subordinate
32# commands (like cc1, as, etc.).
33build --action_env=PATH=/usr/bin
34build --host_action_env=PATH=/usr/bin
35
36# Make all shell run actions use /bin/bash instead of whatever the host might
37# have set. Again, looking at you, Bazel-on-NixOS.
38build --shell_executable=/bin/bash
39
Leopoldbc93c2b2023-01-14 13:12:23 +010040# No local CPP toolchain resolution. In our sandbox root, it doesn't make sense -
41# anything auto-detected during analysis stage is on the host instead of the sandbox.
42# Sysroot rebuild is pure Go and doesn't need it either.
43# The flag ensures we fail early if we somehow depend on the host toolchain,
44# and do not spend unnecessary time on autodiscovery.
45build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
46
47# Use new-style C++ toolchain resolution.
48build --incompatible_enable_cc_toolchain_resolution
49
50# In our monorepo, we mostly ignore the host platform since we bring our own
51# execution environment. However, we still need to run a small number of tools
52# such as gazelle. We can just use rules_go's pure-Go platform. Attempting to
53# build CGO binaries for the host will fail (and does not make sense).
54# The host is lava - it could be NixOS (or even potentially macOS/Windows).
55build --host_platform=@io_bazel_rules_go//go/toolchain:linux_amd64
56
57# Target platform for the monorepo is currently the same as the host platform,
58# but we'll support cross-compilation at some point. Do not rely on it.
59build --platforms=//build/platforms:linux_amd64
60# Make sure our platform is picked instead of the --host_platform.
61build --extra_execution_platforms=//build/platforms:linux_amd64
62
Leopoldeb2fb7b2022-06-08 13:18:51 +020063# Build resources
Leopold Schabel5c80aca2019-10-22 15:48:58 +020064startup --batch_cpu_scheduling --io_nice_level 7
Leopoldafb925b2023-01-08 16:57:28 +010065test --test_output=errors
Lorenz Brun5d7d2a42020-04-06 14:11:02 +020066
Leopold96b03c72022-06-08 12:59:58 +020067# selinux:
68# build with SELinux (containerd, kubelet)
69# no_zfs,no_aufs,no_devicemapper:
70# disable containerd features we don't need
71# providerless,dockerless:
72# build k8s without cloud provider and docker support
Serge Bazanski46e72ab2022-09-05 15:13:22 +020073# nowasm:
74# disable wasm plugin support in sqlc
Tim Windelschmidtd8a3fa22023-11-24 23:14:09 +010075# nobtrfs,nozfs,notapestats,norapl:
76# disable node_exporter features we don't need
77build --@io_bazel_rules_go//go/config:tags=selinux,seccomp,no_zfs,no_aufs,no_devicemapper,providerless,dockerless,nowasm,netgo,osusergo,nobtrfs,nozfs,notapestats,norapl
Serge Bazanskibb7db922020-04-30 12:43:10 +020078
Lorenz Brun65702192023-08-31 16:27:38 +020079# kvm_debug:
80# prevent stackoverflows for gvisor
Tim Windelschmidtd8a3fa22023-11-24 23:14:09 +010081build:dbg --@io_bazel_rules_go//go/config:tags=selinux,seccomp,no_zfs,no_aufs,no_devicemapper,providerless,dockerless,nowasm,netgo,osusergo,nobtrfs,nozfs,notapestats,norapl,kvm_debug
Lorenz Brun65702192023-08-31 16:27:38 +020082
Serge Bazanskibb7db922020-04-30 12:43:10 +020083# Build with C++17.
84build --cxxopt=-std=c++17
85
Lorenz Brunf6402112020-05-04 16:50:31 +020086# Set workspace status file and stamp
Serge Bazanskia6a03922023-11-13 19:57:48 +010087build --stamp --workspace_status_command=./build/print-workspace-status.py
Serge Bazanski385c12f2020-06-17 12:12:42 +020088
Leopold31545872022-06-08 13:22:32 +020089# Load custom per-user settings.
90try-import %workspace%/.bazelrc.user
Serge Bazanski99b02142024-04-17 16:33:28 +020091
92test --experimental_allow_tags_propagation
93# Assume a 10k IOPS device (average NVMe) and 64GiB of RAM for test scheduling.
94test --local_extra_resources=iops=10000 --local_extra_resources=ram=64000