Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: invalid values for go build flag -p don't fail builds #46686

Closed
ainar-g opened this issue Jun 10, 2021 · 1 comment
Closed

cmd/go: invalid values for go build flag -p don't fail builds #46686

ainar-g opened this issue Jun 10, 2021 · 1 comment
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Jun 10, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17beta1 linux/amd64

(Same in 1.16.)

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ainar/.cache/go-build"
GOENV="/home/ainar/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ainar/go/pkg/mod"
GONOPROXY="[removed]"
GONOSUMDB="[removed]"
GOOS="linux"
GOPATH="/home/ainar/go"
GOPRIVATE="[removed]"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ainar/go/go1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ainar/go/go1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17beta1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="[removed]"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3876884678=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -p=0

What did you expect to see?

Either a build with the default value of p, as if -p=0 weren't there, or an error message and a non-zero exit code.

What did you see instead?

Binary isn't built, there are no error messages, the exit code is zero.

See the following code:

par := cfg.BuildP
if cfg.BuildN {
par = 1
}
for i := 0; i < par; i++ {

Perhaps there should be either some validation there or something like:

par := cfg.BuildP
if par <= 0 {
        par = runtime.GOMAXPROCS(0)
}
@seankhliao seankhliao added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 10, 2021
@jayconrod jayconrod added this to the Backlog milestone Jul 12, 2021
Yuuki77 added a commit to Yuuki77/go that referenced this issue Jul 23, 2021
Fixed a problem where an error would not occur
when a negative value was specified for the p flag.

Fixes golang#46686
@gopherbot
Copy link

Change https://golang.org/cl/336751 mentions this issue: work/exec throw an error when buildP is negative

Yuuki77 added a commit to Yuuki77/go that referenced this issue Jul 24, 2021
Fixed a problem where an error would not occur
when a negative value was specified for the p flag.

Fixes golang#46686
@golang golang locked and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants