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: continue conversion to bug-resistant //go:build constraints #41184

Open
rsc opened this issue Sep 2, 2020 · 34 comments
Open

cmd/go: continue conversion to bug-resistant //go:build constraints #41184

rsc opened this issue Sep 2, 2020 · 34 comments

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Sep 2, 2020

In June I posted a draft design for moving from // +build lines with ad-hoc syntax to //go:build lines with standard Boolean expressions; that doc also has links to a video overview and a prototype implementation.

I propose that we adopt this design, with N = 17 in the Transition section, meaning that the prep work would happen in Go 1.16, the main change would land in Go 1.17, and the transition would be finalized in Go 1.18.

@rsc rsc added this to the Proposal milestone Sep 2, 2020
@rsc rsc added this to Active in Proposals Sep 2, 2020
@rsc rsc changed the title proposal: start conversion to bug-resistant //go:build constraints proposal: cmd/go: start conversion to bug-resistant //go:build constraints Sep 2, 2020
@rsc
Copy link
Contributor Author

@rsc rsc commented Sep 16, 2020

Based on the emoji above and the lack of any objections (along with the overwhelmingly positive Reddit thread), this seems like a likely accept.

@cristaloleg
Copy link

@cristaloleg cristaloleg commented Sep 16, 2020

@rsc rsc moved this from Active to Likely Accept in Proposals Sep 16, 2020
@rsc
Copy link
Contributor Author

@rsc rsc commented Sep 23, 2020

No change in consensus, so accepted.

@rsc rsc moved this from Likely Accept to Accepted in Proposals Sep 23, 2020
@rsc
Copy link
Contributor Author

@rsc rsc commented Sep 23, 2020

Please note that accepting this means that //go:build lines will start working in Go 1.17, not Go 1.16.
Don't everyone rush to put them in.

@rsc rsc removed this from the Proposal milestone Sep 23, 2020
@rsc rsc added this to the Go1.16 milestone Sep 23, 2020
@rsc rsc changed the title proposal: cmd/go: start conversion to bug-resistant //go:build constraints cmd/go: start conversion to bug-resistant //go:build constraints Sep 23, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 12, 2020

Change https://golang.org/cl/240600 mentions this issue: go/build: reject //go:build without // +build

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 12, 2020

Change https://golang.org/cl/240553 mentions this issue: cmd/go: add IgnoredOtherFiles to go list; pass IgnoredFiles to vet

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 12, 2020

Change https://golang.org/cl/240601 mentions this issue: cmd/compile: reject misplaced go:build comments

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 12, 2020

Change https://golang.org/cl/240602 mentions this issue: cmd/asm: reject misplaced go:build comments

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 12, 2020

Change https://golang.org/cl/240554 mentions this issue: cmd/vet: look at ignored files in buildtag check

gopherbot pushed a commit that referenced this issue Oct 12, 2020
Show constraint-ignored non-.go files in go list, as Package.IgnoredOtherFiles
(same as go/build's IgnoredOtherFiles).

Pass full list of ignored files to vet, to help buildtag checker.

For #41184.

Change-Id: I749868de9082cbbc1efbc59370783c8c82fe735f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240553
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Oct 13, 2020
We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.
The standard go command checks only consider the top of the file.
This compiler check, along with a separate go vet check for ignored files,
handles the remainder of the file.

For #41184.

Change-Id: I014006eebfc84ab5943de18bc90449e534f150a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/240601
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Oct 13, 2020
We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

Reject any //go:build comments found after actual assembler code
(include #include etc directives), because the go command itself
doesn't read that far.

For #41184.

Change-Id: Ib460bfd380cce4239993980dd208afd07deff3f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/240602
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Oct 13, 2020
We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

For #41184.

Change-Id: I29b8a789ab1526ab5057f613d5533bd2060ba9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/240600
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 13, 2020

Change https://golang.org/cl/261958 mentions this issue: cmd: go get golang.org/x/tools@d88ec18 && go mod vendor

@gopherbot
Copy link

@gopherbot gopherbot commented May 12, 2021

Change https://golang.org/cl/319389 mentions this issue: all: add //go:build lines to assembly files

@gopherbot
Copy link

@gopherbot gopherbot commented May 12, 2021

Change https://golang.org/cl/319410 mentions this issue: cmd/vendor: update golang.org/x/sys to latest

@gopherbot
Copy link

@gopherbot gopherbot commented May 12, 2021

Change https://golang.org/cl/319469 mentions this issue: all: add //go:build lines to assembly files

gopherbot pushed a commit that referenced this issue May 13, 2021
Don't add them to files in vendor and cmd/vendor though. These will be
pulled in by updating the respective dependencies.

For #41184

Change-Id: Icc57458c9b3033c347124323f33084c85b224c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/319389
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
gopherbot pushed a commit that referenced this issue May 13, 2021
To pull in CL 318212.

For #41184

Change-Id: Iec0d7bee2d3a5874c24a55ec20efd7746bf70902
Reviewed-on: https://go-review.googlesource.com/c/go/+/319410
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit to golang/crypto that referenced this issue May 13, 2021
For golang/go#41184

Change-Id: Ica67fdbf2745ad2eef63dbb9ef70136e9e6fd348
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/319469
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented May 17, 2021

Change https://golang.org/cl/320312 mentions this issue: all: update golang.org/x/sys to latest

gopherbot pushed a commit that referenced this issue May 17, 2021
To pull in CL 318309.

For #41184

Change-Id: I99adb0478e71dbd72e13551a87ed09eae2a0ef2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/320312
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
mikroskeem added a commit to mikroskeem/golang-blake2s that referenced this issue May 20, 2021
For golang/go#41184

Change-Id: Ica67fdbf2745ad2eef63dbb9ef70136e9e6fd348
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/319469
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 1, 2021

Change https://golang.org/cl/323750 mentions this issue: runtime/internal/sys: generate //go:build lines in gengoos.go

gopherbot pushed a commit that referenced this issue Jun 2, 2021
For #41184

Change-Id: If7a1c3980f47bc28d0a13fe497eaba6178c65c91
Reviewed-on: https://go-review.googlesource.com/c/go/+/323750
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 10, 2021

Change https://golang.org/cl/341009 mentions this issue: all: gofmt more (but vendor, testdata, and top-level test directories)

@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Aug 12, 2021

This issue is currently labeled as early-in-cycle for Go 1.18.
That time is now, so this is a friendly ping so the issue is looked at again.

gopherbot pushed a commit that referenced this issue Aug 13, 2021
CL 294430 made packages in std and cmd modules use Go 1.17 gofmt format,
adding //go:build lines. This change applies the same formatting to some
more packages that 'go fmt' missed (e.g., syscall/js, runtime/msan), and
everything else that is easy and safe to modify in bulk.

Consider the top-level test directory, testdata, and vendor directories
out of scope, since there are many files that don't follow strict gofmt
formatting, often for intentional and legitimate reasons (testing gofmt
itself, invalid Go programs that shouldn't crash the compiler, etc.).

That makes it easy and safe to gofmt -w the .go files that are found
with gofmt -l with aforementioned directories filtered out:

	$ gofmt -l . 2>/dev/null | \
		grep -v '^test/' | \
		grep -v '/testdata/' | \
		grep -v '/vendor/' | wc -l
	      51

None of the 51 files are generated. After this change, the same command
prints 0.

For #41184.

Change-Id: Ia96ee2a0f998d6a167d4473bcad17ad09bc1d86e
Reviewed-on: https://go-review.googlesource.com/c/go/+/341009
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
@toothrot
Copy link
Contributor

@toothrot toothrot commented Aug 25, 2021

Reminder that this is an early-in-cycle release-blocker for Go 1.18 and should be addressed soon.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 25, 2021

Change https://golang.org/cl/344955 mentions this issue: all: go fix -fix=buildtag std (except for bootstrap deps)

@heschi
Copy link
Contributor

@heschi heschi commented Sep 29, 2021

ping @rsc -- to me this seems like something we would like to get in well before the freeze?

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Oct 8, 2021

For quick reference, the outstanding CLs for this issue that I'm aware of and their status as of this posting:

  • CL 240611 - includes "For #​41184", has +2, outstanding TryBot failures, one trivial code review comment, needs rebasing
  • CL 344955 - includes "Fixes #​41184", unreviewed, outstanding TryBot failures, needs rebasing

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

Successfully merging a pull request may close this issue.

None yet
8 participants