Skip to content

Register discovered headers for path mapping#29547

Open
layus wants to merge 1 commit into
bazelbuild:masterfrom
layus:fix-discovered-headers-mapping
Open

Register discovered headers for path mapping#29547
layus wants to merge 1 commit into
bazelbuild:masterfrom
layus:fix-discovered-headers-mapping

Conversation

@layus
Copy link
Copy Markdown
Contributor

@layus layus commented May 15, 2026

Description

This PR adds all the discovered headers to the list of artifacts checked for collision by path mapping. This ensure we do not apply path mapping when several of these headers conflict. Otherwise it fails later on, when computing merkle hashes, with a big bad crash.

Motivation

Fixes #29546

Build API Changes

Not really. It may silently disable path mapping on actions that used to support it before.

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

@layus layus requested review from a team and lberki as code owners May 15, 2026 11:58
@layus layus requested review from gregestren and removed request for a team May 15, 2026 11:58
@github-actions github-actions Bot added team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels May 15, 2026
* (headers found via .d file parsing) do have collisions, causing a crash at execution time.
*/
@Override
public NestedSet<Artifact> getAdditionalArtifactsForPathMapping() {
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 method should only be overridden for very special use cases. Allowed derived inputs are relevant for path mapping for any action that discovers inputs, so I think it's cleaner if we just add getAllowedDerivedInputs() at the call site.

* execution time.
*/
@Test
public void cppCompileAction_returnsAdditionalArtifactsForPathMapping() throws Exception {
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 is very "unit test-y" and won't give us much assurance that C++ actions with header collisions build correctly. Could you try to add an integration test to path_mapping_test.sh instead?

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

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path stripping collision with C++ discovered includes

2 participants