.bazelrc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. build --workspace_status_command=./scripts/workspace_status.py
  9. build --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. build --flag_alias=release=//bazel/version:release
  13. build --flag_alias=pre_release=//bazel/version:pre_release
  14. build --flag_alias=rc_number=//bazel/version:rc_number
  15. build --flag_alias=beta_number=//bazel/version:beta_number
  16. build --flag_alias=alpha_number=//bazel/version:alpha_number
  17. build --flag_alias=nightly_date=//bazel/version:nightly_date
  18. # Support running clang-tidy with:
  19. # bazel build --config=clang-tidy -k //...
  20. # See: https://github.com/erenon/bazel_clang_tidy
  21. build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
  22. build:clang-tidy --output_groups=report
  23. build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config
  24. # This warning seems to incorrectly fire in this build configuration, despite
  25. # not firing in our normal builds.
  26. build:clang-tidy --copt=-Wno-unknown-pragmas
  27. # Provide an alias for controlling the `carbon_*` Bazel rules' configuration. We
  28. # enable use of the target config here to make our build and tests more
  29. # efficient, see the documentation in //bazel/carbon_rules/BUILD for details.
  30. build --flag_alias=use_target_config_carbon_rules=//bazel/carbon_rules:use_target_config_carbon_rules
  31. build --use_target_config_carbon_rules
  32. # Default to using a disk cache to minimize re-building LLVM and Clang which we
  33. # try to avoid updating too frequently to minimize rebuild cost. The location
  34. # here can be overridden in the user configuration where needed.
  35. #
  36. # Note that this cache will grow without bound currently. You should
  37. # periodically run the `scripts/clean_disk_cache.sh` script or some equivalent.
  38. # https://github.com/bazelbuild/bazel/issues/5139 tracks fixing this in Bazel.
  39. build --disk_cache=~/.cache/carbon-lang-build-cache
  40. # Enable some safety when using the build cache, likely to be defaulted in
  41. # future Bazel releases.
  42. build --experimental_guard_against_concurrent_changes
  43. # Disable warnings for all external compilations. These involve code that isn't
  44. # developed as part of Carbon and may be difficult or impossible to patch, so
  45. # warnings aren't likely to be actionable.
  46. build --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  47. build --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  48. # The `rules_treesitter` synthesized libraries don't allow us to inject flags,
  49. # and compile generated code where we can't fix warnings.
  50. build --per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w
  51. build --host_per_file_copt=utils/treesitter/_treesitter.tree_sitter/.*\.c$@-w
  52. # The `cc_proto_library` rule doesn't allow providing `copts`:
  53. # https://github.com/bazelbuild/bazel/issues/22610
  54. #
  55. # We unfortunately need to work around issues with `-Wmissing-prototypes` in
  56. # generated protobuf code, so pass the `copt` manually here. The warning issue
  57. # is likely part of:
  58. # https://github.com/llvm/llvm-project/issues/94138
  59. build --per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes
  60. build --host_per_file_copt=.*\.pb\.cc$@-Wno-missing-prototypes
  61. # Default dynamic linking to off. While this can help build performance in some
  62. # edge cases with very large linked executables and a slow linker, between using
  63. # fast linkers on all platforms (LLD and the Apple linker), as well as having
  64. # relatively few such executables, shared objects simply waste too much space in
  65. # our builds.
  66. build --dynamic_mode=off
  67. # Always compile PIC code. There are few if any disadvantages on the platforms
  68. # and architectures we care about and it avoids the need to compile files twice.
  69. build --force_pic
  70. # Completely disable Bazel's automatic stripping of debug information. Removing
  71. # that information causes unhelpful backtraces from unittest failures and other
  72. # crashes. Optimized builds already avoid using debug information by default.
  73. build --strip=never
  74. # Enable Abseil for GoogleTest.
  75. build --define=absl=1
  76. # Configuration for enabling Address Sanitizer. Note that this is enabled by
  77. # default for fastbuild. The config is provided to enable ASan even in
  78. # optimized or other build configurations.
  79. build:asan --features=asan
  80. # Configuration for enabling LibFuzzer (along with ASan).
  81. build:fuzzer --features=fuzzer
  82. # Always allow tests to symbolize themselves with whatever `llvm-symbolize` is
  83. # in the users environment.
  84. build --test_env=ASAN_SYMBOLIZER_PATH
  85. # Force actions to have a UTF-8 language encoding.
  86. # TODO: Need to investigate what this should be on Windows, but at least for
  87. # Linux and macOS this seems strictly better than the Bazel default of just
  88. # `en_US`.
  89. build --action_env=LANG=en_US.UTF-8
  90. # Enable libpfm for google_benchmark on Linux only.
  91. build --enable_platform_specific_config
  92. build:linux --define=pfm=1
  93. # Allow users to override any of the flags desired by importing a user-specific
  94. # RC file here if present.
  95. try-import %workspace%/user.bazelrc