.bazelrc 4.0 KB

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