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

proposal: cmd/go: support bracketed expressions for build constraints #36279

Closed
bronze1man opened this issue Dec 25, 2019 · 3 comments
Closed

proposal: cmd/go: support bracketed expressions for build constraints #36279

bronze1man opened this issue Dec 25, 2019 · 3 comments

Comments

@bronze1man
Copy link
Contributor

@bronze1man bronze1man commented Dec 25, 2019

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

$ go version
go version go1.13.1 darwin/amd64

Does this issue reproduce with the latest release?

do not know

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/a/Library/Caches/go-build"
GOENV="/Users/a/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/a/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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=/var/folders/m9/qtbxkp6s3p96fk54rln7qhj80000gp/T/go-build303619785=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

write a build contstraint that is not to // +build linux,!cgo darwin,!cgo

What did you expect to write?

add bracket simple// +build !(linux,!cgo darwin,!cgo)
or
using golang syntax // +build !((linux && (!cgo)) || (darwin && (!cgo)))
or
the boolean formula in https://golang.org/pkg/go/build/#hdr-Build_Constraints // +build (NOT ((linux AND (NOT cgo)) OR (darwin AND (NOT cgo))))

What did you write instead?

// +build !linux cgo
// +build !darwin cgo

I have read the document of https://golang.org/pkg/go/build/#hdr-Build_Constraints
Then I do some boolean algebra from https://en.wikipedia.org/wiki/Boolean_algebra#Laws
Then I get the working code.
I think the golang should support bracket in this place.

@smasher164 smasher164 changed the title build constraint is too difficult to write cmd/go: support bracketed expressions for build constraints Dec 25, 2019
@smasher164 smasher164 changed the title cmd/go: support bracketed expressions for build constraints proposal: cmd/go: support bracketed expressions for build constraints Dec 25, 2019
@gopherbot gopherbot added this to the Proposal milestone Dec 25, 2019
@gopherbot gopherbot added the Proposal label Dec 25, 2019
@smasher164

This comment has been minimized.

Copy link
Member

@smasher164 smasher164 commented Dec 25, 2019

Note that the above build constraint can be further simplified to

// +build !linux,!darwin cgo

which gives you the one-liner you were looking for at the beginning.

@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented Dec 28, 2019

Dup of #25348?

@smasher164

This comment has been minimized.

Copy link
Member

@smasher164 smasher164 commented Dec 28, 2019

@josharian Thanks for spotting it. I'll reopen that issue since it appears there wasn't a consensus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.