Files
carbon-lang/bazel/malloc/BUILD
T
Jon Ross-Perkins bafddd8711 Use @bazel_tools//tools/cpp:malloc instead of defining a library (#4404)
@bazel_tools//tools/cpp:malloc is equivalent and comes from
https://bazel.build/reference/be/c-cpp#cc_binary.malloc. This also
avoids some confusion in the documentation, since while system_malloc
_can_ be used with `malloc`, it has no effect when it's used with
`--custom_malloc`. But, rather than trying to adjust that, maybe we can
just use @bazel_tools//tools/cpp:malloc
2024-10-11 21:11:11 +00:00

35 lines
913 B
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:defs.bzl", "cc_library")
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
)
config_setting(
name = "opt",
values = {"compilation_mode": "opt"},
)
selects.config_setting_group(
name = "linux_opt",
match_all = [
":is_linux",
":opt",
],
)
# A library that enables TCMalloc for optimized builds on Linux. On other
# platforms and configurations, this falls back on the system malloc.
cc_library(
name = "tcmalloc_if_linux_opt",
deps = select({
":linux_opt": ["@tcmalloc//tcmalloc"],
"//conditions:default": ["@bazel_tools//tools/cpp:malloc"],
}),
)