Skip to content

Commit

Permalink
Even more dep_link_style
Browse files Browse the repository at this point in the history
Summary:
See {D48258217}.

This is useful to me in an upcoming diff where I need to adjust how `style_info` and `dep_link_style` interact with external debuginfo (Split DWARF).

Reviewed By: zertosh, shayne-fletcher

Differential Revision: D48277525

fbshipit-source-id: ec28f3815e779f9f80132f2e146abf729bd362dd
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Aug 11, 2023
1 parent 6f11382 commit 74ab215
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions prelude/rust/link_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ RustLinkStyleInfo = record(
external_debug_info = field(ArtifactTSet.type),
)

def style_info(info: RustLinkInfo.type, link_style: LinkStyle.type) -> RustLinkStyleInfo.type:
if FORCE_RLIB and link_style == LinkStyle("shared"):
link_style = DEFAULT_STATIC_LINK_STYLE
def style_info(info: RustLinkInfo.type, dep_link_style: LinkStyle.type) -> RustLinkStyleInfo.type:
if FORCE_RLIB and dep_link_style == LinkStyle("shared"):
dep_link_style = DEFAULT_STATIC_LINK_STYLE

return info.styles[link_style]
return info.styles[dep_link_style]

# A Rust dependency
RustDependency = record(
Expand Down
11 changes: 6 additions & 5 deletions prelude/rust/rust_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def prebuilt_rust_library_impl(ctx: AnalysisContext) -> list[Provider]:
crate = attr_crate(ctx)
styles = {}
for style in LinkStyle:
tdeps, tmetadeps, external_debug_info = _compute_transitive_deps(ctx, style)
dep_link_style = style
tdeps, tmetadeps, external_debug_info = _compute_transitive_deps(ctx, dep_link_style)
external_debug_info = make_artifact_tset(
actions = ctx.actions,
children = external_debug_info,
Expand Down Expand Up @@ -393,12 +394,12 @@ def _handle_rust_artifact(
is computing the right set of dependencies.
"""

link_style = params.dep_link_style
dep_link_style = params.dep_link_style

# If we're a crate where our consumers should care about transitive deps,
# then compute them (specifically, not proc-macro).
if crate_type_transitive_deps(params.crate_type):
tdeps, tmetadeps, external_debug_info = _compute_transitive_deps(ctx, link_style)
tdeps, tmetadeps, external_debug_info = _compute_transitive_deps(ctx, dep_link_style)
else:
tdeps, tmetadeps, external_debug_info = {}, {}, []

Expand Down Expand Up @@ -681,7 +682,7 @@ def _native_providers(
# Compute transitive deps. Caller decides whether this is necessary.
def _compute_transitive_deps(
ctx: AnalysisContext,
link_style: LinkStyle.type) -> (dict[Artifact, CrateName.type], dict[Artifact, CrateName.type], list[ArtifactTSet]):
dep_link_style: LinkStyle.type) -> (dict[Artifact, CrateName.type], dict[Artifact, CrateName.type], list[ArtifactTSet]):
transitive_deps = {}
transitive_rmeta_deps = {}
external_debug_info = []
Expand All @@ -691,7 +692,7 @@ def _compute_transitive_deps(
if info == None:
continue

style = style_info(info, link_style)
style = style_info(info, dep_link_style)
transitive_deps[style.rlib] = info.crate
transitive_deps.update(style.transitive_deps)

Expand Down

0 comments on commit 74ab215

Please sign in to comment.