.bazelrc 4.9 KB

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