defs.bzl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. """Provides helpers for cc rules. Intended for general consumption."""
  5. load("@bazel_cc_toolchain//:clang_detected_variables.bzl", "llvm_symbolizer")
  6. def cc_env():
  7. """Returns standard environment settings for a cc_binary.
  8. In use, this looks like:
  9. ```
  10. load("//bazel/cc_toolchains:defs.bzl", "cc_env")
  11. cc_binary(
  12. ...
  13. env = cc_env(),
  14. )
  15. ```
  16. We're currently setting this on a target-by-target basis, mainly because
  17. it's difficult to modify default behaviors.
  18. """
  19. # On macOS, there's a nano zone allocation warning due to asan (arises
  20. # in fastbuild/dbg). This suppresses the warning in `bazel run`.
  21. #
  22. # Concatenation of a dict with a select isn't supported, so we concatenate
  23. # within the select.
  24. # https://github.com/bazelbuild/bazel/issues/12457
  25. return select({
  26. "//bazel/cc_toolchains:macos_asan": {
  27. "LLVM_SYMBOLIZER_PATH": llvm_symbolizer,
  28. "MallocNanoZone": "0",
  29. },
  30. "//conditions:default": {
  31. "LLVM_SYMBOLIZER_PATH": llvm_symbolizer,
  32. },
  33. })