Skip to content

Validate variables_extension passed to the linking APIs - #845

Open
fmeum wants to merge 1 commit into
bazelbuild:mainfrom
fmeum:variables-extension-validation
Open

Validate variables_extension passed to the linking APIs#845
fmeum wants to merge 1 commit into
bazelbuild:mainfrom
fmeum:variables-extension-validation

Conversation

@fmeum

@fmeum fmeum commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

The compile APIs reject variables_extension values that are not strings, string lists or string depsets, but cc_common.link and cc_common.create_linking_context_from_compilation_outputs merged the dict into the link build variables unchecked, which could cause a Bazel crash on an unsupported value type.

@fmeum
fmeum marked this pull request as ready for review August 12, 2026 10:41
@fmeum
fmeum marked this pull request as draft August 12, 2026 10:49
@fmeum
fmeum marked this pull request as ready for review August 12, 2026 10:51
@fmeum
fmeum force-pushed the variables-extension-validation branch from 69f7423 to 95519a3 Compare August 12, 2026 12:38
@fmeum
fmeum marked this pull request as draft August 12, 2026 12:39
@fmeum
fmeum marked this pull request as ready for review August 13, 2026 09:03
lilygorsheneva
lilygorsheneva previously approved these changes Aug 14, 2026
pzembrod
pzembrod previously approved these changes Aug 18, 2026

@pzembrod pzembrod left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have a conflict with head - could you rebase?

The compile APIs reject variables_extension values that are not strings,
string lists or string depsets, but cc_common.link and
cc_common.create_linking_context_from_compilation_outputs merged the
dict into the link build variables unchecked.

Build variable values are stored as opaque objects and only converted
when the toolchain expands them, so an unsupported value is not a
Starlark error: it either stays unnoticed, if no flag group references
the variable, or fails a ClassCastException deep in the command line
construction, far away from the API call that supplied it.

Extract the existing compile-side check into
validate_variables_extension and call it from create_cc_link_actions,
which both public linking entry points funnel through and which also
forwards the variables to the LTO indexing action.
@fmeum
fmeum dismissed stale reviews from pzembrod and lilygorsheneva via 38d8162 August 18, 2026 15:12
@fmeum
fmeum force-pushed the variables-extension-validation branch from 95519a3 to 38d8162 Compare August 18, 2026 15:12
@fmeum

fmeum commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

@pzembrod Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants