← Back to Pull requests

Stage transitive dynamic libraries into binary runfiles #4310

Open
unknown opened this pull request with 271 lines diff across 3 files
View on GitHub
unknown unknown commented on Sep 30, 2026 14:23 UTC
Author

Fixes #4309.

rustc_compile_action staged a binary's CcInfo dynamic libraries into its runfiles by walking only the rule's own deps and link_deps, while _compute_rpaths walks the full transitive linker-input set. A rust_test(crate = ...) whose crate links a dylib therefore had DT_NEEDED for it and an rpath into the _solib_<cpu> dir, but the file was never shipped, so the test failed at load time on any host without its own copy of the library (sandbox, remote execution, CI):

error while loading shared libraries: libfoo.so: cannot open shared object file: No such file or directory

Change

Iterate dep_info.transitive_noncrates, the same set the rpath computation uses. _is_dylib still keeps only libraries that were linked dynamically, so this adds nothing the binary does not already need, and the existing assertion that a cc_library's implicit .so stays out of runfiles when a static alternative exists still holds.

Targets that reach the dylib through a rust_library in deps are unchanged: establish_cc_info already merges the transitive CcInfo into that library's provider, so the old deps-only walk saw those. link_deps are folded into crate_info.deps and so are covered by the transitive set as well. On Windows the same list feeds the symlink-next-to-binary logic, which now also covers dylibs reached only through crate.

Test

test/unit/check_runfiles gains a cc_import of libbar.so, a rust_library that depends on it, and a rust_test(crate = ...) of that library. A cc_import puts nothing in its own runfiles, so the only way libbar.so reaches the test's runfiles is through the staging in rustc_compile_action. The new check_runfiles_crate_test asserts it is there; it fails on main and passes with this change. foo_crate_test itself also builds and runs. Note that it passes on main too when run locally: glibc resolves $ORIGIN from the binary's real path under bazel-out, so the rpath reaches the build output even though the runfiles tree lacks it. The failure only shows where the execroot is not there, such as remote execution, which is how it went unnoticed.

Diff: 271 lines (+203 / -68) across 3 files Reviewer: krasimirgg Review duration: 87978m
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.46) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 271 lines diff across 3 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
44%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.335
Real PR Conversation Timeline
1 comments
"Review active on #4310"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 44.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 46.5% (MEDIUM) · Higher = larger blast radius
46.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 44.7% · Lower = rushed or shallow review
44.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 25.7% · Safe to merge
25.7%