Expose virtual:original header mappings via CcToolchain variables #21157
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.
Whenever
prefix
and/orstrip_include_prefix
is passed intocc_library
rules, Bazel copies the headers into a special "_virtual_includes" directory that allows for such path transformations to occur. Unfortunately, this also has the side-effect of changing how source files are designated within the source binaries: they will refer to the file in the_virtual_includes
sandbox directory instead of the actual files in the build tree.This change allows us to work around this problem by providing a mapping between the "virtual" and where they are in the filesystem as a CcToolchainConfigInfo variable,
virtual_to_original_dirs
, which ends up being a list of<virtual>=<original>
mappings that can be used in rules_cc toolchain features, specifically using -ffile-prefix-map.Questions
<virtual>=<original>
okay, or do we need a more sophisticated lazy expansion involving subvariables like whatlibraries_to_link
has? E.g., do we imagine another compiler command-line flag format that'd requireA:B
instead ofA=B
? (Then again, considering MSVC's ASan is implemented w//fsanitize=address
, maybe they're on theA=B
train now?)Notes
virtual_to_original_headers
.Fixes upstream #11874.