Skip to content

Commit b618de3

Browse files
Nikita Patskovfacebook-github-bot
authored andcommitted
Enable tranformation spec for rust with shared linking
Summary: Transformation specs should also be available for Rust (mostly to migrate off link group-based APIs that is currently rolled out for rust too). Thankfully this is easy to configure because all we should do is to propagate the values and all handling will work out of the box. Passing transformation spec context to part that handles shared linkage Reviewed By: dtolnay Differential Revision: D83559460 fbshipit-source-id: 8484d265c96f10ae721431f26fec18a49e01ec41
1 parent 61a6ecb commit b618de3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

prelude/rust/rust_binary.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ load(
3131
"get_link_group_map_json",
3232
)
3333
load("@prelude//cxx:linker.bzl", "DUMPBIN_SUB_TARGET", "PDB_SUB_TARGET", "get_dumpbin_providers", "get_pdb_providers")
34+
load("@prelude//cxx:transformation_spec.bzl", "build_transformation_spec_context")
3435
load(
3536
"@prelude//dist:dist_info.bzl",
3637
"DistInfo",
@@ -53,6 +54,10 @@ load(
5354
"@prelude//tests:re_utils.bzl",
5455
"get_re_executors_from_props",
5556
)
57+
load(
58+
"@prelude//utils:build_graph_pattern.bzl",
59+
"new_build_graph_info",
60+
)
5661
load("@prelude//utils:utils.bzl", "flatten_dict")
5762
load(
5863
":build.bzl",
@@ -119,10 +124,11 @@ def _rust_binary_common(
119124
link_strategy = LinkStrategy(ctx.attrs.link_style) if ctx.attrs.link_style else DEFAULT_STATIC_LINK_STRATEGY
120125
link_strategy = process_link_strategy_for_pic_behavior(link_strategy, compile_ctx.cxx_toolchain_info.pic_behavior)
121126

127+
cxx_deps = cxx_attr_deps(ctx)
122128
resources = flatten_dict(gather_resources(
123129
label = ctx.label,
124130
resources = rust_attr_resources(ctx),
125-
deps = cxx_attr_deps(ctx),
131+
deps = cxx_deps,
126132
).values())
127133

128134
extra_flags = toolchain_info.rustc_binary_flags + (extra_flags or [])
@@ -177,12 +183,15 @@ def _rust_binary_common(
177183
targets_consumed_by_link_groups = targets_consumed_by_link_groups,
178184
)
179185

186+
build_graph_info = new_build_graph_info(ctx, cxx_deps)
187+
transformation_spec_context = build_transformation_spec_context(ctx, build_graph_info)
188+
180189
# Gather and setup symlink tree of transitive shared library deps.
181190
shared_libs = build_shared_libs_for_symlink_tree(
182191
use_link_groups = rust_cxx_link_group_info != None,
183192
link_group_ctx = link_group_ctx,
184193
link_strategy = link_strategy,
185-
shared_libraries = traverse_shared_library_info(shlib_info, transformation_provider = None),
194+
shared_libraries = traverse_shared_library_info(shlib_info, transformation_provider = transformation_spec_context),
186195
extra_shared_libraries = [],
187196
)
188197

0 commit comments

Comments
 (0)