Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: -x flag does not produce executable output #9052
dfc@qnap:~$ go build -x os/user WORK=/tmp/go-build337667835 mkdir -p $WORK/os/user/_obj/ mkdir -p $WORK/os/ cd /home/dfc/go/src/os/user CGO_LDFLAGS="-g" "-O2" /home/dfc/go/pkg/tool/linux_arm/cgo -objdir $WORK/os/user/_obj/ -- -I $WORK/os/user/_obj/ lookup_unix.go ** SNIP * The key is the assignment to CGO_LDFLAGS should be ="-g -O2", but is incorrectly '-g", "-O2" which will cause the shell to look for a command, "-O2" $ CGO_LDFLAGS="-g" "-O2" /home/dfc/go/pkg/tool/linux_arm/cgo -objdir $WORK/os/user/_obj/ -- -I $WORK/os/user/_obj/ lookup_unix.go -bash: -O2: command not found
go build -x is not about producing an exact shell script. This kind of bug has been filed before (maybe about dist?), but of course it depends on the quoting rules of the shell and more. I'm not terribly inclined to try to shove those rules into cmd/go. If you want to use %q that's fine, but it still won't be shell input.