Implement Bazel path mapping for cross-mode cache sharing#3927
Open
rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
Open
Implement Bazel path mapping for cross-mode cache sharing#3927rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
Conversation
Path mapping support for Rustc actions, enabling cross-configuration cache sharing via --experimental_output_paths=strip. Bazel's path mapper requires File objects in Args (not literal path strings) and the supports-path-mapping execution requirement. This PR converts key paths to use File objects: - --out-dir uses map_each = _file_dirname callback - OUT_DIR passed via --set-env (new process wrapper flag) instead of env dict - Linker path uses File object when available - -L stdlib paths use map_each = _file_dirname with uniquify = True - build_script_env values passed through --extra_env args for path mapping Also updates get_linker_and_args() to return the linker File object and rust_std_paths to use File depset with map_each callback.
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.
Summary
supports-path-mappingexecution requirement to Rustc and CargoBuildScriptRun actions--set-envflag to process wrapper for path-mapped environment variablesget_linker_and_args()to return the linker File object for path mappingrust_std_pathsto use File depset withmap_eachcallbackMotivation
Bazel's
--experimental_output_paths=stripenables cross-configuration cache sharing by mapping output paths (e.g.bazel-out/k8-fastbuild/bin/...andbazel-out/k8-opt/bin/...both map tobazel-out/cfg/bin/...). This requires actions to:supports-path-mappingin execution requirementsrules_rust was using
.pathstrings in many places, preventing path mapping from working. This PR converts the key paths to use File objects in Args:--out-dirusesmap_each = _file_dirnamecallbackOUT_DIRis passed via--set-env(a new process wrapper flag) instead of the env dict--codegen=linker=uses the File object when available-L(stdlib paths) usesmap_each = _file_dirnamewithuniquify = True--output-fileuses File objectsBuild script environment variables containing file paths are passed through
--extra_envcommand-line args (which Bazel path-maps) instead of the action env dict (which Bazel does not path-map).Test plan
--experimental_output_paths=stripand verify builds succeed--compilation_mode=fastbuildthen--compilation_mode=optand verify increased cache hit rate