cmd/go: many subcommands take nonsensical build flags #62250
Labels
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
What did you expect to see?
I expected the
go
command to reject the-gcflags
flag because it makes no sense for that subcommand.What did you see instead?
It quietly succeeded.
Many of the
go
subcommands are sensitive not just to which packages match the package pattern, but the specific set of source files selected for a build configuration. These callwork.AddBuildFlags
to register the flags that affect source selection, but this function also registers many flags that only affect actual compilation and linking.clean
command is sensitive to source file selection because it finds all source files in the a package that have a correspondingly named binary in the directory (but are not part of package main) to delete the binaries.fix
command useswork.AddBuildFlags
, but appears not to be sensitive to any build flags, because it usespkg.InternalAllGoFiles()
to list source files, which should returns all source files regardless of source file selection.generate
command only searches forgo:generate
directives in matched source files.The full set of build flags makes sense for
build
,install
,get
,run
,test
,vet
, andlist
because they all build source files (vet
andlist -export
both invoke the toolchain to create up-to-date export files).cc @bcmills
The text was updated successfully, but these errors were encountered: