Skip to content

Commit

Permalink
Read the custom_malloc configuration field in swift_{binary,test}
Browse files Browse the repository at this point in the history
… to use an allocator provided by the `--custom_malloc` flag, if any.

PiperOrigin-RevId: 329317960
  • Loading branch information
allevato authored and swiple-rules-gardener committed Aug 31, 2020
1 parent 6154179 commit bb8196d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions swift/internal/swift_binary_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ into the binary. Possible values are:
"_cc_toolchain": attr.label(
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
),
# A late-bound attribute denoting the value of the `--custom_malloc`
# command line flag (or None if the flag is not provided).
"_custom_malloc": attr.label(
default = configuration_field(
fragment = "cpp",
name = "custom_malloc",
),
providers = [[CcInfo]],
),
# TODO(b/119082664): Used internally only.
"_grep_includes": attr.label(
allow_single_file = True,
Expand Down Expand Up @@ -215,10 +224,8 @@ def _swift_linking_rule_impl(

# If a custom malloc implementation has been provided, pass that to the
# linker as well.
if ctx.attr.malloc:
additional_linking_contexts.append(
ctx.attr.malloc[CcInfo].linking_context,
)
malloc = ctx.attr._custom_malloc or ctx.attr.malloc
additional_linking_contexts.append(malloc[CcInfo].linking_context)

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

1 comment on commit bb8196d

@keith
Copy link
Member

@keith keith commented on bb8196d Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.