.bazelrc 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. build --crosstool_top=@bazel_cc_toolchain
  5. build --host_crosstool_top=@bazel_cc_toolchain
  6. # Default to using a disk cache to minimize re-building LLVM and Clang which we
  7. # try to avoid updating too frequently to minimize rebuild cost. The location
  8. # here can be overridden in the user configuration where needed.
  9. #
  10. # Note that this cache will grow without bound currently. You should
  11. # periodically run the `scripts/clean_disk_cache.sh` script or some equivalent.
  12. # https://github.com/bazelbuild/bazel/issues/5139 tracks fixing this in Bazel.
  13. build --disk_cache=~/.cache/carbon-lang-build-cache
  14. # Enable some safety when using the build cache, likely to be defaulted in
  15. # future Bazel releases.
  16. build --experimental_guard_against_concurrent_changes
  17. # Allow the toolchain to configure itself differently in the host build from
  18. # the target build. Even when the host and target platforms are ostensibly the
  19. # same (and use identical toolchains), it is beneficial to be able to configure
  20. # the specific toolchain features enabled for the target separately from the
  21. # host. For example, sanitizers make sense for the target significantly more
  22. # than for the host.
  23. #
  24. # Bazel bug tracking undoing the default here:
  25. # https://github.com/bazelbuild/bazel/issues/13315
  26. build --incompatible_dont_enable_host_nonhost_crosstool_features=false
  27. # Disable warnings for all external compilations. These involve code that isn't
  28. # developed as part of Carbon and may be difficult or impossible to patch, so
  29. # warnings aren't likely to be actionable.
  30. build --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  31. build --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
  32. # Default dynamic linking to off. While this can help build performance in some
  33. # edge cases with very large linked executables and a slow linker, between using
  34. # fast linkers on all platforms (LLD and the Apple linker), as well as having
  35. # relatively few such executables, shared objects simply waste too much space in
  36. # our builds.
  37. build --dynamic_mode=off
  38. # Always compile PIC code. There are few if any disadvantages on the platforms
  39. # and architectures we care about and it avoids the need to compile files twice.
  40. build --force_pic
  41. # Completely disable Bazel's automatic stripping of debug information. Removing
  42. # that information causes unhelpful backtraces from unittest failures and other
  43. # crashes. Optimized builds already avoid using debug information by default.
  44. build --strip=never
  45. # Enable Abseil for GoogleTest.
  46. build --define=absl=1
  47. # Configuration for enabling Address Sanitizer. Note that this is enabled by
  48. # default for fastbuild. The config is provided to enable ASan even in
  49. # optimized or other build configurations.
  50. build:asan --features=asan
  51. # Configuration for enabling LibFuzzer (along with ASan).
  52. build:fuzzer --features=fuzzer
  53. # Always allow tests to symbolize themselves with whatever `llvm-symbolize` is
  54. # in the users environment.
  55. build --test_env=ASAN_SYMBOLIZER_PATH
  56. # Force actions to have a UTF-8 language encoding.
  57. # TODO: Need to investigate what this should be on Windows, but at least for
  58. # Linux and macOS this seems strictly better than the Bazel default of just
  59. # `en_US`.
  60. build --action_env=LANG=en_US.UTF-8
  61. # Allow users to override any of the flags desired by importing a user-specific
  62. # RC file here if present.
  63. try-import %workspace%/user.bazelrc