.bazelrc 6.1 KB

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