blob: e65a85a410948927c6666a2c25fdb740a56f43bb [file] [log] [blame]
Lorenz Brun65702192023-08-31 16:27:38 +02001# Set compilation mode (-c) to debug when running with --config debug.
2build:dbg --compilation_mode=dbg
3
Leopoldeb2fb7b2022-06-08 13:18:51 +02004# Enable strict_action_env (use static PATH and do not inherit environment variables).
5# This avoids unnecessary cache invalidations.
6build --incompatible_strict_action_env=true
7
Leopoldbc93c2b2023-01-14 13:12:23 +01008# Run all spawns in our own hermetic sandbox sysroot.
Leopold Schabel9508b122023-07-14 17:54:17 +02009build --experimental_use_hermetic_linux_sandbox
Leopold7fbf1042023-01-06 19:57:37 +010010build --action_env=MONOGON_SANDBOX_DIGEST
11import %workspace%/.bazelrc.sandbox
12
Leopold Schabel9508b122023-07-14 17:54:17 +020013# Hardwire all action envs to just use /usr/bin from the above sandbox. This is
14# necessary on NixOS Bazel builds, as they really like to inject /nix/store/*
15# paths otherwise. We also explicitly set it to /usr/bin only (no /bin) as
16# otherwise calling gcc from /bin/gcc breaks its own resolution of subordinate
17# commands (like cc1, as, etc.).
18build --action_env=PATH=/usr/bin
19build --host_action_env=PATH=/usr/bin
20
21# Make all shell run actions use /bin/bash instead of whatever the host might
22# have set. Again, looking at you, Bazel-on-NixOS.
23build --shell_executable=/bin/bash
24
Leopoldbc93c2b2023-01-14 13:12:23 +010025# No local CPP toolchain resolution. In our sandbox root, it doesn't make sense -
26# anything auto-detected during analysis stage is on the host instead of the sandbox.
27# Sysroot rebuild is pure Go and doesn't need it either.
28# The flag ensures we fail early if we somehow depend on the host toolchain,
29# and do not spend unnecessary time on autodiscovery.
30build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
31
32# Use new-style C++ toolchain resolution.
33build --incompatible_enable_cc_toolchain_resolution
34
35# In our monorepo, we mostly ignore the host platform since we bring our own
36# execution environment. However, we still need to run a small number of tools
37# such as gazelle. We can just use rules_go's pure-Go platform. Attempting to
38# build CGO binaries for the host will fail (and does not make sense).
39# The host is lava - it could be NixOS (or even potentially macOS/Windows).
40build --host_platform=@io_bazel_rules_go//go/toolchain:linux_amd64
41
42# Target platform for the monorepo is currently the same as the host platform,
43# but we'll support cross-compilation at some point. Do not rely on it.
44build --platforms=//build/platforms:linux_amd64
45# Make sure our platform is picked instead of the --host_platform.
46build --extra_execution_platforms=//build/platforms:linux_amd64
47
Leopoldeb2fb7b2022-06-08 13:18:51 +020048# Build resources
Leopold Schabel5c80aca2019-10-22 15:48:58 +020049startup --batch_cpu_scheduling --io_nice_level 7
Leopoldafb925b2023-01-08 16:57:28 +010050test --test_output=errors
Lorenz Brun5d7d2a42020-04-06 14:11:02 +020051
Leopold96b03c72022-06-08 12:59:58 +020052# selinux:
53# build with SELinux (containerd, kubelet)
54# no_zfs,no_aufs,no_devicemapper:
55# disable containerd features we don't need
56# providerless,dockerless:
57# build k8s without cloud provider and docker support
Serge Bazanski46e72ab2022-09-05 15:13:22 +020058# nowasm:
59# disable wasm plugin support in sqlc
Tim Windelschmidtcf8a3242023-11-23 02:22:57 +010060# nobtrfs:
61# disable btrfs support in node_exporter
62build --@io_bazel_rules_go//go/config:tags=selinux,seccomp,no_zfs,no_aufs,no_devicemapper,providerless,dockerless,nowasm,netgo,osusergo,nobtrfs
Serge Bazanskibb7db922020-04-30 12:43:10 +020063
Lorenz Brun65702192023-08-31 16:27:38 +020064# kvm_debug:
65# prevent stackoverflows for gvisor
66build:dbg --@io_bazel_rules_go//go/config:tags=selinux,seccomp,no_zfs,no_aufs,no_devicemapper,providerless,dockerless,nowasm,netgo,osusergo,kvm_debug
67
Serge Bazanskibb7db922020-04-30 12:43:10 +020068# Build with C++17.
69build --cxxopt=-std=c++17
70
Lorenz Brunf6402112020-05-04 16:50:31 +020071# Set workspace status file and stamp
Serge Bazanskia6a03922023-11-13 19:57:48 +010072build --stamp --workspace_status_command=./build/print-workspace-status.py
Serge Bazanski385c12f2020-06-17 12:12:42 +020073
Serge Bazanskic3ad8462021-01-08 16:45:51 +010074# Load CI bazelrc if present.
75try-import %workspace%/ci.bazelrc
Leopold31545872022-06-08 13:22:32 +020076
77# Load custom per-user settings.
78try-import %workspace%/.bazelrc.user