1
0
mirror of https://github.com/golang/go synced 2024-11-07 06:46:12 -07:00
Commit Graph

40761 Commits

Author SHA1 Message Date
Colin Arnott
e8eb1d8269 math: add MaxUint, MinInt, MaxInt
Since we have int8 to int64 min max and uint8 to uint64 max constants,
we should probably have some for the word size types too. This change
also adds tests to validate the correctness of all integer limit
values.

Fixes #28538

Change-Id: Idd25782e98d16c2abedf39959b7b66e9c4c0c98b
Reviewed-on: https://go-review.googlesource.com/c/go/+/247058
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-05-03 22:44:33 +00:00
Brad Fitzpatrick
ed5ebd32b3 os: update some docs to reference fs.ErrFoo instead of os.ErrFoo
Change-Id: I8b771f407028406a6ec9a1f2500c806054961267
Reviewed-on: https://go-review.googlesource.com/c/go/+/313569
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-03 22:01:04 +00:00
Eddie Scholtz
ddb648fdf6 archive/zip: add File.OpenRaw, Writer.CreateRaw, Writer.Copy
These new methods provide support for cases where performance is a
primary concern. For example, copying files from an existing zip to a
new zip without incurring the decompression and compression overhead.
Using an optimized, external compression method and writing the output
to a zip archive. And compressing file contents in parallel and then
sequentially writing the compressed bytes to a zip archive.

TestWriterCopy is copied verbatim from https://github.com/rsc/zipmerge

Fixes #34974

Change-Id: Iade5bc245ba34cdbb86364bf59f79f38bb9e2eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/312310
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
2021-05-03 21:11:47 +00:00
Dmitri Shuralyov
9f347035ef cmd/api: disallow silent API additions after api/go1.n.txt is created
At this time, the golang.org/s/release process arranges such that the
api/go1.n.txt file is created when a Go 1.N Beta 1 release is being cut.
The API check is currently configured so that tests don't fail visibly
even if api/go1.n.txt becomes a subset of the actual API additions in
the upcoming Go 1.N release as long as 'go version' has "devel" in it.
The first time that 'go version' output drops the "devel" substring
during testing is after the release-branch.go1.N branch is created
as part of the process to cut a Go 1.N Release Candidate 1 release.

The month or so between Beta 1 and RC 1 is well into the freeze and
deliberate API changes are rare and very intentional. There seems to
be agreement that it's healthy to make the API check stricter during
that time period. Doing so will ensure that api/go1.n.txt cannot get
stale after creation without anyone noticing, and may catch CLs that
don't have the intended diff on the API.

This CL changes behavior to be simple and clear: from the moment
an api/go1.n.txt file corresponding to the current Go version in
development is added to the tree, silent API additions stop being
permitted.

This CL also moves the magical "override the value of -allow_new flag
if runtime.Version() contains 'devel' string" behavior from cmd/api
command to the run.go script that calls it, making the CLI of cmd/api
itself less surprising.

Fixes #43956.

Change-Id: I89468207573f7ccdbc9f12625dcdd3ef2bcf8f10
Reviewed-on: https://go-review.googlesource.com/c/go/+/315350
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2021-05-03 19:14:16 +00:00
Bryan C. Mills
791854700d all: update x/net to pull in CL 316129
As a side effect, this also upgrades x/sys to the version currently
required by the latest x/net.

Because x/net is now lazy, it no longer requires checksums for
older-than-selected versions of x/sys, x/term, and x/text.

For #36460
Updates #36905

Change-Id: I242815e202aa7d482fc3983a6717bece10ea8111
Reviewed-on: https://go-review.googlesource.com/c/go/+/316251
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-03 18:23:49 +00:00
Bryan C. Mills
a144af9136 cmd: update x/term to pull in CL 316112
Even though x/term is now lazy, this has no overall effect (yet) on
the contents of cmd/go.sum, because the dependency that would be
pruned out (an old version of x/sys) is still transitively required
through x/crypto, x/sys, and/or x/tools.

Once those modules are also lazy (CL 316109, CL 316111, and CL 315570
respectively), the extra go.sum entries for x/sys will drop out.

For #36460
Updates #36905

Change-Id: I79e715328f7c417ea20ae8fe4f8e0e3eb71ee6c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/316250
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-03 18:23:31 +00:00
David Chase
8a4b7294af cmd/compile: fix possible nil deref added in CL 270943
In the event allocSpan returned a nil, this would crash.
Cleaned up the code and comments slightly, too.

Change-Id: I6231d4b4c14218e6956b4a97a205adc3206f59ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/316429
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-03 18:17:42 +00:00
Cuong Manh Le
7f9febd4a1 cmd/compile: fix linux-amd64-noopt builder
CL 312214 added unsafe.{Add,Slice}, which may appears in expression that
evaluating requires function calls. "mayCall" does not handle that
case, causing linux-amd64-noopt builder failed.

Fixes #45917

Change-Id: I900aefb702122480be621355def3d2c20eadbe70
Reviewed-on: https://go-review.googlesource.com/c/go/+/316170
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: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-05-03 17:49:50 +00:00
David Chase
90ec257735 cmd/compile: make the stack allocator more careful about register args.
Assignment between input parameters causes them to have more than
one "Name", and running this backwards from names to values can end
up confusing (conflating) parameter spill slots.

Around 105a6e9518, this cases a stack overflow running
go test -race encoding/pem
because two slice parameters spill (incorrectly) into the same
stack slots (in the AB?I-defined parameter spill area).

This also tickles a failure in cue, which turned out to be
easier to isolate.

Fixes #45851.
Updates #40724.

Change-Id: I39c56815bd6abb652f1ccbe83c47f4f373a125c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/313212
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>
2021-05-03 17:46:12 +00:00
Roland Shoemaker
b584230889 net/http: use relative path in Location redirect
If the cleaned path did not match the requested path, ServeMux.Handler
would return a Location header which reflected the hostname in the
request, possibly leading to an incorrect redirect. Instead the
Location header should be relative, like the other cases in
ServeMux.Handler.

Change-Id: I2c220d925e708061bc128f0bdc96cca7a32764d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/313950
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-05-03 17:34:10 +00:00
Alessandro Arzilli
169155d61e cmd/compile: preserve argument order in debug_info
When regabi is used sorting by stack offset will not preserve the order
of function arguments. Trust that variables are already ordered
correctly when creating debug_info entries.

Fixes #45720

Change-Id: I1dbdd185975273f70244a23302d34f082347603d
Reviewed-on: https://go-review.googlesource.com/c/go/+/315280
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Jeremy Faller <jeremy@golang.org>
2021-05-03 16:42:22 +00:00
Than McIntosh
472f519fe2 cmd/compile/internal/ssagen: fix misleading comment
Fix up a slightly stale comment in the part of ssa generation that
zeros ambiguously live variables: with the advent of the register ABI,
the ir.Func "Dcl" slice is no longer entirely sorted by frame offset,
although this is still the case for the local vars in Dcl.

Change-Id: I633f43d16f0d4e0b444193a6edb6b2aa1154eea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/316309
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-05-03 16:31:10 +00:00
Dan Scales
d75fbac54d cmd/compile: add edge from lock rank edge from forceGC to traceStackTab
This edge can happen when forcegchelper() calls
goparkunlock(&forcegc.lock, ...) while holding the forcegc lock.
goparkunlock() eventually calls park_m(). In park_m(), traceGoPark()
(which leads to (*traceStackTable).put() and acquires the traceStackTab
lock) can be called before the forcegc lock is released.

Fixes #45774

Change-Id: If0fceab596712eb9ec0b9b47326778bc0ff80913
Reviewed-on: https://go-review.googlesource.com/c/go/+/316029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Carlos Amedee <carlos@golang.org>
2021-05-03 16:25:05 +00:00
Robert Griesemer
7b768d43d0 math: replace float32/64 extrema with exact expressions
Follow-up on https://golang.org/cl/315170.

Updates #44057.
Updates #44058.

Change-Id: I0b071e8ee7a1c97aae2436945cc9583cde3b40b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/315969
Trust: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-05-03 16:23:09 +00:00
Cherry Zhang
be1da9cdee cmd/link: unify text segment write
Currently we have two code paths of writing the text segment. They
are semantically the same:

- if we split text sections, we write all ".text" sections as
  text and the the rest as data.
- if we do not split text sections, we write the first section
  as text and the rest as data. The first section is named ".text"
  and is the only one in this case.

Unify the code.

Change-Id: Ic639eed625615be3c8a8d41f5b47e901552f587a
Reviewed-on: https://go-review.googlesource.com/c/go/+/316049
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-03 16:20:10 +00:00
Cherry Zhang
8327d2150f cmd/compile: add traceback argument info to ABI0 assembly functions
For ABI0 assembly functions that have Go declarations, generate
traceback argument info and attach it to the assembly functions.
So we can print argument in tracebacks if e.g. assembly function
panics.

Only do this for ABI0 functions, as for ABIInternal assembly
functions it is likely that they never spill arguments to memory.

Change-Id: I7e601ccd9aded5e6af2f02be975bf81ff9948f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/315870
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-03 15:53:36 +00:00
Cuong Manh Le
844e1fc6f1 cmd/compile: make typecheckaste correctly report invalid use of "..."
Currently, when "..." argument is passed to non-variadic function, the
compiler may skip that check, but continue checking whether the number
of arguments matches the function signature.

That causes the sanity check which was added in CL 255241 trigger.

Instead, we should report an invalid use of "...", which matches the
behavior of new type checker and go/types.

Fixes #45913

Change-Id: Icbb254052cbcd756bbd41f966c2c8e316c44420f
Reviewed-on: https://go-review.googlesource.com/c/go/+/315796
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>
2021-05-03 15:03:57 +00:00
Lynn Boger
9ed736ac2a cmd/link/internal: fix use of DynlinkingGo with ppc64le trampolines
When creating programs with large text sections on ppc64le,
trampolines are needed for calls that are too far; however
they are not created if the code is generated such that the TOC
register r2 is initialized and maintained in the code because
then the external linker can create the trampolines. Previously
the function DynlinkingGo was used to determine this but in the
case where plugins are used, this could return true even though
r2 is not valid.

To fix this problem I've added a new function r2Valid which returns
true when the build options indicate that the r2 is
initialized and maintained. Because of the ways that
DynlinkingGo is used I wanted to maintain its previous
behavior.

Fixes #45850

Change-Id: I6d902eba6ad41757aa6474948b79acdbd479cb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/315289
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-03 12:26:15 +00:00
Lynn Boger
30674ae91b cmd/dist: disable misc/cgo/testsanitizers on ppc64le
A while back in this release the sanitizer tests were enabled
for ppc64le, where previously they were never run. This
uncovered some errors in these tests on ppc64le. One linker
fix was made but there are still bugs in how tsan is made to
work within the code, especially in how signals are enabled
with cgo.

Some attempts were made to make this work but intermittent
failures continue to happen with the Trybots so I am just
going to disable this test for ppc64le within cmd/dist.

Updates #45040

Change-Id: I5392368ccecd4079ef568d0c645c9f7c94016d99
Reviewed-on: https://go-review.googlesource.com/c/go/+/315430
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
2021-05-03 12:20:09 +00:00
Bryan C. Mills
2c9f5a1da8 cmd: update x/arch to pull in CL 315572
Because x/arch is now lazy, this removes the checksum for rsc.io/pdf
from the go.sum file: the requirements of rsc.io/pdf are known not to
be relevant to any package imported within the cmd packages.

For #36460
Updates #36905

Change-Id: I3abb6a8029cd0c9099b592ccb01ca5606c93edec
Reviewed-on: https://go-review.googlesource.com/c/go/+/316110
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-03 01:35:44 +00:00
Tobias Klauser
abb110bf3d os/user: implement (*User).GroupIds on solaris
It seems like getgrouplist is supported since Solaris 11.3 (released in
2016):
https://docs.oracle.com/cd/E86824_01/html/E54766/getgrouplist-3c.html

Use it to implement (*User).GroupIds on solaris, like on other Unix
platforms.

Unfortunately it looks like getgrouplist was added to illumos only
fairly recently, see
f2c438c505

Thus, don't use it on GOOS=illumos for now.

Updates #14709

Change-Id: Ibfcdbfca6b7d1af96630512d08921e5637ca76d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/315278
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>
2021-05-02 21:27:08 +00:00
Tobias Klauser
b177b2d51e os, syscall: use wait6 to avoid wait/kill race on dragonfly
Follow CL 23967 and CL 24021 which did the same on linux and freebsd,
respectively.

Updates #13987
Updates #16028

Change-Id: Ia30ef8b5cffd8f9eb75c29ee5fe350dac2be6d44
Reviewed-on: https://go-review.googlesource.com/c/go/+/315279
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>
2021-05-02 21:26:09 +00:00
Tobias Klauser
7eb2d30883 syscall: add //go:build lines to files generated with with mksyscall_libc.pl
Change-Id: I2e02d02d9208fc2dbf01c0cea4a67c288967cd07
Reviewed-on: https://go-review.googlesource.com/c/go/+/315276
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>
2021-05-02 21:24:28 +00:00
Kevin Burke
bb09f8a29b time: make time.Time print a valid Go string with %#v
Previously calling fmt.Sprintf("%#v", t) on a time.Time value would
yield a result like:

    time.Time{wall:0x0, ext:63724924180, loc:(*time.Location)(nil)}

which does not compile when embedded in a Go program, and does not
tell you what value is represented at a glance.

This change adds a GoString method that returns much more legible
output:

    "time.Date(2009, time.February, 5, 5, 0, 57, 12345600, time.UTC)"

which gives you more information about the time.Time and also can be
usefully embedded in a Go program without additional work.

Update Quote() to hex escape non-ASCII characters (copying logic
from strconv), which makes it safer to embed them in the output of
GoString().

Fixes #39034.

Change-Id: Ic985bafe4e556f64e82223c643f65143c9a45c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/267017
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-02 20:59:26 +00:00
Matthew Dempsky
fadad851a3 cmd/compile: implement unsafe.Add and unsafe.Slice
Updates #19367.
Updates #40481.

Change-Id: Iabd2afdd0d520e5d68fd9e6dedd013335a4b3886
Reviewed-on: https://go-review.googlesource.com/c/go/+/312214
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-05-02 20:38:13 +00:00
Ian Lance Taylor
0d32d9e8a8 os: document that Windows Symlink to missing target creates file symlink
Fixes #39183

Change-Id: Iec4a5a561182ade57dc7dc24247710005d6b9f21
Reviewed-on: https://go-review.googlesource.com/c/go/+/314275
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-02 18:22:19 +00:00
Vitaly Zdanevich
352a322a83 path/filepath: fix documentation typo (was "each each")
Change-Id: I8dcf6c4489e16e91b8685c31569297cfeb700f9d
GitHub-Last-Rev: f6b40e0298
GitHub-Pull-Request: golang/go#45905
Reviewed-on: https://go-review.googlesource.com/c/go/+/316009
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
Trust: Kevin Burke <kev@inburke.com>
2021-05-02 18:13:38 +00:00
Cherry Zhang
053fe2f485 cmd/link: emit better error for duplicated definition
Print the packages where the duplicates come from.

Change-Id: Ib3dc9aa0a3f5ddd97b03744be6d01d4bfcb33996
Reviewed-on: https://go-review.googlesource.com/c/go/+/315949
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-01 19:17:47 +00:00
Cherry Zhang
d7473fd907 cmd/link: mangle ABI name for shared linkage
Currently, when ABI wrappers are used, we don't use ABI aliases.
One exception is shared linkage. When loading a shared library, if
a symbol has only one ABI, and the name is not mangled, we don't
know what ABI it is, so we have to use ABI aliases.

This CL makes it always mangle ABIInternal function name in shared
linkage, so we know what ABI to choose when loading a shared
library. And we now can fully stop using ABI aliases when ABI
wrappers are used.

Change-Id: Id15d9cd72a59f391f54574710ebba7dc44cb6e23
Reviewed-on: https://go-review.googlesource.com/c/go/+/315869
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-01 19:17:12 +00:00
Rob Findley
879db69ce2 go/types: list errors by default in TestManual
This is a port of CL 315729 to go/types, adjusted for the slightly
different test set-up in go/types.

Added a TODO to reconcile these differences.

Change-Id: I71cae712d8fc23b7311ce35e09168b258e07fa35
Reviewed-on: https://go-review.googlesource.com/c/go/+/315850
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-01 11:43:19 +00:00
Rob Findley
a9db5a7386 go/types: simplify use of TestManual
This is a 1:1 port of CL 315689 to go/types.

Change-Id: If71186b3719be8433c9d21b22c51ffde2cadd55b
Reviewed-on: https://go-review.googlesource.com/c/go/+/315849
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-01 11:42:49 +00:00
Rob Findley
ffc38d8ab4 go/types: slice-to-array-pointer conversion requires go1.17
This is a port of CL 315169 to go/types. It uses a slightly different
mechanism for evaluating the convertibility error message, to be
consistent with operand.assignableTo.

Change-Id: Iea2e2a9fbb4cf17d472b2b7392786118e079528a
Reviewed-on: https://go-review.googlesource.com/c/go/+/315809
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-01 11:42:29 +00:00
Joel Sing
8e91458b19 runtime,syscall: convert syscall on openbsd/386 to libc
Convert the syscall package on openbsd/386 to use libc rather than performing
direct system calls.

Updates #36435

Change-Id: Ifcfbca0e6b933762596a564243caa850dac01442
Reviewed-on: https://go-review.googlesource.com/c/go/+/287654
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30 20:00:36 +00:00
Joel Sing
faff49aae6 runtime: switch runtime to libc for openbsd/386
Use libc rather than performing direct system calls for the runtime on
openbsd/386.

Updates #36435

Change-Id: I0cd65368bc824c81f5f98ea24e4f82db5468b170
Reviewed-on: https://go-review.googlesource.com/c/go/+/287653
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30 19:59:10 +00:00
David Chase
0bbfc5c31e runtime: break up large calls to memclrNoHeapPointers to allow preemption
If something "huge" is allocated, and the zeroing is trivial (no pointers
involved) then zero it by chunks in a loop so that preemption can occur,
not all in a single non-preemptible call.

Benchmarking suggests that 256K is the best chunk size.

Updates #42642.

Change-Id: I94015e467eaa098c59870e479d6d83bc88efbfb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/270943
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-30 19:41:02 +00:00
Than McIntosh
41afd3af42 cmd/compile: fix abbrev selection for output params
In Cl 302071 we changed the compiler to use a different recipe for
selecting the DWARF frame offset for output parameters, to reflect the
fact that registerized output params don't have a stack memory
location on entry to the function. In the process, however, we
switched from using an abbrev pf DW_ABRV_PARAM to an abbrev of
DW_ABRV_AUTO, which means that Delve can't recognize them correctly.
To fix the problem, switch back to picking the correct abbrev entry,
while leaving the new offset recipe intact.

Updates #40724.
Updates #45720.

Change-Id: If721c9255bcd030177806576cde3450563f7a235
Reviewed-on: https://go-review.googlesource.com/c/go/+/315610
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30 19:38:51 +00:00
Than McIntosh
d19eece91f cmd/compile: handle field padding for register-passed structs
When constructing multi-piece DWARF location expressions for
struct-typed parameters using the register ABI, make sure that the
location expressions generated properly reflect padding between
elements (this is required by debuggers). Example:

   type small struct { x uint16 ; y uint8 ; z int32 }
   func ABC(p1 int, p2 small, f1 float32) {
     ...

In the DWARF location expression for "p2" on entry to the routine, we
need pieces for each field, but for debuggers (such as GDB) to work
properly, we also need to describe the padding between elements. Thus
instead of

  <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 <rdi> DW_OP_piece 4

we need to emit

  <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 DW_OP_piece 1 <rdi> DW_OP_piece 4

This patch adds a new helper routine in abiutils to compute the
correct padding amounts for a struct type, a unit test for the helper,
and updates the debug generation code to call the helper and insert
apadding "piece" ops in the right spots.

Updates #40724.
Updates #45720.

Change-Id: Ie208bee25776b9eb70642041869e65e4fa65a005
Reviewed-on: https://go-review.googlesource.com/c/go/+/315071
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-04-30 19:38:25 +00:00
Than McIntosh
162d4f9c92 cmd/compile: regabi support for DWARF location expressions
Revise the code that generates DWARF location expressions for input
parameters to get it to work properly with the new register ABI when
optimization is turned off.

The previously implementation assumed stack locations for all
input+output parameters when -N (disable optimization) was in effect.
In the new implementation, a register-resident input parameter is
given a 2-element location list, the first list element pointing to
the ABI register(s) containing the param, and the second element
pointing to the stack home once it has been spilled.

NB, this change fixes a bunch of the Delve pkg/proc unit tests (maybe
about half of the outstanding failures). Still a good number that need
to be investigated, however.

Updates #40724.
Updates #45720.

Change-Id: I743bbb9af187bcdebeb8e690fdd6db58094ca415
Reviewed-on: https://go-review.googlesource.com/c/go/+/314431
Trust: Than McIntosh <thanm@google.com>
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-04-30 19:38:07 +00:00
Matt Harden
93200b98c7 bufio: mention ErrFinalToken in SplitFunc documentation
It is documented elsewhere in the package documentation but this additional
mention of it will hopefully reduce confusion.

Fixes #44261

Change-Id: I4e9d8f4564ebb7fbe047c92ee2cdffedb39f2a31
GitHub-Last-Rev: 64b6421503
GitHub-Pull-Request: golang/go#45839
Reviewed-on: https://go-review.googlesource.com/c/go/+/314969
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-04-30 19:34:38 +00:00
Joel Sing
c23a32284a runtime: work around vet asmdecl checks for openbsd/386 mstart_stub
Include a NOP with the SP in order to disable/bypass vet asmdecl checks
for runtime.mstart_stub on openbsd/386. Without this we get:

runtime/sys_openbsd_386.s:33:1: [386] mstart_stub: use of 32(SP) points beyond argument frame

Change-Id: I834ae3dbceffcb5776481b076ec2afe3700671cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/315789
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
2021-04-30 19:26:14 +00:00
Than McIntosh
afa58ddf5a cmd/compile: revise block/func end sentinels in debug analysis
The SSA code for debug variable location analysis (for DWARF) has two
special 'sentinel' values that it uses to handshake with the
debugInfo.GetPC callback when capturing the PC values of debug
variable ranges after prog generatoin: "BlockStart" and "BlockEnd".

"BlockStart" has the expected semantics: it means "the PC value of the
first instruction of block B", but "BlockEnd" does not mean "PC value
of the last instruction of block B", but rather it is implemented as
"the PC value of the last instruction of the function". This causes
confusion when reading the code, and seems to to result in implementation
flaws in the past, leading to incorrect ranges in some cases.

To help with this, add a new sentinel "FuncEnd" (which has the "last
inst in the function" semantics) and change the implementation of
"BlockEnd" to actually mean what its name implies (last inst in
block).

Updates #45720.

Change-Id: Ic3497fb60413e898d2bfe27805c3db56483d12a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/314930
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-04-30 18:46:51 +00:00
Cherry Zhang
83ac59b1a5 cmd/internal/archive: make error message contain printable characters only
Use %q instead of %s to print unchecked bytes. Also strip the
"\x00" byte, as "go116ld" reads better than "\x00go116ld".

Change-Id: Id3d1f426ea91d53a55b928dac4a68e1333b80158
Reviewed-on: https://go-review.googlesource.com/c/go/+/315750
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-30 18:43:09 +00:00
Joel Sing
c3b2b04156 runtime: switch openbsd/386 locking to libc
Switch openbsd/386 to locking via libc, rather than performing direct
system calls.

Update #36435

Change-Id: I8198171e21f9acf28846ad723ea9ff48f7c8a69d
Reviewed-on: https://go-review.googlesource.com/c/go/+/287652
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30 18:34:40 +00:00
Joel Sing
4893eee9dc runtime: switch openbsd/386 to pthreads
This switches openbsd/386 to thread creation via pthreads, rather than doing
direct system calls.

Update #36435

Change-Id: I000a815fc0edd0272c3285954f3f007229bc60a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/250577
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30 18:34:10 +00:00
Bryan C. Mills
d9bfda8124 cmd/go: remove the special case for "unsafe" in importFromModules
The comment for this special case claims:
> There's no directory for import "C" or import "unsafe".

However, there clearly is a directory for "unsafe" in
GOROOT/src/unsafe, and all of our integration tests seem to pass
without this special case. As far as I can tell, it's just confusing.

Also note that the internal/goroot package explicitly considers
package "unsafe" to be in the standard library; see CL 137435.

For #36460

Change-Id: Ib857d18f731a7f3c911c1bd116a34e3a9b3d74a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/315412
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:14:41 +00:00
Bryan C. Mills
cbff713e68 cmd/go: add GODEBUG tokens for debugging lazy module loading
GODEBUG=lazymod=log causes the go command to log a stack dump whenever
the full module graph is loaded in a lazy module.

GODEBUG=lazymod=strict does the same, but also terminates the command
with a nonzero exit code.

For #36460

Change-Id: Ia5a4c46069044bcc157b285f64c2392990d70bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/315411
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:14:29 +00:00
Bryan C. Mills
eb71887b99 cmd/go: prune go.mod and go.sum files from vendored dependencies
Fixes #42970

Change-Id: I79246ef7fc16ae05c8e7b40ffb239a61f6415447
Reviewed-on: https://go-review.googlesource.com/c/go/+/315410
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:14:18 +00:00
Bryan C. Mills
c3365ad5f2 cmd/go: annotate versions in vendor/modules.txt
In order to prevent edit wars with previous cmd/go releases,
the new version annotations are only included if the main module
specifies 'go 1.17' or higher.

Fixes #36876

Change-Id: Iba15e47dd1ac2c16d754679a9b501db4069fa250
Reviewed-on: https://go-review.googlesource.com/c/go/+/315409
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:07:24 +00:00
Bryan C. Mills
7dedc237c5 cmd/go: smooth out upgrade paths for lazy loading
This change adds two possible upgrade paths for lazy loading:

1. Run 'go mod tidy -go=1.17'.

2. Starting in a module with no existing 'go' directive,
   run any 'go' command that updates the go.mod file.

In the latter case, commands other than 'go mod tidy'
may leave the go.mod file *very* untidy if it had non-trivial
dependencies. (The 'go' invocation will promote all
implicit eager dependencies to explicit lazy ones,
which preserves the original module graph — most of which is
not actually relevant.)

'go mod tidy -go=1.17' can be used to enable lazy loading without
accidentally downgrading existing transitive dependencies.

'go mod tidy -go=1.16' can be used to disable lazy loading and clear
away redundant roots in a single step (if reducing the go version), or
to prune away dependencies of tests-of-external-tests (if increasing
the go version).

'go mod tidy -go=1.15' can be used to add dependencies of
tests-of-external-tests, although there isn't much point to that.

DO NOT MERGE

This change still needs an explicit test and a release note.

Fixes #45094
For #36460

Change-Id: I68f057e39489dfd6a667cd11dc1e320c1ee1aec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/315210
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:06:46 +00:00
Bryan C. Mills
0e315ad79a cmd/go/internal/modload: avoid loading the full module graph when listing specific modules
For #36460
For #41297
Updates #29666

Change-Id: I5f324c0ef9a164f8043d2188101d141bb5fa7454
Reviewed-on: https://go-review.googlesource.com/c/go/+/309191
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-30 18:06:38 +00:00