Skip to content

Commit 6b8b88f

Browse files
capickettfacebook-github-bot
authored andcommitted
Fixes for advanced_unstable_linking
Summary: A few fixes in order to make advanced_unstable_linking work, a few fixes were needed to handle compiling + linking rust code. 1. Make sure hollow rlibs are always generated for metadata-full emits. 2. Make sure that the targets themselves are added as dependencies when using advanced_unstable_linking. 3. Apply a workaround for version scripts related to latest clang + building dylibs. Reviewed By: diliop Differential Revision: D58169850 fbshipit-source-id: 15b675b3ae35ea0b00c279f47e4c9a701e990eb6
1 parent 5d65670 commit 6b8b88f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

prelude/rust/build.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,16 @@ def rust_compile(
435435

436436
lints, clippy_lints = _lint_flags(compile_ctx)
437437

438+
# If we are building metadata-full for a dylib target, we want the hollow-rlib version of rmeta, not the shared lib version.
439+
if compile_ctx.dep_ctx.advanced_unstable_linking and emit == Emit("metadata-full") and params.crate_type == CrateType("dylib"):
440+
params = BuildParams(
441+
crate_type = CrateType("rlib"),
442+
reloc_model = params.reloc_model,
443+
dep_link_strategy = params.dep_link_strategy,
444+
prefix = "lib",
445+
suffix = ".rlib",
446+
)
447+
438448
common_args = _compute_common_args(
439449
ctx = ctx,
440450
compile_ctx = compile_ctx,

prelude/rust/link_info.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ RustOrNativeDependency = record(
201201
RustDependency = record(
202202
info = field(RustLinkInfo),
203203
label = field(ConfiguredProvidersLabel),
204+
dep = field(Dependency),
204205
name = field([None, str]),
205206
flags = field(list[str]),
206207
proc_macro_marker = field([None, RustProcMacroMarker]),
@@ -343,6 +344,7 @@ def resolve_rust_deps_inner(
343344
rust_deps.append(RustDependency(
344345
info = info,
345346
label = label,
347+
dep = dep.dep,
346348
name = dep.name,
347349
flags = dep.flags,
348350
proc_macro_marker = proc_macro_marker,
@@ -389,9 +391,15 @@ def inherited_exported_link_deps(ctx: AnalysisContext, dep_ctx: DepCollectionCon
389391
deps = {}
390392
for dep in _native_link_dependencies(ctx, dep_ctx):
391393
deps[dep.label] = dep
392-
for info in _rust_non_proc_macro_link_infos(ctx, dep_ctx):
393-
for dep in info.exported_link_deps:
394+
for dep in resolve_rust_deps(ctx, dep_ctx):
395+
if dep.proc_macro_marker != None:
396+
continue
397+
398+
if dep_ctx.advanced_unstable_linking:
399+
deps[dep.label] = dep.dep
400+
for dep in dep.info.exported_link_deps:
394401
deps[dep.label] = dep
402+
395403
return deps.values()
396404

397405
def inherited_rust_cxx_link_group_info(

0 commit comments

Comments
 (0)