-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
.bazelrc
132 lines (108 loc) · 6.06 KB
/
.bazelrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Ensure all builds have Carbon's workspace status attached. We have carefully
# factored the stamping done by this to avoid excessive build performance impact
# and so enable stamping with it by default. CI and systems especially dependent
# on caching should explicitly use `--nostamp`.
build --workspace_status_command=./scripts/workspace_status.py
build --stamp
# Provide aliases for configuring the release and pre-release version being
# built. For documentation of these flags, see //bazel/version/BUILD.
build --flag_alias=release=//bazel/version:release
build --flag_alias=pre_release=//bazel/version:pre_release
build --flag_alias=rc_number=//bazel/version:rc_number
build --flag_alias=nightly_date=//bazel/version:nightly_date
# Support running clang-tidy with:
# bazel build --config=clang-tidy -k //...
# See: https://github.com/erenon/bazel_clang_tidy
build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
build:clang-tidy --output_groups=report
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config
# This warning seems to incorrectly fire in this build configuration, despite
# not firing in our normal builds.
build:clang-tidy --copt=-Wno-unknown-pragmas
# Provide an alias for controlling the `carbon_*` Bazel rules' configuration. We
# enable use of the target config here to make our build and tests more
# efficient, see the documentation in //bazel/carbon_rules/BUILD for details.
build --flag_alias=use_target_config_carbon_rules=//bazel/carbon_rules:use_target_config_carbon_rules
build --use_target_config_carbon_rules
# Default to using a disk cache to minimize re-building LLVM and Clang which we
# try to avoid updating too frequently to minimize rebuild cost. The location
# here can be overridden in the user configuration where needed.
#
# Note that this cache will grow without bound currently. You should
# periodically run the `scripts/clean_disk_cache.sh` script or some equivalent.
# https://github.com/bazelbuild/bazel/issues/5139 tracks fixing this in Bazel.
build --disk_cache=~/.cache/carbon-lang-build-cache
# Enable some safety when using the build cache, likely to be defaulted in
# future Bazel releases.
build --experimental_guard_against_concurrent_changes
# Disable warnings for all external compilations. These involve code that isn't
# developed as part of Carbon and may be difficult or impossible to patch, so
# warnings aren't likely to be actionable.
build --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
build --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
# The `rules_treesitter` synthesized libraries don't allow us to inject flags,
# and compile generated code where we can't fix warnings.
build --per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w
build --host_per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w
# The `cc_proto_library` rule doesn't allow providing `copts`:
# https://github.com/bazelbuild/bazel/issues/22610
#
# We unfortunately need to work around issues with `-Wmissing-prototypes` in
# generated protobuf code, so pass the `copt` manually here. The warning issue
# is likely part of:
# https://github.com/llvm/llvm-project/issues/94138
build --per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes
build --host_per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes
# Default dynamic linking to off. While this can help build performance in some
# edge cases with very large linked executables and a slow linker, between using
# fast linkers on all platforms (LLD and the Apple linker), as well as having
# relatively few such executables, shared objects simply waste too much space in
# our builds.
build --dynamic_mode=off
# Always compile PIC code. There are few if any disadvantages on the platforms
# and architectures we care about and it avoids the need to compile files twice.
build --force_pic
# Completely disable Bazel's automatic stripping of debug information. Removing
# that information causes unhelpful backtraces from unittest failures and other
# crashes. Optimized builds already avoid using debug information by default.
build --strip=never
# Enable Abseil for GoogleTest.
build --define=absl=1
# Enable TCMalloc on Linux in optimized builds.
build --custom_malloc=//bazel/malloc:tcmalloc_if_linux_opt
# Configuration for enabling Address Sanitizer. Note that this is enabled by
# default for fastbuild. The config is provided to enable ASan even in
# optimized or other build configurations. Note that ASan and TCMalloc are
# incompatible so this explicitly forces the system malloc.
build:asan --features=asan
build:asan --custom_malloc=@bazel_tools//tools/cpp:malloc
# Configuration for enabling LibFuzzer (along with ASan).
build:fuzzer --features=fuzzer
# Always allow tests to symbolize themselves with whatever `llvm-symbolize` is
# in the users environment.
build --test_env=ASAN_SYMBOLIZER_PATH
# Force actions to have a UTF-8 language encoding.
# TODO: Need to investigate what this should be on Windows, but at least for
# Linux and macOS this seems strictly better than the Bazel default of just
# `en_US`.
build --action_env=LANG=en_US.UTF-8
# Allow per-platform configuration.
build --enable_platform_specific_config
# Enable libpfm for google_benchmark on Linux only.
build:linux --define=pfm=1
# Enable split debug info on Linux, which is significantly more space efficient
# and should work well with modern debuggers. Note that this is Linux specific
# as macOS has its own approach that is always partially but not completely
# split.
#
# Note: if using GDB, see documentation to get that working:
# https://docs.carbon-lang.dev/docs/project/contribution_tools.html#debugging-with-gdb-instead-of-lldb
build:linux --fission=yes
# Disables `actions.declare_symlink`. Done for cross-environment support.
build --allow_unresolved_symlinks=false
# Allow users to override any of the flags desired by importing a user-specific
# RC file here if present.
try-import %workspace%/user.bazelrc