Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: provide package path for main packages to cmd/compile #34480
Can cmd/go provide cmd/compile with the full package path to the source package, even when compiling main packages?
When benchmarking cmd/compile changes, it's useful to key stuff by
But this currently doesn't work for main packages, because cmd/go sets
So you end up with a bunch of "BenchmarkFoo:main" lines, which muddle the benchcmp/benchstat output.
I figure two main options:
The compiler uses myimportpath for symbol names and such. But as you said we can rewrite it to "main" as necessary. So either option will work for this use case.
I'm slightly inclined to option 2, for an option specific for benchmarking. User could also overwrite it if necessary.
For option 1, a binary may have multiple packages named
For option 2, would you want to use this for import paths (strings that appear in
That makes sense.
Perhaps cmd/go could provide
Hm, so I want that when I run "go build [pkgs...]", that each individual compile operation has some unique stable identifier so I can correlate benchmarks across builds.
That makes me think we actually want the resolved package path, which then also means we can't always rely on -p even for non-main packages.