Skip to content

Make strip_include_prefix apply to textual_hdrs - #26327

Closed
keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/make-strip_include_prefix-apply-to-textual_hdrs
Closed

Make strip_include_prefix apply to textual_hdrs#26327
keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/make-strip_include_prefix-apply-to-textual_hdrs

Conversation

@keith

@keith keith commented Jun 18, 2025

Copy link
Copy Markdown
Member

Fixes #12424

This reverts commit dfc72d0.

@keith
keith requested a review from Copilot June 18, 2025 05:08
@keith

keith commented Jun 18, 2025

Copy link
Copy Markdown
Member Author

new version of #25749

@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jun 18, 2025
@keith

keith commented Jun 18, 2025

Copy link
Copy Markdown
Member Author

@pzembrod ptal for a reland 🙏🏻 hopefully the solution of allowing textual_hdrs to not start with strip_include_prefix is acceptable. I don't see another solution that won't break existing code. I can squash these commits once you review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reverts a previous change to re-enable applying strip_include_prefix to textual_hdrs. It adds a test case and updates the helper logic to handle textual headers similarly to public headers.

  • Add textual_hdrs test files and BUILD rule
  • Extend _compute_public_headers signature and logic for non-module headers
  • Integrate textual_headers into compilation context (include paths, coverage mapping, declared inputs)

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/starlark/tests/.../test_include_textual.cc New C++ test covering strip_include_prefix on textual headers
src/main/starlark/tests/.../not_nested.h New textual header outside nested dir
src/main/starlark/tests/.../nested/lib.h New nested header
src/main/starlark/tests/.../nested/lib.cc Implementation of foo() and its include
src/main/starlark/tests/.../BUILD.builtin_test Add cc_library/cc_test with strip_include_prefix and textual_hdrs
src/main/starlark/builtins_bzl/common/cc/compile/cc_compilation_helper.bzl Update _compute_public_headers signature and logic; wire textual headers into context
Comments suppressed due to low confidence (1)

src/main/starlark/tests/builtins_bzl/cc/basics/test/nested/lib.cc:14

  • When using strip_include_prefix = "nested", the header should be included as #include "lib.h" (or #include "nested/lib.h" before stripping) instead of the full workspace path to match the virtual include layout.
#include "src/main/starlark/tests/builtins_bzl/cc/basics/test/nested/lib.h"

Comment thread src/main/starlark/builtins_bzl/common/cc/compile/cc_compilation_helper.bzl Outdated
@pzembrod pzembrod assigned pzembrod and unassigned pzembrod Jun 18, 2025
@pzembrod
pzembrod self-requested a review June 18, 2025 18:24
@pzembrod

Copy link
Copy Markdown
Contributor

@pzembrod ptal for a reland 🙏🏻 hopefully the solution of allowing textual_hdrs to not start with strip_include_prefix is acceptable. I don't see another solution that won't break existing code. I can squash these commits once you review

Yes, your reasoning makes sense to me. And I'd actually be okay with leaving the two commits; once they get piped through the import and export mechanism, they will turn into one commit in the end anyway, I think.

@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 Jun 18, 2025
@keith

keith commented Jun 18, 2025

Copy link
Copy Markdown
Member Author

ok great, any thoughts on #25749 (comment)

@iancha1992

Copy link
Copy Markdown
Member

@bazel-io fork 8.3.0

@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jun 26, 2025
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Jun 26, 2025
Fixes bazelbuild#12424

This reverts commit 35fb97f.

Closes bazelbuild#26327.

PiperOrigin-RevId: 776069042
Change-Id: Iecbcf1db90dc021582c08753517b2d27dd04eb34
copybara-service Bot pushed a commit that referenced this pull request Jun 30, 2025
*** Reason for rollback ***

Breakages in the nightly: []

*** Original change description ***

Make strip_include_prefix apply to textual_hdrs

Fixes #12424

This reverts commit 35fb97f.

Closes #26327.

PiperOrigin-RevId: 777467219
Change-Id: I7d62a1e73160450c352a49610f073d4376d011fb
@keith keith reopened this Jun 30, 2025
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jun 30, 2025
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 5b24d05 to 6b8ed14 Compare June 30, 2025 16:52
@keith

keith commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

this was reverted again in dfc72d0

@keith

keith commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

I pushed the fix here 6e4698b (#26327) this seems to break internally at google only, so I don't have a good test case for it

@keith
keith requested review from pzembrod and trybka June 30, 2025 17:05

@trybka trybka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Tested with some of the internal breakages I was tracking. The added test failed before these fixes, and passes now.

@iancha1992

Copy link
Copy Markdown
Member

I'll start importing this one.

@keith

keith commented Aug 6, 2025

Copy link
Copy Markdown
Member Author

@iancha1992 hit any blockers?

@iancha1992

iancha1992 commented Aug 7, 2025

Copy link
Copy Markdown
Member

@iancha1992 hit any blockers?

Hi @keith
@trybka is actually importing this one

@trybka

trybka commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

Can you rebase this?

I suspect some changes may need to be made after some changes to introduce _ModuleMapInfo provider.

Currently getting :

...
        File "/virtual_builtins_bzl/common/cc/cc_common.bzl", line 673, column 19, in _compile
        File "/virtual_builtins_bzl/common/cc/compile/compile.bzl", line 245, column 112, in compile
        File "/virtual_builtins_bzl/common/cc/compile/cc_compilation_helper.bzl", line 526, column 38, in _init_cc_compilation_context
        File "/virtual_builtins_bzl/common/cc/compile/cc_compilation_helper.bzl", line 325, column 33, in _create_module_map_action
        File "/virtual_builtins_bzl/common/cc/compile/cc_compilation_helper.bzl", line 189, column 26, in _ModuleMapInfo
Error: got unexpected field 'textual_headers' in call to instantiate provider _ModuleMapInfo

@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 2a85b83 to 8734d18 Compare August 20, 2025 21:23
@keith

keith commented Aug 20, 2025

Copy link
Copy Markdown
Member Author

fixed, looks like it was just that thing needing a new field

Comment thread src/main/starlark/builtins_bzl/common/cc/compile/cc_compilation_helper.bzl Outdated
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 29317f9 to 0bbb178 Compare September 2, 2025 17:37
@keith
keith requested review from pzembrod and trybka October 17, 2025 18:25
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 0bbb178 to 28f3f6d Compare November 25, 2025 04:53
@keith

keith commented Nov 25, 2025

Copy link
Copy Markdown
Member Author

rebased to fix the conflict and add missing rules_cc imports, AFAIUI the tests are only failing because of how this has to mirrored to rules_cc at the same time as the import

@trybka

trybka commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

is there a separate change for rules_cc as well?

@keith

keith commented Nov 25, 2025

Copy link
Copy Markdown
Member Author

No but I can make one if that is easier

@keith

keith commented Nov 27, 2025

Copy link
Copy Markdown
Member Author

created bazelbuild/rules_cc#537 if that's easier

keith added a commit to keith/rules_cc that referenced this pull request Dec 19, 2025
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from b366afe to 63fc241 Compare December 19, 2025 21:08
@trybka

trybka commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

The goal would be to enable it internally soon as well, but to be able to approve this change without blocking on said clean-up.

Are the buildkite failures something we can address in this change, or are they just related to rules_cc version skew?

@keith

keith commented Dec 23, 2025

Copy link
Copy Markdown
Member Author

Yea it's that it's reading the rules_cc one for the tests which isn't sync'd.

copybara-service Bot pushed a commit to bazelbuild/rules_cc that referenced this pull request Jan 21, 2026
Copybara Import from #537

BEGIN_PUBLIC
Make strip_include_prefix apply to textual_hdrs (#537)

Mirror of bazelbuild/bazel#26327

Closes #537
END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=#537 from keith:ks/make-strip_include_prefix-apply-to-textual_hdrs 72348e4
PiperOrigin-RevId: 859124025
Change-Id: I5425de1829802ee03b8d8a793bea83998ae5aebd
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 63fc241 to 2aa0e68 Compare March 3, 2026 19:12
@keith
keith force-pushed the ks/make-strip_include_prefix-apply-to-textual_hdrs branch from 2aa0e68 to 174d23c Compare March 4, 2026 16:15
@keith

keith commented Mar 4, 2026

Copy link
Copy Markdown
Member Author

@trybka want to merge this test case for the changes we landed in rules_cc?

@keith

keith commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

moved this to rules_cc instead bazelbuild/rules_cc#634

@keith keith closed this Mar 13, 2026
@keith
keith deleted the ks/make-strip_include_prefix-apply-to-textual_hdrs branch March 13, 2026 19:04
@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Mar 13, 2026
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.

strip_include_prefix doesn't apply to textual_hdrs

5 participants