Skip to content

[9.3.0] Allow the include scanner to resolve generated (output-directory) toolchain headers. - #30879

Merged
iancha1992 merged 1 commit into
bazelbuild:release-9.3.0from
keith:ks/9.3.0-allow-the-include-scanner-to-resolve-generated-output-directory-toolchain-headers
Sep 2, 2026
Merged

[9.3.0] Allow the include scanner to resolve generated (output-directory) toolchain headers.#30879
iancha1992 merged 1 commit into
bazelbuild:release-9.3.0from
keith:ks/9.3.0-allow-the-include-scanner-to-resolve-generated-output-directory-toolchain-headers

Conversation

@keith

@keith keith commented Aug 26, 2026

Copy link
Copy Markdown
Member

RELNOTES: The C++ include scanner now properly resolves headers that are generated at build time and included as part of the toolchain.
PiperOrigin-RevId: 970080035
Change-Id: I267fcd63fae455c793a81c4cfde6c9f9c8c9449b
(cherry picked from commit 3a9b19c)

…ory) toolchain headers.

RELNOTES: The C++ include scanner now properly resolves headers that are generated at build time and included as part of the toolchain.
PiperOrigin-RevId: 970080035
Change-Id: I267fcd63fae455c793a81c4cfde6c9f9c8c9449b
(cherry picked from commit 3a9b19c)
@keith
keith requested a review from a team as a code owner August 26, 2026 17:06
keith referenced this pull request Aug 26, 2026
…lchain headers.

Currently, we can't use a generated directory for the C++ toolchain sysroot because the include scanner will discard all of its headers.  The problem is that the scanner only resolves headers located under the output directory when they are a "declared" header (tracked in IncludeScanningHeaderData).

This CL teaches the scanner to treat the toolchain's own compiler_files as resolvable.

  - CppCompileActionBuilder folds ccToolchain.getCompilerFiles() into the action's
    prunable headers when include scanning is on, so the generated headers are
    legitimate discoverable inputs.
  - IncludeScanningHeaderData.Builder.addDeclaredHeaders() registers those
    artifacts as declared headers, but only the generated (non-source) ones;
    source-file sysroots already resolve via source-artifact lookup, so those
    toolchains see no change to their declared-header map.
  - CppCompileAction registers the prunable headers at both header-data build
    sites.

Regression tests added:
  - CppCompileActionTest.discoverInputs_generatedPrunableHeader_isDeclaredAndDiscovered:
    a generated prunable header is registered as a declared header on the action's
    IncludeScanningHeaderData and is discovered (verifies the CppCompileAction wiring).
  - IncludeScannerTest.addDeclaredHeaders_registersOnlyGeneratedHeaders:
    addDeclaredHeaders registers generated headers but skips source headers.
  - IncludeScannerTest.addDeclaredHeaders_generatedHeaderIsResolvedByScanner:
    end-to-end -- the real include scanner prunes an undeclared generated header
    but resolves it once addDeclaredHeaders registers it.

RELNOTES: The C++ include scanner now properly resolves headers that are generated at build time and included as part of the toolchain.
PiperOrigin-RevId: 970080035
Change-Id: I267fcd63fae455c793a81c4cfde6c9f9c8c9449b
@keith
keith requested a review from iancha1992 August 26, 2026 17:07
@google-cla

google-cla Bot commented Aug 26, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Aug 26, 2026
@iancha1992
iancha1992 enabled auto-merge August 26, 2026 17:35
@iancha1992 iancha1992 added this to the 9.3.0 release blockers milestone Aug 26, 2026
@iancha1992
iancha1992 requested review from pzembrod and removed request for iancha1992 August 27, 2026 20:43
@pzembrod pzembrod added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Sep 2, 2026
@iancha1992
iancha1992 added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 2, 2026
@iancha1992 iancha1992 removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Sep 2, 2026
@iancha1992
iancha1992 added this pull request to the merge queue Sep 2, 2026
Merged via the queue into bazelbuild:release-9.3.0 with commit 5377b5e Sep 2, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants