Introduce shorten_virtual_includes cc toolchain feature#26528
Closed
meteorcloudy wants to merge 2 commits intobazelbuild:masterfrom
Closed
Introduce shorten_virtual_includes cc toolchain feature#26528meteorcloudy wants to merge 2 commits intobazelbuild:masterfrom
meteorcloudy wants to merge 2 commits intobazelbuild:masterfrom
Conversation
Member
Author
|
I can confirm with Bazel built at this change and bazelbuild/rules_cc#438, I can build protobuf 31.1 with |
fmeum
reviewed
Jul 11, 2025
src/main/starlark/builtins_bzl/common/cc/compile/cc_compilation_helper.bzl
Outdated
Show resolved
Hide resolved
| virtual_include_dir = paths.join(paths.join(package_source_root(label.workspace_name, label.package, is_sibling_repository_layout), _VIRTUAL_INCLUDES_DIR), label.name) | ||
| source_package_path = package_source_root(label.workspace_name, label.package, is_sibling_repository_layout) | ||
| if shorten_virtual_includes: | ||
| virtual_include_dir = paths.join(_VIRTUAL_INCLUDES_DIR, "%x" % hash(paths.join(source_package_path, label.name))) |
Collaborator
There was a problem hiding this comment.
The Starlark hash is not particularly collision resistant, even on non-adversarial inputs. What would happen if this collides?
This could be an argument for introducing a better hash function to Starkark.
Member
Author
There was a problem hiding this comment.
Yeah, we had the same discussion when reviewing the previous PR internally. We should probably upgrade it, but in another change.
…n_helper.bzl Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
This was referenced Jul 11, 2025
fmeum
approved these changes
Jul 11, 2025
copybara-service bot
pushed a commit
to bazelbuild/rules_cc
that referenced
this pull request
Jul 11, 2025
Copybara Import from #438 BEGIN_PUBLIC Support shorten_virtual_includes (#438) Context: bazelbuild/bazel#26528, protocolbuffers/protobuf#20085 Enable `shorten_virtual_includes` for MSVC toolchains to shorten virtual include paths to mitigate long path issue on windows. Closes #438 END_PUBLIC COPYBARA_INTEGRATE_REVIEW=#438 from meteorcloudy:shorten_virtual_includes 5ab4b94 PiperOrigin-RevId: 781977791 Change-Id: Ia683103cb9da2eed8cca165ccf1243f3ee1357da
meteorcloudy
added a commit
to meteorcloudy/bazel
that referenced
this pull request
Jul 11, 2025
Fixes bazelbuild#18683 Related: protocolbuffers/protobuf#20085 This change is a rework of bazelbuild#26005 to enable short virtual includes based on a cc feature, therefore we can limit the change to only MSVC compiler on Windows. RELNOTES: If a cc toolchain feature named `shorten_virtual_includes` is enabled, virtual include header files are linked under `bin/_virtual_includes/<hash of target path>` instead of `bin/<target package path>/_virtual_includes/<target name>`. This shortens the virtual include paths which is critical for mitigating long path issue with MSVC on Windows. Closes bazelbuild#26528. PiperOrigin-RevId: 781975309 Change-Id: Ia573a5f25707ad2462aa3a4459fc66db1779df36
Contributor
|
In the future, please consider documenting features like this here. |
Member
Author
|
Ah, thanks for catching this, will fix it now! |
Member
Author
|
@armandomontanez Doc added at 6ce0384 |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 11, 2025
Fixes #18683 Related: protocolbuffers/protobuf#20085 This change is a rework of #26005 to enable short virtual includes based on a cc feature, therefore we can limit the change to only MSVC compiler on Windows. RELNOTES: If a cc toolchain feature named `shorten_virtual_includes` is enabled, virtual include header files are linked under `bin/_virtual_includes/<hash of target path>` instead of `bin/<target package path>/_virtual_includes/<target name>`. This shortens the virtual include paths which is critical for mitigating long path issue with MSVC on Windows. Closes #26528. PiperOrigin-RevId: 781975309 Change-Id: Ia573a5f25707ad2462aa3a4459fc66db1779df36 --------- Co-authored-by: Googler <pzembrod@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18683
Related: protocolbuffers/protobuf#20085
This change is a rework of #26005 to enable short virtual includes based on a cc feature, therefore we can limit the change to only MSVC compiler on Windows.
RELNOTES: If a cc toolchain feature named
shorten_virtual_includesis enabled, virtual include header files are linked underbin/_virtual_includes/<hash of target path>instead ofbin/<target package path>/_virtual_includes/<target name>. This shortens the virtual include paths which is critical for mitigating long path issue with MSVC on Windows.