Skip to content

Commit bafddd8

Browse files
authored
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
1 parent 8ecf844 commit bafddd8

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ build --custom_malloc=//bazel/malloc:tcmalloc_if_linux_opt
9494
# optimized or other build configurations. Note that ASan and TCMalloc are
9595
# incompatible so this explicitly forces the system malloc.
9696
build:asan --features=asan
97-
build:asan --custom_malloc=//bazel/malloc:system_malloc
97+
build:asan --custom_malloc=@bazel_tools//tools/cpp:malloc
9898

9999
# Configuration for enabling LibFuzzer (along with ASan).
100100
build:fuzzer --features=fuzzer

bazel/malloc/BUILD

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@ selects.config_setting_group(
2323
],
2424
)
2525

26-
# A placeholder empty library that can be used as a `malloc` attribute or with
27-
# the `--custom_malloc` bazel flag to have no custom malloc and use the system
28-
# malloc instead.
29-
cc_library(name = "system_malloc")
30-
3126
# A library that enables TCMalloc for optimized builds on Linux. On other
3227
# platforms and configurations, this falls back on the system malloc.
3328
cc_library(
3429
name = "tcmalloc_if_linux_opt",
3530
deps = select({
3631
":linux_opt": ["@tcmalloc//tcmalloc"],
37-
"//conditions:default": [":system_malloc"],
32+
"//conditions:default": ["@bazel_tools//tools/cpp:malloc"],
3833
}),
3934
)

0 commit comments

Comments
 (0)