← Back to Pull requests

rust: avoid duplicate native flags from direct build scripts #4276

Open
unknown opened this pull request with 157 lines diff across 1 files
View on GitHub
unknown unknown commented on Sep 24, 2026 08:53 UTC
Author

A package binary can need its build script directly for cfg flags, rustc-env, and generated files in OUT_DIR, even when it also depends on the package library. Cargo applies rustc-link-lib to the library in that situation; the binary links the native dependency through the library.

Record each crate's direct build script in DepInfo and decide native-link flag ownership during the existing dependency collection pass. A matching library dependency suppresses only the duplicate native-link flag file. The binary keeps its compiler flags, environment, generated output, and link search paths. This avoids flattening dependency sets to rediscover the library's build script.

The regression fixtures require build-script output to compile the binary. Five analysis cases cover the library, a binary sharing its script, a standalone binary, a shared script through an intermediate library, and a library with a different script.

Validation: bazel test --config=rustfmt --config=clippy //cargo/tests/cargo_build_script/duplicate_link_flags:all passes all 5 analysis tests and the fixture builds on macOS arm64 with Bazel 9.3.1 at a90209fb, rebased onto upstream main b11ab7e2. Repository pre-commit checks and whitespace checks pass.

Closes #4291.

Diff: 157 lines (+117 / -40) across 1 files Reviewer: jrandolf Review duration: 80223m
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 157 lines diff across 1 files
0.40
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.303
Real PR Conversation Timeline
1 comments
"Review active on #4276"
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: 40.3% (MEDIUM) · Higher = larger blast radius
40.3%
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: 22.3% · Safe to merge
22.3%