1
0
mirror of https://github.com/golang/go synced 2024-09-29 14:24:32 -06:00
Commit Graph

45131 Commits

Author SHA1 Message Date
Ian Lance Taylor
e43ef8dda2 test: add test that fails with gofrontend
The gofrontend code doesn't correctly handle inlining a function that
refers to a constant with methods.

For #35739

Change-Id: I6bd0b5cd4272dbe9969634b4821e668acacfdcf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261662
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-13 22:50:26 +00:00
Matthew Dempsky
85bb4294c0 cmd/compile: fix and improve alias detection
"aliased" is the function responsible for detecting whether we can
turn "a, b = x, y" into just "a = x; b = y", or we need to pre-compute
y and save it in a temporary variable because it might depend on a.

It currently has two issues:

1. It suboptimally treats assignments to blank as writes to heap
   memory. Users generally won't write "_, b = x, y" directly, but it
   comes up a lot in generated code within the compiler.

   This CL changes it to ignore blank assignments.

2. When deciding whether the assigned variable might be referenced by
   pointers, it mistakenly checks Class() and Name.Addrtaken() on "n"
   (the *value* expression being assigned) rather than "a" (the
   destination expression).

   It doesn't appear to result in correctness issues (i.e.,
   incorrectly reporting no aliasing when there is potential aliasing),
   due to all the (overly conservative) rewrite passes before code
   reaches here. But it generates unnecessary code and could have
   correctness issues if we improve those other passes to be more
   aggressive.

   This CL fixes the misuse of "n" for "a" by renaming the variables
   to "r" and "l", respectively, to make their meaning clearer.

Improving these two cases shaves 4.6kB of text from cmd/go, and 93kB
from k8s.io/kubernetes/cmd/kubelet:

       text	   data	    bss	    dec	    hex	filename
    9732136	 290072	 231552	10253760	 9c75c0	go.before
    9727542	 290072	 231552	10249166	 9c63ce	go.after
    97977637	1007051	 301344	99286032	5eafc10	kubelet.before
    97884549	1007051	 301344	99192944	5e99070	kubelet.after

While here, this CL also collapses "memwrite" and "varwrite" into a
single variable. Logically, they're detecting the same thing: are we
assigning to a memory location that a pointer might alias. There's no
need for two variables.

Updates #6853.
Updates #23017.

Change-Id: I5a307b8e20bcd2196e85c55eb025d3f01e303008
Reviewed-on: https://go-review.googlesource.com/c/go/+/261677
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-13 20:44:46 +00:00
Bryan C. Mills
c9211577eb cmd/go/internal/modfetch: remove error return from Lookup
We generally don't care about errors in resolving a repo if the result
we're looking for is already in the module cache. Moreover, we can
avoid some expense in initializing the repo if all of the methods we
plan to call on it hit in the cache — especially when using
GOPROXY=direct.

This also incidentally fixes a possible (but rare) bug in Download:
we had forgotten to reset the downloaded file in case the Zip method
returned an error after writing a nonzero number of bytes.

For #37438

Change-Id: Ib64f10f763f6d1936536b8e1f7d31ed1b463e955
Reviewed-on: https://go-review.googlesource.com/c/go/+/259158
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-13 20:13:34 +00:00
Bryan C. Mills
3a65abfbda cmd/go: adjust ImportMissingError when module lookup is disabled
Previously, ImportMissingError said
"cannot find module providing package …"
even when we didn't even attempt to find such a module.

Now, we write "no module requirement provides package …"
when we did not attempt to identify a suitable module,
and suggest either 'go mod tidy' or 'go get -d' as appropriate.

Fixes #41576

Change-Id: I979bb999da4066828c54d99a310ea66bb31032ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/258298
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-13 20:13:25 +00:00
Bryan Boreham
076a45acd5 fmt: explain how Formatter interface affects verbs and flags
Formatter is mentioned further down, but it's helpful
to add it amongst the verbs and flags.

Background: I spent a while puzzling how "%+v" prints
a stack trace for github.com/pkg/errors when this isn't
documented under 'flags'.

Change-Id: Ic70145902a36780147dedca568b3cf482974fc38
GitHub-Last-Rev: 6571b499f2
GitHub-Pull-Request: golang/go#39860
Reviewed-on: https://go-review.googlesource.com/c/go/+/240000
Reviewed-by: Rob Pike <r@golang.org>
Trust: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2020-10-13 19:15:53 +00:00
Martin Möhrmann
e08059f4fc runtime: remove unused alg constants
CL 191198 removed algarray from the runtime
which used these constants as indices.

Change-Id: Ia669cf410372ef5113dadccd115a39ff8d47e5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/261364
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Martin Möhrmann <moehrmann@google.com>
2020-10-13 18:27:28 +00:00
Martin Möhrmann
6b66b59328 internal/cpu: remove unused arm64 capabilities
Change-Id: I038b0fe165931b8ec3ef59f08dc73c8128d56572
Reviewed-on: https://go-review.googlesource.com/c/go/+/261365
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-13 18:26:39 +00:00
Tao Qingyun
ad53103aef io: add ErrBadWriteCount
Fixes #39978

Change-Id: Ib41459861ba9f7cf0bf1fc95b1479c358c4bdbd8
GitHub-Last-Rev: 19cbb1461c
GitHub-Pull-Request: golang/go#39989
Reviewed-on: https://go-review.googlesource.com/c/go/+/240740
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-10-13 17:36:36 +00:00
Fazlul Shahriar
58e51b1e62 cmd/go/internal/fsys: skip symlink test on Plan 9
Fixes #41950
Fixes #41954

Change-Id: I95d97f076fa928f3638309b78748d7ccc7277b14
Reviewed-on: https://go-review.googlesource.com/c/go/+/261897
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-13 16:27:46 +00:00
Lynn Boger
a15ec3895b cmd/link: update plt size appropriately on ppc64
When attempting to enable internal linking with cgo on ppc64
it was discovered that the plt size was not being updated
after adding entries to it, which resulted in this error:

  .plt: initialize bounds (16 < 24)

This changes fixes that problem.

Updates #21961

Change-Id: Ie17539c329f5a4802e5defd93852dcdde19ded8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261837
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-13 16:26:21 +00:00
Cherry Zhang
575ea5a87a cmd/link: set runtime.text to the address of the first function
In CL 240065 we changed it to set to FlagTextAddr. Normally it
is the address of the first function, except on plan9/amd64
where, as FlagTextAddr is not aligned, it is rounded up. Set it
to the actual text start address.

Fixes #41137.

Change-Id: I1bba67f5eb4e24d9f745a11350fc999ff48bff45
Reviewed-on: https://go-review.googlesource.com/c/go/+/261644
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-13 14:50:14 +00:00
Tobias Klauser
5b509d993d lib/time, time/tzdata: update tz data to 2020b
Set ZFLAGS="-b fat" as the default was changed to '-b slim', see
http://mm.icann.org/pipermail/tz-announce/2020-October/000059.html
This will make sure that backwards-compatibibilty data is still emitted.

Updates #22487

Change-Id: I310a1b3a91e435673d1df41fbf8bb76abce1f94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261363
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>
2020-10-13 08:36:41 +00:00
Tobias Klauser
e69f6e8393 internal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc
Change-Id: I09ba19e19b195e345a0fe29d542e0d86529b0d31
Reviewed-on: https://go-review.googlesource.com/c/go/+/261359
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>
2020-10-13 06:48:02 +00:00
Russ Cox
c8fdfa756e go/build: reject //go:build without // +build
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>
2020-10-13 03:12:23 +00:00
Russ Cox
85f829deb8 cmd/asm: reject misplaced go:build comments
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>
2020-10-13 01:16:56 +00:00
Russ Cox
2c6df2e35d cmd/compile: reject misplaced go:build comments
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>
2020-10-13 01:16:45 +00:00
Russ Cox
ec095f1df0 path: avoid import of strings
Pushing path lower in the hierarchy, to allow path < io/fs < os
in the io/fs prototype. But this change is worth doing even if io/fs
is not accepted.

Change-Id: Id51b3a638167ca005dadfb9b730287e518ec12a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/243904
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>
Reviewed-by: Rob Pike <r@golang.org>
2020-10-13 01:12:09 +00:00
Russ Cox
84f3b33f10 syscall: remove dependency on io
Keep syscall and io separated; neither should depend on the other.

Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112
Reviewed-on: https://go-review.googlesource.com/c/go/+/243902
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>
Reviewed-by: Rob Pike <r@golang.org>
2020-10-13 00:55:35 +00:00
Russ Cox
5ef78c4d84 hash/crc32: fix race between lazy Castagnoli init and Update/Write
The switch on tab is checking tab == castagnoliTable,
but castagnoliTable can change value during a concurrent
call to MakeTable.

Fixes #41911.

Change-Id: I6124dcdbf33e17fe302baa3e1aa03202dec61b4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261639
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>
2020-10-13 00:31:47 +00:00
David Chase
7bda6154ca cmd/compile: add generic optimization patterns for late-expanded calls.
Repeats existing patterns for old calls, so that these will apply
during the optimization phases that precede call expansion.

Change-Id: I1ca0a78c159aa1a51004db217edde4ecc772b646
Reviewed-on: https://go-review.googlesource.com/c/go/+/248190
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-12 22:39:53 +00:00
Cherry Zhang
6c0135d377 cmd/go: don't always link in cgo for PIE
Internal linking for PIE is now supported and enabled by default
on some platforms, for which cgo is not needed. Don't always
bring in cgo.

Change-Id: I043ed436f0e6a3acbcc53ec543f06e193d614b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/261498
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-12 22:37:15 +00:00
Tobias Klauser
027367ac50 time: add ios build constraint to zoneinfo_ios.go
This allows to build the time package using a Go version which doesn't
know GOOS=ios yet.

Change-Id: Ib1b00687432f3309bac8fd8bf5c02b9c62f049a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/261362
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-12 22:34:47 +00:00
Ignacio Hagopian
ca3c0df1f8 net/http/httputil: flush ReverseProxy immediately if Content-Length is -1
Finish up a prior TODO by making ReverseProxy flush immediately
if Content-Length is -1, which is a case that can occur if for
example we have a streamed response, or chunked encoding, or when
the body's length wasn't known.

Fixes #41642

Change-Id: I30babaaf3e14837b99e3ecdc562a0a0e50c579bf
GitHub-Last-Rev: efc019a9fe
GitHub-Pull-Request: golang/go#41858
Reviewed-on: https://go-review.googlesource.com/c/go/+/260637
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-12 22:23:38 +00:00
Cherry Zhang
c321430bdc cmd/link: remove residual darwin/386 code
Change-Id: Iffed1c544d6ebb4ecd8fdb1cc51cf862a9f6d3de
Reviewed-on: https://go-review.googlesource.com/c/go/+/261641
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-12 22:18:00 +00:00
Michael Matloob
15a11cedc6 cmd/go: support walking through overlay directories
Change-Id: I7d9d75aa1dbc34fec5073ca36091c626b9dd4920
Reviewed-on: https://go-review.googlesource.com/c/go/+/261537
Trust: Michael Matloob <matloob@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-12 21:13:04 +00:00
Cherry Zhang
3a34395363 cmd/link: always mark runtime.buildVersion and runtime.modinfo reachable
runtime.buildVersion and runtime.modinfo are referenced in the
.go.buildinfo section, therefore reachable. They should normally
be reachable from the runtime. Just make it explicit, in case.

Change-Id: I60ff3132e0bbb690f4a3cba8bb18735921fbe951
Reviewed-on: https://go-review.googlesource.com/c/go/+/261637
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-12 20:51:51 +00:00
Russ Cox
8994607f82 go/build: clean up ctxt.shouldBuild, tests
Make ctxt.shouldBuild return multiple values
instead of modifying *sawBinaryOnly in place.
Also give it a table-driven test.

Cleanup in preparation for boolean expressions,
but nice even if those don't end up happening.

Change-Id: Ibb78b0080070deafac7299a6de87ab8bebeb702d
Reviewed-on: https://go-review.googlesource.com/c/go/+/240598
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:36 +00:00
Russ Cox
112c4d569e cmd/fix: print warning to stderr, show provenance
This cgo warning shows up when running "go test" in cmd/fix:

	warning: no cgo types: exit status 1

(It may show up at other times too.)

Warnings belong on standard error, and while we're here,
make it say where it came from.

Change-Id: I3eaba592a219cc6abf2d584762374f9d6ec5135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/240597
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:29 +00:00
Russ Cox
2f4368c174 cmd/fix: rename confusing boolean
("truth" says nothing about what is true.
This boolean tracks whether the file was fixed.)

Change-Id: I29bb80c4fad3ca7f2ae96e50e16f6cde484b374f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240556
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:22 +00:00
Russ Cox
09833da6b4 cmd/fix: always format source file before fixing
This makes the changes to the file easier to explain.
Not all the changes may come from the fixers directly,
if the file is not gofmt-ed already.

Change-Id: I81776da446a34a1239a3130317d2aae1437d61a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240555
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:15 +00:00
Russ Cox
7b77ff4c88 cmd/go: add IgnoredOtherFiles to go list; pass IgnoredFiles to vet
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>
2020-10-12 18:31:10 +00:00
Russ Cox
8b289a15e4 cmd/go: remove Package.constraintIgnoredGoFiles
Now all of IgnoredGoFiles is constraint-ignored Go files.

Change-Id: I03001796c290708ab835526250c619dd667a8607
Reviewed-on: https://go-review.googlesource.com/c/go/+/240552
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:02 +00:00
Russ Cox
5acec489a1 go/build: add Package.IgnoredOtherFiles
Just like it is useful to report ignored .go files,
it is also useful to report ignored non-.go files.

Also, remove _* and .* files from IgnoredGoFiles.
The fact that they were there at all was a mistake.
This list is for files being ignored due to build constraints.

Change-Id: Ie08252dde9f56bda08647e7ebeab7906e9271c54
Reviewed-on: https://go-review.googlesource.com/c/go/+/240551
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 18:31:01 +00:00
Robert Griesemer
e0cb80e4d1 cmd/compile/internal/syntax: provide BadExpr where needed, call correct error handler
- For "if" statements without a condition, provide a BadExpr rather than nil
  (clients expect IfStmt.Cond != nil since the parser is taking care of
  reporting a missing condition).

- For 3-index slice expressions, also provide BadExpr where an index is
  required but missing.

- Declare a parser-local error method to hide the embedded error method
  so we don't use it by mistake.

Accidentally found while adjusting prototype parser to work for generics.

Change-Id: Iacc211cc60869be05efe9ae630d65dff1dac00a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/261218
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-12 18:01:22 +00:00
Russ Cox
aeae46a7e5 cmd/go: disable automatic go vet -unreachable during go test of std
go test runs a limited number of vet checks by default.
In the standard library, we run more, both to get additional checking
for the standard library and to get experience with whether to enable
any others by default.

One that experience has shown us should not be enabled by default
is go vet -unreachable. When you are testing, it is common to want to
put an early return or a panic into code to bypass a section of code.
That often causes unreachable code. It's incredibly frustrating if the
result is an "unreachable code" error that keeps your test from completing.

Change-Id: Ib194e87759eb65f5a193d771a9880b38d2fd3ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/240550
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-12 17:39:47 +00:00
Cherry Zhang
1aa43a53be cmd/link: only dynamically export necessary symbols on darwin
Currently on darwin, when a symbol needs to be exported, we
export it both statically and dynamically. The dynamic export is
unnecessary for some symbols. Only export the necessary ones.

For special runtime C symbols (e.g. crosscall2), they used to be
exported dynamically, and we had a special case for pclntab to
not include those symbols (otherwise, when the dynamic linker
dedup them, the pclntab entries end up pointing out of the
module's address space). This CL changes it to not export those
symbols, and remove the special case.

Change-Id: I2ab40630742d48a09b86ee150aa5f1f7002b134d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261497
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-12 17:23:06 +00:00
Russ Cox
373695727b net/http: deflake TestTransportPersistConnLeak on macOS
On a loaded system, sometimes connections don't work out.
Ignore those in TestTransportPersistConnLeak to avoid flakes.

For #33585.

Change-Id: Ic07057532dc0ea5115d6ec49c3c29099a9382295
Reviewed-on: https://go-review.googlesource.com/c/go/+/261538
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Russ Cox <rsc@golang.org>
2020-10-12 17:22:19 +00:00
Russ Cox
9e2acf94fe hash/maphash: adjust package comment
Add note about using per-use seeds.

Delete "collision-resistant but" in:
> The hash functions are collision-resistant but not cryptographically secure.

"Collision-resistant" has a precise cryptographic meaning that is
incompatible with "not cryptographically secure".
All that is really meant by it here here is "it's a good hash function",
which should be established already.

Also delete:
> The hash value of a given byte sequence is consistent within a
> single process, but will be different in different processes.

This was added for its final clause in response to #37040,
but "The hash value of a given byte sequence" is by design not a
concept in this package. Only "... of a given seed and byte sequence".
And seeds cannot be shared between processes, so again by design
you can't even set up the appropriate first half of the sentence
to say the second half.

Change-Id: I2c02bee0e804ef3b120cb4752bf89e60f3f5ff5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/255968
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-12 16:30:45 +00:00
Russ Cox
9384d34c58 text/template: allow newlines inside action delimiters
This allows multiline constructs like:

	{{"hello" |
	  printf}}

Now that unclosed actions can span multiple lines,
track and report the start of the action when reporting errors.

Also clean up a few "unexpected <error message>" to be just "<error message>".

Fixes #29770.

Change-Id: I54c6c016029a8328b7902a4b6d85eab713ec3285
Reviewed-on: https://go-review.googlesource.com/c/go/+/254257
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2020-10-12 16:30:36 +00:00
Russ Cox
39b5276914 net: remove dependency on math/rand
Like we did for sync, let the runtime give net random numbers,
to avoid forcing an import of math/rand for DNS.

Change-Id: Iab3e64121d687d288a3961a8ccbcebe589047253
Reviewed-on: https://go-review.googlesource.com/c/go/+/241258
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>
2020-10-12 16:30:11 +00:00
Alberto Donizetti
349a287646 cmd/compile: use Bool accessor in place of Val.U.(bool)
We have a Bool() accessor for the value in boolean nodes, that we use
elsewhere for n.Val().U.(bool), use it here too. Noticed while reading
the code.

Change-Id: Ie42e014970099a05fe9f02f378af77b63e7e6b13
Reviewed-on: https://go-review.googlesource.com/c/go/+/261360
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-10-12 16:12:25 +00:00
soolaugust
2e7706d1fa ssa: comment Sdom() with the form "Sdom..."
Change-Id: I7ddb3d178e5437a7c3d8e94a089ac7a476a7dc85
GitHub-Last-Rev: bc27289128
GitHub-Pull-Request: golang/go#41925
Reviewed-on: https://go-review.googlesource.com/c/go/+/261437
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-12 15:38:05 +00:00
dqu123
0f53453b32 net/http: deep copy Request.TransferEncoding
The existing implementation in Request.Clone() assigns the wrong
pointer to r2.TransferEncoding.

Fixes #41907

Change-Id: I7f220a41b1b46a55d1a1005e47c6dd69478cb025
Reviewed-on: https://go-review.googlesource.com/c/go/+/261258
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-12 14:44:34 +00:00
gzdaijie
e92ce92662 os: call f.Close before t.Fatal to avoid vet unreachable code warnings
Change-Id: Ic3f756ecf9b4fad8fb8c259e7dad6df894863b0e
GitHub-Last-Rev: 303e524029
GitHub-Pull-Request: golang/go#41900
Reviewed-on: https://go-review.googlesource.com/c/go/+/261217
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-12 09:28:40 +00:00
hk
9449a125e8 cmd/compile/internal/gc: fix wrong function name in the comment
Change-Id: I2fc5cff7495b5db4eb8f286a5335787241f1a850
GitHub-Last-Rev: 1d226f14c8
GitHub-Pull-Request: golang/go#41917
Reviewed-on: https://go-review.googlesource.com/c/go/+/261317
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2020-10-11 17:54:59 +00:00
Meng Zhuo
3036b76df0 cmd/asm: Add SHA3 hardware instructions for ARM64
Armv8.2-SHA introduced four SHA3-related instructions

EOR3 <Vd>.16B, <Vn>.16B, <Vm>.16B, <Va>.16B
RAX1 <Vd>.2D, <Vn>.2D, <Vm>.2D
XAR <Vd>.2D, <Vn>.2D, <Vm>.2D, #<imm6>
BCAX <Vd>.16B, <Vn>.16B, <Vm>.16B, <Va>.16B

We convert them into Go asm style as:

VEOR3 <Va>.B16, <Vm>.B16, <Vn>.B16, <Vd>.B16
VRAX1 <Vm>.D2, <Vn>.D2, <Vd>.D2
VXAR $imm6, <Vm>.D2, <Vn>.D2, <Vd>.D2
VBCAX <Va>.B16, <Vm>.B16, <Vn>.B16, <Vd>.B16

Armv8 Reference Manual:
* EOR3 (Three-way Exclusive OR) on C7.2.42
* RAX1 (Rotate and Exclusive OR) on C7.2.217
* XAR (Exclusive OR and Rotate) on C7.2.401
* BCAX (Bit Clear and Exclusive OR) on C7.2.12

Change-Id: I9a5d1b5ad508ed8fd5289d535906c54d9a63ca5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/180757
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-10 16:06:07 +00:00
Cuong Manh Le
d317ba5d44 cmd/compile: remove NewPtr/NewSlice calls with untyped string
This is follow up of CL 260699, NewPtr/NewSlice should not be called
with untyped string.

No significal change in performance.

name          old time/op       new time/op       delta
Template            167ms ± 5%        168ms ± 6%    ~     (p=0.549 n=9+10)
Unicode            73.9ms ±21%       69.5ms ± 5%    ~     (p=0.182 n=10+9)
GoTypes             611ms ± 4%        603ms ± 2%    ~     (p=0.356 n=10+9)
Compiler            3.07s ± 4%        3.05s ± 2%    ~     (p=0.356 n=9+10)
SSA                 7.61s ± 3%        7.49s ± 1%  -1.67%  (p=0.017 n=10+9)
Flate               114ms ±10%        110ms ±12%    ~     (p=0.165 n=10+10)
GoParser            148ms ±23%        138ms ±13%    ~     (p=0.436 n=9+9)
Reflect             377ms ± 9%        364ms ± 8%    ~     (p=0.105 n=10+10)
Tar                 149ms ±12%        151ms ±12%    ~     (p=0.315 n=10+10)
XML                 201ms ± 3%        206ms ± 8%    ~     (p=0.237 n=8+10)
LinkCompiler        308ms ± 3%        325ms ± 9%  +5.38%  (p=0.017 n=9+10)
[Geo mean]          352ms             348ms       -1.19%

Passes toolstash-check.

Change-Id: I1ca8e9635f1926e53e457bc06648fa08a5473bf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/260859
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-10 00:55:54 +00:00
Jay Conrod
712cba3bf2 cmd/go: ignore retracted versions when converting revisions to versions
When a module author retracts a version, the go command should act as
if it doesn't exist unless it's specifically requested.

When converting a revision to a version, we should ignore tags for
retracted versions. For example, if the tag v1.0.0 is retracted, and
branch B points to the same revision, we should convert B to a
pseudo-version, not v1.0.0. Similarly, if B points to a commit after
v1.0.0, we should not use v1.0.0 as the base; we can use an earlier
non-retracted tag or no base.

Fixes #41700

Change-Id: Ia596b05b0780e5acfe6616a04e94d24bd342fbae
Reviewed-on: https://go-review.googlesource.com/c/go/+/261079
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2020-10-09 21:47:07 +00:00
Michael Pratt
d4a5797b88 cmd/compile: drop SSA atomics TODO
These ops have been used for sync/atomic since golang.org/cl/28076.

Change-Id: Ic1445c073273f6b191b97018e8eb6f7ad9c48922
Reviewed-on: https://go-review.googlesource.com/c/go/+/261077
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-09 18:49:12 +00:00
David Chase
eb67eab861 cmd/compile: late call expansion for rtcall
Change-Id: I0708c9d649d8a579857330b68d9fbcbbeced29e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/248189
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-09 15:13:57 +00:00