-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Introduce shorten_virtual_includes cc toolchain feature #26528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce shorten_virtual_includes cc toolchain feature #26528
Conversation
|
I can confirm with Bazel built at this change and bazelbuild/rules_cc#438, I can build protobuf 31.1 with |
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))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we had the same discussion when reviewing the previous PR internally. We should probably upgrade it, but in another change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #26529 to track it
…n_helper.bzl Co-authored-by: Fabian Meumertzheim <[email protected]>
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
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
|
In the future, please consider documenting features like this here. |
|
Ah, thanks for catching this, will fix it now! |
|
@armandomontanez Doc added at 6ce0384 |
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 <[email protected]>
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.