mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:50:10 +01:00
Previously, we left it on by default and only disabled it in CI. However, as we have grown more and more examples, the cost of stamping has steadily risen: every example has to be rebuilt because the busybox binary and installation contain an updated stamp. I noticed that I was almost never getting cache hits for these even when I should and it seems like what was once true is no more for daily development. I've updated the default, the docs for the default, and explicitly enabled stamping in the nightly release workflow. I left the explicit disabling in the CI workflows as that seems harmless and a good defense in case we want to shift the default again. One alternative that I didn't pursue because of the complexity was to create two distinct installation prefixes automatically, one with the `.nostamp` suffixed binaries installed and one without that suffix. We could then point example builds and other within-Bazel uses at the non-stamped tree to get maximal caching. But it would create two whole installation trees without much benefit. It seemed simpler to just disable stamping by default for development builds.
222 lines
10 KiB
Plaintext
222 lines
10 KiB
Plaintext
# 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
|
|
|
|
# Setup stamping with Carbon's workspace status attached but disable it by
|
|
# default.
|
|
#
|
|
# Note that while we have minimized the impact of stamping on build caching, it
|
|
# still has a meaningful impact, especially during development. So we disable
|
|
# stamping by default and builds that need to include the workspace status
|
|
# should explicitly enable it with `--stamp`.
|
|
common --workspace_status_command=./scripts/workspace_status.py
|
|
common --nostamp
|
|
|
|
# Provide aliases for configuring the release and pre-release version being
|
|
# built. For documentation of these flags, see //bazel/version/BUILD.
|
|
common --flag_alias=release=//bazel/version:release
|
|
common --flag_alias=pre_release=//bazel/version:pre_release
|
|
common --flag_alias=rc_number=//bazel/version:rc_number
|
|
common --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
|
|
common:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
|
|
common:clang-tidy --output_groups=report
|
|
common:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config
|
|
common: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.
|
|
common:clang-tidy --copt=-Wno-unknown-pragmas
|
|
|
|
# --config=non-fatal-checks makes CHECK failures not terminate compilation.
|
|
common:non-fatal-checks --per_file_copt=common/check_internal.cpp@-DCARBON_NON_FATAL_CHECKS
|
|
|
|
# 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.
|
|
common --flag_alias=use_target_config_carbon_rules=//bazel/carbon_rules:use_target_config_carbon_rules
|
|
common --flag_alias=use_target_config_runtimes_builder=//toolchain/driver:use_target_config_runtimes_builder
|
|
# Bazel doesn't track what commands the flag_alias is valid for, so we can't use
|
|
# common here.
|
|
build --use_target_config_carbon_rules
|
|
build --use_target_config_runtimes_builder
|
|
|
|
# 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.
|
|
common --disk_cache=~/.cache/carbon-lang-build-cache
|
|
# If you'd like a different disk cache size, override it by copying this
|
|
# line to `user.bazelrc` in the repository root and modify the number there.
|
|
common --experimental_disk_cache_gc_max_size=100G
|
|
|
|
# Enable some safety when using the build cache. Defaults to `lite`.
|
|
common --guard_against_concurrent_changes=full
|
|
|
|
# Used by clang_configuration.bzl.
|
|
common --action_env=CC --host_action_env=CC
|
|
common --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.
|
|
common --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
|
|
common --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-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.
|
|
common --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.
|
|
common --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.
|
|
common --strip=never
|
|
|
|
# Enable Abseil for GoogleTest.
|
|
common --define=absl=1
|
|
|
|
# Enable TCMalloc on Linux in optimized builds.
|
|
common --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.
|
|
common:asan --features=asan
|
|
common:asan --custom_malloc=@bazel_tools//tools/cpp:malloc
|
|
|
|
# Configuration for enabling LibFuzzer (along with ASan).
|
|
common:fuzzer --features=fuzzer
|
|
|
|
# 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`.
|
|
common --action_env=LANG=en_US.UTF-8
|
|
|
|
# Allow per-platform configuration.
|
|
common --enable_platform_specific_config
|
|
|
|
# Enable libpfm for google_benchmark on Linux only.
|
|
common: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.
|
|
# common:linux --fission=yes
|
|
|
|
# Disables `actions.declare_symlink`. Done for cross-environment support.
|
|
common --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
|
|
|
|
# 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 the clang-tidy build mode.
|
|
# TODO: Enable the flag once compatibility issues are fixed.
|
|
# common --incompatible_auto_exec_groups
|
|
|
|
# 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_autoloads_in_main_repo
|
|
common --incompatible_disable_native_android_rules
|
|
common --incompatible_disable_native_repo_rules
|
|
common --incompatible_disable_objc_library_transition
|
|
common --incompatible_disable_starlark_host_transitions
|
|
common --incompatible_disable_target_provider_fields
|
|
common --incompatible_disallow_ctx_resolve_tools
|
|
common --incompatible_disallow_empty_glob
|
|
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_enforce_starlark_utf8
|
|
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_locations_prefers_executable
|
|
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
|