blob: ddef26c10d34b7efcaf00fcfe852d7e0964a1a5d [file] [log] [blame]
Tim Windelschmidt6c851e22024-01-11 15:23:48 +01001# Import Aspect bazelrc presets
Tim Windelschmidt2979a432025-02-24 18:55:52 +01002import %workspace%/third_party/bazelrc/aspect/bazel8.bazelrc
Tim Windelschmidt6c851e22024-01-11 15:23:48 +01003import %workspace%/third_party/bazelrc/aspect/convenience.bazelrc
4import %workspace%/third_party/bazelrc/aspect/correctness.bazelrc
5import %workspace%/third_party/bazelrc/aspect/performance.bazelrc
6
Tim Windelschmidt2979a432025-02-24 18:55:52 +01007# We still require WORKSPACE support as bazeldnf isn't bzlmod compatible yet.
8common --enable_workspace
9
10# rules_proto_grpc isn't fully compatible with Bazel 8 yet.
11common --noincompatible_disallow_ctx_resolve_tools
12
Tim Windelschmidtd7f59932024-07-24 23:37:03 +020013# Actually make the lock file a lock file by not updating it without any
14# request to do so.
15common --lockfile_mode=error
16
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010017# Allow empty globs as there are a lot until we replace our rust toolchain and
18# qemu BUILD files.
19common --noincompatible_disallow_empty_glob
20
21# Don't warn about too high test timeout as these can vary a lot.
22test --notest_verbose_timeout_warnings
23
Leopold Schabel8661db32024-07-24 16:28:27 +000024# Set compilation mode (-c) to debug when running with --config dbg.
Lorenz Brun65702192023-08-31 16:27:38 +020025build:dbg --compilation_mode=dbg
26
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +010027# Run race config with race detector
28build:race --@io_bazel_rules_go//go/config:race
Jan Schär0fd36f42025-04-29 10:26:03 +000029build:race --no@io_bazel_rules_go//go/config:pure
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +010030
Tim Windelschmidt32e74302025-01-15 04:37:26 +010031# Only download the final result, the intermediate files can stay on the
32# server side.
33build:remote --remote_download_toplevel
34build:remote --noremote_upload_local_results
35
36# Set the execution platform which adds constraints for the scheduler.
Jan Schär51c67482025-05-05 13:11:55 +000037build:remote --extra_execution_platforms=//build/platforms:remote_x86_64
Tim Windelschmidt32e74302025-01-15 04:37:26 +010038
Lorenz Brun27f2efb2025-06-28 11:53:12 +020039# We have some large uploads and actions, the default 60s is not enough.
40build:remote --remote_timeout=360s
41
Jan Schär0fd36f42025-04-29 10:26:03 +000042# Enable pure by default. Specific go_binary targets which need cgo should set
43# `pure = "off"`.
44build --@io_bazel_rules_go//go/config:pure
45
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +010046# Force netgo and osusergo
47build --@io_bazel_rules_go//go/config:tags=osusergo,netgo
48
Leopoldbc93c2b2023-01-14 13:12:23 +010049# Run all spawns in our own hermetic sandbox sysroot.
Leopold Schabel9508b122023-07-14 17:54:17 +020050build --experimental_use_hermetic_linux_sandbox
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010051build --sandbox_fake_hostname
52build --sandbox_fake_username
Leopold7fbf1042023-01-06 19:57:37 +010053build --action_env=MONOGON_SANDBOX_DIGEST
54import %workspace%/.bazelrc.sandbox
55
Jan Schärafb922c2025-05-19 10:18:37 +000056# Include platform in output directory name. For each platform we use, a short
57# name should be assigned here, otherwise Bazel uses a hash.
58build --experimental_platform_in_output_dir
59build --noexperimental_use_platforms_in_output_dir_legacy_heuristic
60build --experimental_override_name_platform_in_output_dir=//build/platforms:linux_x86_64=linux-x86_64
61build --experimental_override_name_platform_in_output_dir=//build/platforms:linux_aarch64=linux-aarch64
62build --experimental_override_name_platform_in_output_dir=//build/platforms:uefi_x86_64=uefi-x86_64
63build --experimental_override_name_platform_in_output_dir=//build/platforms:uefi_aarch64=uefi-aarch64
64build --experimental_override_name_platform_in_output_dir=//build/platforms:remote_x86_64=remote-x86_64
65build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:darwin_amd64=go-darwin-amd64
66build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:darwin_arm64=go-darwin-arm64
67build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:windows_amd64=go-windows-amd64
68build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:windows_arm64=go-windows-arm64
69
Jan Schäraf72f682025-05-19 09:58:13 +000070# Enable path mapping to improve cache hit rate.
71# Actions in custom rules can opt in with supports-path-mapping.
72# See https://github.com/bazelbuild/bazel/discussions/22658
73build --experimental_output_paths=strip
74
Jan Schära81e2a62025-05-05 12:02:24 +000075# Stop propagation of settings to exec config by default.
76# See https://github.com/bazelbuild/bazel/issues/22457
77build --experimental_exclude_starlark_flags_from_exec_config
78# These flags need to be propagated for nogo to work. We currently need to
79# reference rules_go with the canonical repo name; this is no longer necessary
80# once the fix for https://github.com/bazelbuild/bazel/issues/25208 is released.
81build --experimental_propagate_custom_flag=@@rules_go+//go/private:request_nogo
82build --experimental_propagate_custom_flag=@@rules_go+//go/private:bootstrap_nogo
83
Leopold Schabel9508b122023-07-14 17:54:17 +020084# Hardwire all action envs to just use /usr/bin from the above sandbox. This is
85# necessary on NixOS Bazel builds, as they really like to inject /nix/store/*
86# paths otherwise. We also explicitly set it to /usr/bin only (no /bin) as
87# otherwise calling gcc from /bin/gcc breaks its own resolution of subordinate
88# commands (like cc1, as, etc.).
89build --action_env=PATH=/usr/bin
90build --host_action_env=PATH=/usr/bin
91
92# Make all shell run actions use /bin/bash instead of whatever the host might
93# have set. Again, looking at you, Bazel-on-NixOS.
94build --shell_executable=/bin/bash
95
Leopoldbc93c2b2023-01-14 13:12:23 +010096# No local CPP toolchain resolution. In our sandbox root, it doesn't make sense -
97# anything auto-detected during analysis stage is on the host instead of the sandbox.
98# Sysroot rebuild is pure Go and doesn't need it either.
99# The flag ensures we fail early if we somehow depend on the host toolchain,
100# and do not spend unnecessary time on autodiscovery.
101build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
102
103# Use new-style C++ toolchain resolution.
104build --incompatible_enable_cc_toolchain_resolution
Tim Windelschmidt2da91b92025-04-15 21:10:12 +0200105build --experimental_cc_static_library
Leopoldbc93c2b2023-01-14 13:12:23 +0100106
Tim Windelschmidt886abba2024-07-17 21:29:55 +0200107# Use new-style proto toolchain resolution.
108build --incompatible_enable_proto_toolchain_resolution
109
Leopoldbc93c2b2023-01-14 13:12:23 +0100110# In our monorepo, we mostly ignore the host platform since we bring our own
111# execution environment. However, we still need to run a small number of tools
Serge Bazanski139550a2023-06-20 13:30:27 +0200112# such as gazelle.
Jan Schär51c67482025-05-05 13:11:55 +0000113build --host_platform=//build/platforms:linux_x86_64
Leopoldbc93c2b2023-01-14 13:12:23 +0100114
115# Target platform for the monorepo is currently the same as the host platform,
116# but we'll support cross-compilation at some point. Do not rely on it.
Jan Schär51c67482025-05-05 13:11:55 +0000117build --platforms=//build/platforms:linux_x86_64
Leopoldbc93c2b2023-01-14 13:12:23 +0100118# Make sure our platform is picked instead of the --host_platform.
Jan Schär51c67482025-05-05 13:11:55 +0000119build --extra_execution_platforms=//build/platforms:linux_x86_64
Leopoldbc93c2b2023-01-14 13:12:23 +0100120
Leopoldeb2fb7b2022-06-08 13:18:51 +0200121# Build resources
Leopold Schabel5c80aca2019-10-22 15:48:58 +0200122startup --batch_cpu_scheduling --io_nice_level 7
Lorenz Brun5d7d2a42020-04-06 14:11:02 +0200123
Serge Bazanskibb7db922020-04-30 12:43:10 +0200124# Build with C++17.
125build --cxxopt=-std=c++17
126
Lorenz Brunf6402112020-05-04 16:50:31 +0200127# Set workspace status file and stamp
Serge Bazanskia6a03922023-11-13 19:57:48 +0100128build --stamp --workspace_status_command=./build/print-workspace-status.py
Serge Bazanski385c12f2020-06-17 12:12:42 +0200129
Jan Schärbddad352025-04-23 14:55:26 +0000130# The --nostamp Bazel flag does not work in this repo; instead use
131# --config=nostamp to disable stamping with commit info.
132build:nostamp --workspace_status_command="./build/print-workspace-status.py --nostamp"
133
Serge Bazanski99b02142024-04-17 16:33:28 +0200134# Assume a 10k IOPS device (average NVMe) and 64GiB of RAM for test scheduling.
Tim Windelschmidt5be299e2024-07-13 02:59:52 +0200135test --local_resources=iops=10000 --local_resources=ram=64000
Tim Windelschmidtf1e0fa12024-07-17 21:28:23 +0200136
Tim Windelschmidt78fd25b2025-07-02 21:30:09 +0200137common --downloader_config=build/bazel/bazel_downloader.cfg
Tim Windelschmidt5178dd72024-12-04 04:38:45 +0100138
Tim Windelschmidtf1e0fa12024-07-17 21:28:23 +0200139# Load custom per-user settings.
Serge Bazanskif9c82492024-09-16 16:50:39 +0200140try-import %workspace%/.bazelrc.user