Skip to content

Commit a59b8d1

Browse files
keithallevato
andauthored
Read the custom_malloc configuration field in swift_{binary,test} to use an allocator provided by the --custom_malloc flag, if any. (#478)
PiperOrigin-RevId: 329317960 Co-authored-by: Tony Allevato <[email protected]>
1 parent d5eb04f commit a59b8d1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

swift/internal/swift_binary_test.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ into the binary. Possible values are:
7878
"_cc_toolchain": attr.label(
7979
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
8080
),
81+
# A late-bound attribute denoting the value of the `--custom_malloc`
82+
# command line flag (or None if the flag is not provided).
83+
"_custom_malloc": attr.label(
84+
default = configuration_field(
85+
fragment = "cpp",
86+
name = "custom_malloc",
87+
),
88+
providers = [[CcInfo]],
89+
),
8190
# TODO(b/119082664): Used internally only.
8291
"_grep_includes": attr.label(
8392
allow_single_file = True,
@@ -215,10 +224,8 @@ def _swift_linking_rule_impl(
215224

216225
# If a custom malloc implementation has been provided, pass that to the
217226
# linker as well.
218-
if ctx.attr.malloc:
219-
additional_linking_contexts.append(
220-
ctx.attr.malloc[CcInfo].linking_context,
221-
)
227+
malloc = ctx.attr._custom_malloc or ctx.attr.malloc
228+
additional_linking_contexts.append(malloc[CcInfo].linking_context)
222229

223230
# Finally, consider linker flags in the `linkopts` attribute and the
224231
# `--linkopt` command line flag last, so they get highest priority.

0 commit comments

Comments
 (0)