Description
This issue could easily have been a comment on #19109, but opening a new issue seemed better for everyone.
Some tools such as go-fuzz do a source-to-source transformation followed by a build. This doesn't play nicely with cmd/go's cache. The problem is where to the translated files. The natural option is to write them all to a tmp dir, but that busts cmd/go's cache, making 'go fuzz' compilation slow. You could instead write them to the user's GOPATH somewhere, but that's mildly hostile, and you end up needing to fight import path rewrites. You could write them into the vendor directory, except that that doesn't work when a package has already been vendored, plus it is definitely hostile (since many people check in their vendor directory).
Note that the one s2s transformation supported in the main Go toolchain, test coverage, gets explicit support from cmd/go, including caching instrumented source code in the pkg dir. (At least if I read the -x
output correctly.)
I don't know what the right interface looks like here. It could be to tell cmd/go "use this transformation tool", but it's tricky to get cmd/go to call the transformation tool with the right set of information (see e.g. #15677). It could be to ask cmd/go for a work dir and then ask it to treat those work dir entries as replacements for the GOPATH/module packages. Or...?