Skip to content

Optimize _virtual_includes when paths are only stripped#671

Open
keith wants to merge 3 commits intobazelbuild:mainfrom
keith:ks/optimize-_virtual_includes-when-paths-are-only-stripped
Open

Optimize _virtual_includes when paths are only stripped#671
keith wants to merge 3 commits intobazelbuild:mainfrom
keith:ks/optimize-_virtual_includes-when-paths-are-only-stripped

Conversation

@keith
Copy link
Copy Markdown
Member

@keith keith commented Mar 27, 2026

In this case it's not neccessary to create _virtual_includes, just
setting the correct include path is enough.

This should alleviate Windows problems with too long paths.

This is a reapply of bazelbuild/bazel@a091d90

Fixes bazelbuild/bazel#17591

@keith
Copy link
Copy Markdown
Member Author

keith commented Mar 27, 2026

im resurrecting this because of my comment here bazelbuild/bazel#17591 (comment)

even with sandboxing disabled the .d validation makes sure you only reference files that are actually accessible to you, so im not sure i see an issue with this approach

In this case it's not neccessary to create _virtual_includes, just
setting the correct include path is enough.

This should alleviate Windows problems with too long paths.

This is a reapply of bazelbuild/bazel@a091d90

Fixes bazelbuild/bazel#17591
@keith keith force-pushed the ks/optimize-_virtual_includes-when-paths-are-only-stripped branch from 0d37055 to 413d632 Compare March 27, 2026 21:58
@armandomontanez armandomontanez added P1 I'll work on this now. (Assignee required) category: core rules type: internal cleanup Does not directly address a feature request or a bug report, but improves project hygiene type: feature request Request for new, generally useful functionality that is missing and removed type: internal cleanup Does not directly address a feature request or a bug report, but improves project hygiene labels Apr 14, 2026
@hvadehra hvadehra removed their request for review April 21, 2026 04:54
@lilygorsheneva
Copy link
Copy Markdown
Collaborator

The original bazelbuild/bazel@a091d90 got rolled back due to a change in include order, though whatever context the rollback had is gone now.
bazelbuild/bazel@f14c99e

@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

huh do you know if that case was a non-sandboxed execution? i would assume this would stay in the same order as before, but if it's not sandboxed there could be more there (which should then fail layering_check or dotd validation)

@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

that was part of the original rollback as well, but im still feeling like non-sandboxed executions that also disabled layering_check and dotd validation should be more important that this potential optimization

@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

maybe a nice way to introduce this would be to put it behind a feature that must be enabled by the toolchain. i think then i would add that feature to the default toolchains, off by default, and users could opt in based on this tradeoff. we could also automatically enable it if dotd file validation or layering_check was enabled too

This must be enabled by default to allow skipping this. We auto-enable
it if you are using dotd validation, or layering_check, since those are
better mechanisms for catching these issues, and those work even if
sandboxing is disabled.
@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

a threw in a feature for this, and enabled it by default assuming some of the other features are enabled. the checking for that isn't perfect since rules_cc does a lot of post processing, so maybe we just don't want to do that piece and make users opt in

@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

I decided it was nicer to just not try to be smart about it and entirely leave it up to the user to enable

@keith
Copy link
Copy Markdown
Member Author

keith commented Apr 24, 2026

unrelated test failure, possibly fixed by #663

@lilygorsheneva
Copy link
Copy Markdown
Collaborator

#663 should have gone in a while ago, checking what's going on with copybara for that.

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

Labels

category: core rules P1 I'll work on this now. (Assignee required) type: feature request Request for new, generally useful functionality that is missing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If a C++ directory referenced by include_prefix already exists in the repo, prefer to use that rather than _virtual_includes

3 participants