-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
.bazelrc
230 lines (199 loc) · 10.7 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# 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
build:clang-tidy --action_env=PATH --host_action_env=PATH
# 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
# Used by clang_configuration.bzl.
build --action_env=CC --host_action_env=CC
build --action_env=CMAKE_SYSROOT --host_action_env=CMAKE_SYSROOT
# 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
# 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
#
# TODO: Bazel has a bug where it doesn't manage dwo files in the cache correctly.
# 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
# Incompatible with `rules_tree_sitter`.
# TODO: WORKSPACE will be removed in bazel 9, and we need to move off.
# TODO: The registry has a different treesitter rule set, and we should
# investigate switching. See:
# https://registry.bazel.build/modules/tree-sitter-bazel
common --enable_workspace
# This is on by default in bazel 8.
common --incompatible_disallow_empty_glob=false
# common --incompatible_auto_exec_groups
# common --incompatible_disable_starlark_host_transitions
# This excludes things like rules_android to reduce warnings.
# TODO: There's a pending fix, so hopefully we can remove it soon.
# - Issue: https://github.com/bazelbuild/bazel/issues/23929
# - 8.0.1 tracker: https://github.com/bazelbuild/bazel/issues/24649
common --incompatible_autoload_externally=+@rules_java,+@rules_python,+@rules_shell
# Query error in `@bazel_tools`. This reproduces with
# `bazel query 'deps(//...)'`.
# TODO: Enable the flag once compatibility issues are fixed.
# common --incompatible_disable_non_executable_java_binary
# Incompatible with `rules_cc`.
# TODO: Enable the flag once compatibility issues are fixed.
# common --incompatible_no_rule_outputs_param
# common --incompatible_stop_exporting_language_modules
# Incompatible with `rules_pkg`.
# TODO: Enable the flag once compatibility issues are fixed.
# common --incompatible_disable_target_default_provider_fields
# Incompatible with `rules_shell`.
# TODO: Enable the flag once compatibility issues are fixed.
# common --incompatible_check_visibility_for_toolchains
# Enable as many incompatible flags as we can, per
# https://bazel.build/release/backward-compatibility. To get the latest list,
# using `bazelisk --migrate build //...` will help.
common --incompatible_allow_tags_propagation
common --incompatible_always_check_depset_elements
common --incompatible_always_include_files_in_data
common --incompatible_bazel_test_exec_run_under
common --incompatible_check_sharding_support
common --incompatible_check_testonly_for_output_files
common --incompatible_config_setting_private_default_visibility
common --incompatible_default_to_explicit_init_py
common --incompatible_depset_for_java_output_source_jars
common --incompatible_depset_for_libraries_to_link_getter
common --incompatible_disable_native_android_rules
common --incompatible_disable_native_repo_rules
common --incompatible_disable_objc_library_transition
common --incompatible_disable_target_provider_fields
common --incompatible_disallow_ctx_resolve_tools
common --incompatible_disallow_legacy_py_provider
common --incompatible_disallow_sdk_frameworks_attributes
common --incompatible_disallow_struct_provider_syntax
common --incompatible_do_not_split_linking_cmdline
common --incompatible_dont_enable_host_nonhost_crosstool_features
common --incompatible_dont_use_javasourceinfoprovider
common --incompatible_enable_apple_toolchain_resolution
common --incompatible_enable_deprecated_label_apis
common --incompatible_enable_proto_toolchain_resolution
common --incompatible_enforce_config_setting_visibility
common --incompatible_exclusive_test_sandboxed
common --incompatible_fail_on_unknown_attributes
common --incompatible_fix_package_group_reporoot_syntax
common --incompatible_java_common_parameters
common --incompatible_legacy_local_fallback
common --incompatible_make_thinlto_command_lines_standalone
common --incompatible_merge_fixed_and_default_shell_env
common --incompatible_merge_genfiles_directory
common --incompatible_modify_execution_info_additive
common --incompatible_new_actions_api
common --incompatible_no_attr_license
common --incompatible_no_implicit_file_export
common --incompatible_no_implicit_watch_label
common --incompatible_objc_alwayslink_by_default
common --incompatible_package_group_has_public_syntax
common --incompatible_py2_outputs_are_suffixed
common --incompatible_py3_is_default
common --incompatible_python_disable_py2
common --incompatible_python_disallow_native_rules
common --incompatible_remote_use_new_exit_code_for_lost_inputs
common --incompatible_remove_legacy_whole_archive
common --incompatible_require_ctx_in_configure_features
common --incompatible_require_linker_input_cc_api
common --incompatible_run_shell_command_string
common --incompatible_sandbox_hermetic_tmp
common --incompatible_simplify_unconditional_selects_in_rule_attrs
common --incompatible_stop_exporting_build_file_path
common --incompatible_strict_action_env
common --incompatible_strip_executable_safely
common --incompatible_top_level_aspects_require_providers
common --incompatible_unambiguous_label_stringification
common --incompatible_use_cc_configure_from_rules_cc
common --incompatible_use_new_cgroup_implementation
common --incompatible_use_plus_in_repo_names
common --incompatible_use_python_toolchains
common --incompatible_validate_top_level_header_inclusions
common --incompatible_visibility_private_attributes_at_definition