Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read the custom_malloc configuration field in swift_{binary,test} to use an allocator provided by the --custom_malloc flag, if any. #478

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

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

will this always exist? should it be if malloc: still ?

Copy link
Member Author

Choose a reason for hiding this comment

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

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