bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.37k stars 651 forks source link

Add support for path mapping #3915

Closed fmeum closed 4 months ago

fmeum commented 5 months ago

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Path mapping improves disk/remote cache hit ratio by automatically removing the configuration-specific path segments (e.g. k8-fastbuild-ST-12345678) from action command lines before staging them for execution.

This commit makes the stdlib, compilepkg (assuming no cgo) and gentestmain actions compatible with path mapping, which is mostly automatic except that GOROOT now needs to be passed in via a flag rather than an environment variable.

See https://www.youtube.com/watch?v=Et1rjb7ixUU for more information on path mapping.

Which issues(s) does this PR fix?

Other notes for review

Can be tested via --experimental_output_paths=strip with Bazel last_green.

fmeum commented 5 months ago

@linzhp @tyler-french Would be interested in hearing your thoughts on this, let me know if you want more context.

fmeum commented 4 months ago

I fixed the merge conflict and added comments to explain why these slightly more convoluted Args constructions are necessary.

fmeum commented 4 months ago

I removed the workaround for the Bazel bug that has now been fixed in last_green and 7.2.0.