defs.bzl 927 B

12345678910111213141516171819202122
  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. env = {"LLVM_SYMBOLIZER_PATH": llvm_symbolizer}
  9. # On macOS, there's a nano zone allocation warning due to asan (arises
  10. # in fastbuild/dbg). This suppresses the warning in `bazel run`.
  11. #
  12. # Concatenation of a dict with a select isn't supported, so we concatenate
  13. # within the select.
  14. # https://github.com/bazelbuild/bazel/issues/12457
  15. return select({
  16. "//bazel/cc_toolchains:macos_asan": env.update({"MallocNanoZone": "0"}),
  17. "//conditions:default": env,
  18. })