Skip to content

Pass ctx through C++ action construction#756

Open
dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
dzbarsky:codex/pass-ctx-through-cc-common
Open

Pass ctx through C++ action construction#756
dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
dzbarsky:codex/pass-ctx-through-cc-common

Conversation

@dzbarsky

@dzbarsky dzbarsky commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Change the cc_common.compile, cc_common.link, cc_common.create_linking_context_from_compilation_outputs, and cc_common.register_linkstamp_compile_action boundaries to accept ctx. The boundaries convert an actions value supplied as ctx once for migration compatibility, while compile, link, LTO, and linkstamp implementations receive the rule context directly. Wrapped link_actions remain separate only where shareable or alternate-configuration link artifacts require them.

Rationale

The action-only parameters forced implementation code to recover the rule context repeatedly through actions2ctx_cheat. Passing ctx from rules_cc callers removes those downstream conversions and gives each implementation direct access to the exact rule context fields it uses.

@dzbarsky dzbarsky changed the title [codex] Pass ctx through C++ action construction Pass ctx through C++ action construction Jun 18, 2026
@dzbarsky dzbarsky marked this pull request as ready for review June 18, 2026 23:00
@dzbarsky dzbarsky force-pushed the codex/pass-ctx-through-cc-common branch from 93104bb to 73db1e4 Compare June 18, 2026 23:03
@c-mita

c-mita commented Jul 6, 2026

Copy link
Copy Markdown
Member

I believe the intent was to remove the usage of ctx, for functions receive the things that are actually required, and that this was simply incomplete.

Passing in ctx again would then be a step backwards on that particular road.

@dzbarsky

dzbarsky commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I believe the intent was to remove the usage of ctx, for functions receive the things that are actually required, and that this was simply incomplete.

Passing in ctx again would then be a step backwards on that particular road.

That's fair, but is anyone actually working on that? OTOH landing this PR allows to remove this actions2ctx_cheat method from the Java host side, which gives a tanglible simplification/improvement to the system, and doesn't actually prevent anyone from doing this (very non-trivial) no-ctx cleanup in the future, if there is appetite.

(As an aside, I think it's fine to just wire ctx everywhere, rule_go tries to do a similar thing with wiring a go context everywhere instead of the real ctx, and it also has to resort to go._ctx cheat in some places...)

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.

2 participants