← Back to Pull requests

Compose C++ toolchain variables in Starlark #828

Open
dzbarsky opened this pull request with 389 lines diff across 6 files
View on GitHub
dzbarsky dzbarsky commented on Aug 02, 2026 21:31 UTC
Author

Keep C++ compile and ThinLTO build variables in Starlark dictionaries until native action registration requires CcToolchainVariables. This removes all 12 _cc_internal.combine_cc_toolchain_variables calls while preserving parent-variable overrides, duplicate-variable errors, public return types, and action-template behavior.

Validation: 127 C++ common, binary, ThinLTO, and compile-variable analysis tests passed, including new override and duplicate-variable tests. Stable analysis heap increased 0.44% on the 127-test workload.

Diff: 389 lines (+320 / -69) across 6 files Reviewer: lilygorsheneva Review duration: 115102m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.53) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 389 lines diff across 6 files
0.53
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 4 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
89%
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
Diff Size diff_size
0.357
Real PR Conversation Timeline
6 items
lilygorsheneva lilygorsheneva commented on code on Sep 11, 2026 21:52 UTC
Code Review
cc/private/compile/compile_build_variables.bzl:1
@@ -183,7 +183,12 @@ def create_compile_variables(
         additional_build_variables = additional_build_variables,
         user_compile_flags = user_compile_flags or [],
     )
-    return _cc_internal.combine_cc_toolchain_variables(cc_toolchain._build_variables, common_vars, variables)
+    duplicate_variables = sorted([key for key in variables if key in common_vars])

why sorted?

lilygorsheneva lilygorsheneva commented on code on Sep 11, 2026 21:56 UTC
Code Review
cc/private/compile/compile_build_variables.bzl:1
@@ -183,7 +183,12 @@ def create_compile_variables(
         additional_build_variables = additional_build_variables,
         user_compile_flags = user_compile_flags or [],
     )
-    return _cc_internal.combine_cc_toolchain_variables(cc_toolchain._build_variables, common_vars, variables)
+    duplicate_variables = sorted([key for key in variables if key in common_vars])

Why is the duplicate check performed only here in create_compile_variables? Every combine_cc_toolchain_variables checks for duplicates.

lilygorsheneva lilygorsheneva requested changes on Sep 11, 2026 21:56 UTC
Changes Requested Reviewer

Requested changes.

dzbarsky dzbarsky commented on code on Sep 13, 2026 16:08 UTC
Code Review
cc/private/compile/compile_build_variables.bzl:1
@@ -183,7 +183,12 @@ def create_compile_variables(
         additional_build_variables = additional_build_variables,
         user_compile_flags = user_compile_flags or [],
     )
-    return _cc_internal.combine_cc_toolchain_variables(cc_toolchain._build_variables, common_vars, variables)
+    duplicate_variables = sorted([key for key in variables if key in common_vars])

Bazel’s MapVariables stores names in sorted order, so the native duplicate error reports them alphabetically. I kept that ordering for compatibility, moved the sort into the error branch, and documented why. The existing test supplies the names in a different order and checks the alphabetical result.

dzbarsky dzbarsky commented on code on Sep 13, 2026 16:09 UTC
Code Review
cc/private/compile/compile_build_variables.bzl:1
@@ -183,7 +183,12 @@ def create_compile_variables(
         additional_build_variables = additional_build_variables,
         user_compile_flags = user_compile_flags or [],
     )
-    return _cc_internal.combine_cc_toolchain_variables(cc_toolchain._build_variables, common_vars, variables)
+    duplicate_variables = sorted([key for key in variables if key in common_vars])

I rechecked all 12 native calls. The first argument is a parent whose values may be overridden; the duplicate check only compares the remaining arguments with each other. create_compile_variables was the only call with two such arguments. The other 11 had one each. I documented this and added a test showing that compile-action values override the same extension entries that create_compile_variables rejects as duplicates

Assignees
dzbarsky dzbarsky
Labels
risk: low confidence: 89.5% 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: 53% (MEDIUM) · Higher = larger blast radius
53%
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: 89.5% · Lower = rushed or shallow review
89.5%
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: 5.6% · Safe to merge
5.6%