rust: avoid duplicate native flags from direct build scripts #4276
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
jrandolf
A package binary can need its build script directly for cfg flags,
rustc-env, and generated files inOUT_DIR, even when it also depends on the package library. Cargo appliesrustc-link-libto the library in that situation; the binary links the native dependency through the library.Record each crate's direct build script in
DepInfoand 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:allpasses all 5 analysis tests and the fixture builds on macOS arm64 with Bazel 9.3.1 ata90209fb, rebased onto upstream mainb11ab7e2. Repository pre-commit checks and whitespace checks pass.Closes #4291.