Skip to content

Commit ab3dc51

Browse files
Nikita Patskovfacebook-github-bot
authored andcommitted
Enable transformation spec for rust with link groups
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 link groups Reviewed By: dtolnay Differential Revision: D83559462 fbshipit-source-id: f6095b7e81bdc1ebec58b77f7b78643bdcad2eee
1 parent 557ee91 commit ab3dc51

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

prelude/rust/link_info.bzl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ load(
4040
"@prelude//cxx:link_groups_types.bzl",
4141
"LinkGroupInfo", # @unused Used as a type
4242
)
43+
load(
44+
"@prelude//cxx:transformation_spec.bzl",
45+
"TransformationSpecContext", # @unused Used as a type
46+
)
4347
load(
4448
"@prelude//linking:link_groups.bzl",
4549
"LinkGroupLib", # @unused Used as a type
@@ -411,7 +415,8 @@ def inherited_third_party_builds(ctx: AnalysisContext, dep_ctx: DepCollectionCon
411415
def inherited_rust_cxx_link_group_info(
412416
ctx: AnalysisContext,
413417
dep_ctx: DepCollectionContext,
414-
link_strategy: LinkStrategy) -> RustCxxLinkGroupInfo | None:
418+
link_strategy: LinkStrategy,
419+
transformation_spec_context: TransformationSpecContext | None) -> RustCxxLinkGroupInfo | None:
415420
# Check minimum requirements
416421
if not cxx_is_gnu(ctx) or not ctx.attrs.auto_link_groups:
417422
return None
@@ -467,6 +472,7 @@ def inherited_rust_cxx_link_group_info(
467472
prefer_stripped_objects = False, # Does Rust ever use stripped objects?
468473
anonymous = ctx.attrs.anonymous_link_groups,
469474
public_nodes = public_link_group_nodes,
475+
transformation_spec_context = transformation_spec_context,
470476
)
471477

472478
auto_link_groups = {}

prelude/rust/rust_binary.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,14 @@ def _rust_binary_common(
149149
predeclared_output = ctx.actions.declare_output(name)
150150
final_output = predeclared_output
151151

152+
build_graph_info = new_build_graph_info(ctx, cxx_deps)
153+
transformation_spec_context = build_transformation_spec_context(ctx, build_graph_info)
154+
152155
rust_cxx_link_group_info = inherited_rust_cxx_link_group_info(
153156
ctx,
154157
compile_ctx.dep_ctx,
155158
link_strategy = link_strategy,
159+
transformation_spec_context = transformation_spec_context,
156160
)
157161
if rust_cxx_link_group_info != None:
158162
link_group_mappings = rust_cxx_link_group_info.link_group_info.mappings
@@ -183,9 +187,6 @@ def _rust_binary_common(
183187
targets_consumed_by_link_groups = targets_consumed_by_link_groups,
184188
)
185189

186-
build_graph_info = new_build_graph_info(ctx, cxx_deps)
187-
transformation_spec_context = build_transformation_spec_context(ctx, build_graph_info)
188-
189190
# Gather and setup symlink tree of transitive shared library deps.
190191
shared_libs = build_shared_libs_for_symlink_tree(
191192
use_link_groups = rust_cxx_link_group_info != None,

0 commit comments

Comments
 (0)