.bazelrc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. # Ensure all builds have Carbon's workspace status attached. We have carefully
  5. # factored the stamping done by this to avoid excessive build performance impact
  6. # and so enable stamping with it by default. CI and systems especially dependent
  7. # on caching should explicitly use `--nostamp`.
  8. common --workspace_status_command=./scripts/workspace_status.py
  9. common --stamp
  10. # Provide aliases for configuring the release and pre-release version being
  11. # built. For documentation of these flags, see //bazel/version/BUILD.
  12. common --flag_alias=release=//bazel/version:release
  13. common --flag_alias=pre_release=//bazel/version:pre_release
  14. common --flag_alias=rc_number=//bazel/version:rc_number
  15. common --flag_alias=nightly_date=//bazel/version:nightly_date
  16. # Support running clang-tidy with:
  17. # bazel build --config=clang-tidy -k //...
  18. # See: https://github.com/erenon/bazel_clang_tidy
  19. common:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
  20. common:clang-tidy --output_groups=report
  21. common:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config
  22. common:clang-tidy --action_env=PATH --host_action_env=PATH
  23. # This warning seems to incorrectly fire in this build configuration, despite
  24. # not firing in our normal builds.
  25. common:clang-tidy --copt=-Wno-unknown-pragmas
  26. # --config=non-fatal-checks makes CHECK failures not terminate compilation.
  27. common:non-fatal-checks --per_file_copt=common/check_internal.cpp@-DCARBON_NON_FATAL_CHECKS
  28. # Provide an alias for controlling the `carbon_*` Bazel rules' configuration. We
  29. # enable use of the target config here to make our build and tests more
  30. # efficient, see the documentation in //bazel/carbon_rules/BUILD for details.
  31. common --flag_alias=use_target_config_carbon_rules=//bazel/carbon_rules:use_target_config_carbon_rules
  32. # Bazel doesn't track what commands the flag_alias is valid for, so we can't use
  33. # common here.
  34. build --use_target_config_carbon_rules
  35. # Default to using a disk cache to minimize re-building LLVM and Clang which we
  36. # try to avoid updating too frequently to minimize rebuild cost. The location
  37. # here can be overridden in the user configuration where needed.
  38. common --disk_cache=~/.cache/carbon-lang-build-cache
  39. # If you'd like a different disk cache size, override it by copying this
  40. # line to `user.bazelrc` in the repository root and modify the number there.
  41. common --experimental_disk_cache_gc_max_size=100G
  42. # Enable some safety when using the build cache, likely to be defaulted in
  43. # future Bazel releases.
  44. common --experimental_guard_against_concurrent_changes
  45. # Used by clang_configuration.bzl.
  46. common --action_env=CC --host_action_env=CC
  47. common --action_env=CMAKE_SYSROOT --host_action_env=CMAKE_SYSROOT
  48. # Disable warnings for all external compilations. These involve code that isn't
  49. # developed as part of Carbon and may be difficult or impossible to patch, so
  50. # warnings aren't likely to be actionable.
  51. common --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  52. common --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  53. # Default dynamic linking to off. While this can help build performance in some
  54. # edge cases with very large linked executables and a slow linker, between using
  55. # fast linkers on all platforms (LLD and the Apple linker), as well as having
  56. # relatively few such executables, shared objects simply waste too much space in
  57. # our builds.
  58. common --dynamic_mode=off
  59. # Always compile PIC code. There are few if any disadvantages on the platforms
  60. # and architectures we care about and it avoids the need to compile files twice.
  61. common --force_pic
  62. # Completely disable Bazel's automatic stripping of debug information. Removing
  63. # that information causes unhelpful backtraces from unittest failures and other
  64. # crashes. Optimized builds already avoid using debug information by default.
  65. common --strip=never
  66. # Enable Abseil for GoogleTest.
  67. common --define=absl=1
  68. # Enable TCMalloc on Linux in optimized builds.
  69. common --custom_malloc=//bazel/malloc:tcmalloc_if_linux_opt
  70. # Configuration for enabling Address Sanitizer. Note that this is enabled by
  71. # default for fastbuild. The config is provided to enable ASan even in
  72. # optimized or other build configurations. Note that ASan and TCMalloc are
  73. # incompatible so this explicitly forces the system malloc.
  74. common:asan --features=asan
  75. common:asan --custom_malloc=@bazel_tools//tools/cpp:malloc
  76. # Configuration for enabling LibFuzzer (along with ASan).
  77. common:fuzzer --features=fuzzer
  78. # Always allow tests to symbolize themselves with whatever `llvm-symbolize` is
  79. # in the users environment.
  80. common --test_env=ASAN_SYMBOLIZER_PATH
  81. # Force actions to have a UTF-8 language encoding.
  82. # TODO: Need to investigate what this should be on Windows, but at least for
  83. # Linux and macOS this seems strictly better than the Bazel default of just
  84. # `en_US`.
  85. common --action_env=LANG=en_US.UTF-8
  86. # Allow per-platform configuration.
  87. common --enable_platform_specific_config
  88. # Enable libpfm for google_benchmark on Linux only.
  89. common:linux --define=pfm=1
  90. # Enable split debug info on Linux, which is significantly more space efficient
  91. # and should work well with modern debuggers. Note that this is Linux specific
  92. # as macOS has its own approach that is always partially but not completely
  93. # split.
  94. #
  95. # Note: if using GDB, see documentation to get that working:
  96. # https://docs.carbon-lang.dev/docs/project/contribution_tools.html#debugging-with-gdb-instead-of-lldb
  97. #
  98. # TODO: Bazel has a bug where it doesn't manage dwo files in the cache correctly.
  99. # common:linux --fission=yes
  100. # Disables `actions.declare_symlink`. Done for cross-environment support.
  101. common --allow_unresolved_symlinks=false
  102. # Allow users to override any of the flags desired by importing a user-specific
  103. # RC file here if present.
  104. try-import %workspace%/user.bazelrc
  105. # Query error in `@bazel_tools`. This reproduces with
  106. # `bazel query 'deps(//...)'`.
  107. # TODO: Enable the flag once compatibility issues are fixed.
  108. # common --incompatible_disable_non_executable_java_binary
  109. # Incompatible with the clang-tidy build mode.
  110. # TODO: Enable the flag once compatibility issues are fixed.
  111. # common --incompatible_auto_exec_groups
  112. # Incompatible with `rules_cc`.
  113. # TODO: Enable the flag once compatibility issues are fixed.
  114. # common --incompatible_no_rule_outputs_param
  115. # common --incompatible_stop_exporting_language_modules
  116. # Incompatible with `rules_flex`.
  117. # TODO: Enable the flag once compatibility issues are fixed.
  118. # common --incompatible_disable_starlark_host_transitions
  119. # Incompatible with `rules_pkg`.
  120. # TODO: Enable the flag once compatibility issues are fixed.
  121. # common --incompatible_disable_target_default_provider_fields
  122. # Incompatible with `rules_shell`.
  123. # TODO: Enable the flag once compatibility issues are fixed.
  124. # common --incompatible_check_visibility_for_toolchains
  125. # Enable as many incompatible flags as we can, per
  126. # https://bazel.build/release/backward-compatibility. To get the latest list,
  127. # using `bazelisk --migrate build //...` will help.
  128. common --incompatible_allow_tags_propagation
  129. common --incompatible_always_check_depset_elements
  130. common --incompatible_always_include_files_in_data
  131. common --incompatible_bazel_test_exec_run_under
  132. common --incompatible_check_sharding_support
  133. common --incompatible_check_testonly_for_output_files
  134. common --incompatible_config_setting_private_default_visibility
  135. common --incompatible_default_to_explicit_init_py
  136. common --incompatible_depset_for_java_output_source_jars
  137. common --incompatible_depset_for_libraries_to_link_getter
  138. common --incompatible_disable_native_android_rules
  139. common --incompatible_disable_native_repo_rules
  140. common --incompatible_disable_objc_library_transition
  141. common --incompatible_disable_target_provider_fields
  142. common --incompatible_disallow_ctx_resolve_tools
  143. common --incompatible_disallow_empty_glob
  144. common --incompatible_disallow_legacy_py_provider
  145. common --incompatible_disallow_sdk_frameworks_attributes
  146. common --incompatible_disallow_struct_provider_syntax
  147. common --incompatible_do_not_split_linking_cmdline
  148. common --incompatible_dont_enable_host_nonhost_crosstool_features
  149. common --incompatible_dont_use_javasourceinfoprovider
  150. common --incompatible_enable_apple_toolchain_resolution
  151. common --incompatible_enable_deprecated_label_apis
  152. common --incompatible_enable_proto_toolchain_resolution
  153. common --incompatible_enforce_config_setting_visibility
  154. common --incompatible_exclusive_test_sandboxed
  155. common --incompatible_fail_on_unknown_attributes
  156. common --incompatible_fix_package_group_reporoot_syntax
  157. common --incompatible_java_common_parameters
  158. common --incompatible_legacy_local_fallback
  159. common --incompatible_locations_prefers_executable
  160. common --incompatible_make_thinlto_command_lines_standalone
  161. common --incompatible_merge_fixed_and_default_shell_env
  162. common --incompatible_merge_genfiles_directory
  163. common --incompatible_modify_execution_info_additive
  164. common --incompatible_new_actions_api
  165. common --incompatible_no_attr_license
  166. common --incompatible_no_implicit_file_export
  167. common --incompatible_no_implicit_watch_label
  168. common --incompatible_objc_alwayslink_by_default
  169. common --incompatible_package_group_has_public_syntax
  170. common --incompatible_py2_outputs_are_suffixed
  171. common --incompatible_py3_is_default
  172. common --incompatible_python_disable_py2
  173. common --incompatible_python_disallow_native_rules
  174. common --incompatible_remote_use_new_exit_code_for_lost_inputs
  175. common --incompatible_remove_legacy_whole_archive
  176. common --incompatible_require_ctx_in_configure_features
  177. common --incompatible_require_linker_input_cc_api
  178. common --incompatible_run_shell_command_string
  179. common --incompatible_sandbox_hermetic_tmp
  180. common --incompatible_simplify_unconditional_selects_in_rule_attrs
  181. common --incompatible_stop_exporting_build_file_path
  182. common --incompatible_strict_action_env
  183. common --incompatible_strip_executable_safely
  184. common --incompatible_top_level_aspects_require_providers
  185. common --incompatible_unambiguous_label_stringification
  186. common --incompatible_use_cc_configure_from_rules_cc
  187. common --incompatible_use_new_cgroup_implementation
  188. common --incompatible_use_plus_in_repo_names
  189. common --incompatible_use_python_toolchains
  190. common --incompatible_validate_top_level_header_inclusions
  191. common --incompatible_visibility_private_attributes_at_definition