Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
golang.org/x/tools/go/packages is a new package designed to aid in locating, parsing, and typechecking Go packages. This change updates go-fuzz-build to use it. This effectively resulted in a rewrite of go-fuzz-build/main.go. Some benefits are: * Improved performance. go-fuzz-build appears to be 2x faster on first build, and 4x faster on subsequent builds. This is due to several factors. One big one is the use of cached type information. And there are more performance improvements available; see the TODOs in the code. * More robust. Previously, the list of ignored packages had to be updated every time the standard library changed. Now the ignored packages are computed on the fly. * More user-friendly. You can now invoke go-fuzz-build without a package path; it assumes ".", and relative paths work seamlessly. * Closer to functionality in a module-enabled world. See the TODOs in the code. * Simpler and better documented. Outstanding issue: * cgo code is not instrumented. See the discussion and linked Go toolchain issue in the code. Implementation notes: * go-fuzz-defs has been split into two. The constants, which are shared across go-fuzz, go-fuzz-build, and instrumented code, have been left in place. The types, which were only needed by go-fuzz and go-fuzz-build, have been moved to a new internal package. This allowed us to break the go-fuzz-dep/go-fuzz-defs dependency and std-depends-on-non-std problems in a simpler way: We simply make another copy of go-fuzz-defs. See the comments in the code for details. * There is now a shared AST across the coverage and sonar passes. This works out OK, since the sonar pass used to request coverage first. Now we just have to be careful about the order in which we use and mutate the AST. This is well documented in the code.
- Loading branch information