Cuong Manh Le [Sat, 3 Jun 2023 01:33:51 +0000 (08:33 +0700)]
cmd/compile: allow ir.OMIN/ir.OMAX in mayCall
CL 496257 adds min/max builtins, which may appear as argument to a
function call, so it will be tested by mayCall. But those ops are not
handled by mayCall, causes the compiler crashes.
Fixes #60582
Change-Id: I729f10bf62b4aad39ffcb1433f576e74d09fdd9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/500575 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Russ Cox [Thu, 1 Jun 2023 18:16:58 +0000 (14:16 -0400)]
cmd/go: maintain go and toolchain lines in go.work
go work init / sync / use need to maintain the invariant that the
go version and toolchain in go.work are up-to-date with respect
to the modules in the workspace.
go get also preserves the invariant when running in a module.
go work use (including with no arguments) reestablishes the invariant.
Replaces the ToolchainTrySwitch func in PackageOpts with a new
gover.Switcher interface implemented by toolchain.Switcher.
Until now, the basic sketch of a particular phase of the go command
has been to call base.Error repeatedly, to report as many problems
as possible, and then call base.ExitIfErrors at strategic places where
continuing in the presence of errors is no longer possible.
A Switcher is similar: you call sw.Error repeatedly and then, when
all the errors from a given phase have been identified, call sw.Switch
to potentially switch toolchains, typically before calling base.ExitIfErrors.
One effect of the regularization of errors reported by the modload.loader
is to add a "go: " prefix to errors showing import stacks. That seems fine.
thepudds [Sat, 3 Jun 2023 00:56:31 +0000 (00:56 +0000)]
cmd/compile/internal/devirtualize: devirtualize methods in other packages if current package has a concrete reference
The new PGO-driven indirect call specialization from CL 492436
in theory should allow for devirtualization on methods
in another package when those methods are directly referenced
in the current package.
However, inline.InlineImpossible was checking for a zero-length
fn.Body and would cause devirtualization to fail
with a debug log message like:
"should not PGO devirtualize (*Speaker1).Speak: no function body"
Previously, the logic in inline.InlineImpossible was only
called on local functions, but with PGO-based devirtualization,
it can now be called on imported functions, where inlinable
imported functions will have a zero-length fn.Body but a
non-nil fn.Inl.
We update inline.InlineImpossible to handle imported functions
by adding a call to typecheck.HaveInlineBody in the check
that was previously failing.
For the test, we need to have a hopefully temporary workaround
of adding explicit references to the callees in another package
for devirtualization to work. CL 497175 or similar should
enable removing this workaround.
Bryan C. Mills [Tue, 30 May 2023 20:43:50 +0000 (16:43 -0400)]
cmd/go: adjust pruning and switch toolchain when needed in 'go mod tidy'
'go mod tidy' may resolve an imported package by added a dependency
that requires a higher 'go' version, which may activate graph pruning
(if the version goes from below go 1.16 to above it), and may even
require switching to a newer toolchain (if the version is not
supported by the current one).
Bryan C. Mills [Thu, 25 May 2023 21:07:26 +0000 (17:07 -0400)]
cmd/go: adjust pruning and switch toolchains if needed when go get changes go version
When we do 'go get', the Go version can change now.
That means we need to do the pruning conversions that
until now have only been necessary in go mod tidy -go=version.
We may also need to upgrade the toolchain in order to load enough o
the module graph to finish the edit, so we should let a TooNewError
bubble up to the caller instead of trying to downgrade the affected
module to avoid the error.
Bryan C. Mills [Fri, 2 Jun 2023 03:42:48 +0000 (23:42 -0400)]
cmd/go: adjust conditions in which toolchain lines are written
'go mod tidy -go=1.20' should tidy as Go 1.20 did, without writing a
toolchain line implicitly. (We don't need it to stabilize toolchain
version switching anyway: because Go 1.20 predates toolchain
switching, any toolchain that supports switching toolchains also
supports Go 1.20 modules directly.)
Dmitri Shuralyov [Fri, 2 Jun 2023 18:33:23 +0000 (14:33 -0400)]
doc/go1.21: document macOS and Windows requirements
For #58645.
Fixes #57125.
Fixes #57003.
Fixes #57004.
Change-Id: I365929ca36aeb32e9ecd19f870e70869933ba6a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/500239 Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Zhiyuan Zheng [Thu, 13 Oct 2022 03:28:10 +0000 (03:28 +0000)]
net: filter disabled interfaces in Windows DNS client
The Go DNS resolver on Windows should filter disabled
interfaces. Otherwise disabled TUN devices, VPNs will be also
considered as valid nameservers and finally timedout.
Fixes #56160
(Originally from Zhiyuan Zheng <zhzy0077@hotmail.com>
in https://go.dev/cl/442375)
Robert Griesemer [Thu, 1 Jun 2023 22:02:54 +0000 (15:02 -0700)]
go/types, types2: report inference instead of assignment failure when types can't match
Interface inference must only be used if we don't require exact
unification, otherwise we may infer types (that are reasonable)
but then fail with an assignment error.
Only checking if exact is set for defined (named) types is not
sufficient, we must also check outside. Oversight.
Fixes #60562.
Change-Id: I208a74bf7ed80bcb976ba9cc172715c83f9e3d0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499996
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Dmitri Shuralyov [Thu, 1 Jun 2023 21:55:06 +0000 (17:55 -0400)]
cmd/api: make check even pickier about api/next/*.txt
As spotted in CL 499981, 3 out of 51 of the api/next/*.txt files
ended up with a blank line at the end. It's possible it would've
been more if human reviewers didn't catch them.
Since there's no formatter for these files, the only way to help
catch things is to make the check pickier (as done in CL 431335).
It can be loosened to let in useful blank lines if needed in the
future.
Change-Id: Iae7ee8e782b32707c576150914539ac4cc0faec4
Reviewed-on: https://go-review.googlesource.com/c/go/+/500115 Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Alan Donovan [Thu, 1 Jun 2023 22:29:57 +0000 (18:29 -0400)]
math/big: rename Int.ToFloat64 to Float64
The "To" prefix was a relic of the first draft
that I failed to make consistent with the unprefixed
name used in the proposal. Fortunately iant spotted
it during the API audit.
Updates #56984
Updates #60560
Change-Id: Ifa6eeddf6dd5f0637c0568e383f9a4bef88b10f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/500116 Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Russ Cox [Thu, 1 Jun 2023 17:25:56 +0000 (13:25 -0400)]
cmd/go: add base.Error and base.Fatal
Many many places in the go command use
base.Errorf("go: %v", err)
or
base.Fatalf("go: %v", err)
Introduce Error(error) and Fatal(error) to do this
and update all call sites (global search and replace).
The new Error gives us the opportunity to unwrap
a multierror and add the go prefix to each line,
which is the motivation for this change.
(We want to start returning a multierror from LoadModFile
and LoadModGraph.)
Austin Clements [Wed, 31 May 2023 16:32:29 +0000 (12:32 -0400)]
cmd/cgo/internal/testerrors: pass if GOEXPERIMENT=cgocheck2 is set
The tests in this package are meant to check cgocheck and cgocheck2
mode, so they're of course sensitive to whether they're set.
Currently, the test will set GOEXPERIMENT=cgocheck2 for tests of
cgocheck2 mode, but won't *unset* cgocheck2 mode if it's already in
the environment for tests that expect it to be off. This means
GOEXPERIMENT=cgocheck2 go test cmd/cgo/internal/testerrors
fails.
Fix this by removing cgocheck2 from GOEXPERIMENT if it's set and the
test case expects it to be unset.
Change-Id: If663e41b791fb89df9940bc5356a566e2a54a77a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499557
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
Christian Banse [Fri, 21 Apr 2023 15:13:17 +0000 (15:13 +0000)]
cmd/link/internal/ld: pass correct offset to codesign.Sign
Previously, codesign.Sign was called with Segtext.Fileoff and
Segtext.Filelen. However, both variables do not contain the
complete __TEXT segment, as it excludes padding and header.
Therefore, we now store a reference to the complete segment
in mstext when it is created and pass its offset (which should
always be 0) and filesize to codesign.Sign.
Ian Lance Taylor [Thu, 1 Jun 2023 16:03:50 +0000 (09:03 -0700)]
doc/go1.21: correct links in go/build note
Change-Id: Ie84cad994c1ffb2c91ce45b2dfb9257e6a7f309b
Reviewed-on: https://go-review.googlesource.com/c/go/+/499957 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Eli Bendersky [Thu, 1 Jun 2023 13:13:46 +0000 (06:13 -0700)]
doc: remove relnote TODO by merging with another section
This change was already described in the linker section.
Change-Id: I3e36dbd66b3b53c5f0063b0d67d8773383f1f77f
Reviewed-on: https://go-review.googlesource.com/c/go/+/499817
Auto-Submit: Eli Bendersky <eliben@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Thu, 1 Jun 2023 16:00:46 +0000 (09:00 -0700)]
doc/go1.21: reformat flag init change note
It reads better as a single paragraph. Also added links.
Change-Id: Id6ba54111b63fbd536423272f674e0eb64b087a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/499956
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Thu, 1 Jun 2023 15:53:54 +0000 (08:53 -0700)]
doc/go1.21: remove some references to reverted CLs
Change-Id: Id9a8871af9cc3ac26be539877f2eea3462db6f3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499955
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Ian Lance Taylor [Thu, 1 Jun 2023 15:49:47 +0000 (08:49 -0700)]
doc/go1.21: fix type in closing tag
Change-Id: Ibcdedb8222a80c0478f783f4a1800e472dbe062c
Reviewed-on: https://go-review.googlesource.com/c/go/+/499935 Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Eli Bendersky [Thu, 1 Jun 2023 12:57:58 +0000 (05:57 -0700)]
doc: add release note for go:wasmimport
Change-Id: I9c6fc4c7e24d0e78086d95dccd61e80bd5ddd856
Reviewed-on: https://go-review.googlesource.com/c/go/+/499815
Auto-Submit: Eli Bendersky <eliben@golang.org> Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Bypass: Eli Bendersky <eliben@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Bryan C. Mills [Fri, 26 May 2023 18:48:22 +0000 (14:48 -0400)]
cmd/go/internal/toolchain: avoid importing modcmd
modcmd is a high-level command, but toolchain is a low-level building
block. A dependency from toolchain on modcmd makes it very difficult
to call from other lower-level packages without creating an import
cycle.
Instead, use modfetch.Download in place of modcmd.DownloadModule.
Eli Bendersky [Thu, 1 Jun 2023 13:11:51 +0000 (06:11 -0700)]
doc: add release note for cgo error on methods on C types
Change-Id: Ibc5f23f37e5bd45034771a0205eadac3072d6870
Reviewed-on: https://go-review.googlesource.com/c/go/+/499816
TryBot-Bypass: Eli Bendersky <eliben@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Eli Bendersky <eliben@google.com>
Michael Pratt [Wed, 31 May 2023 18:45:30 +0000 (14:45 -0400)]
runtime: only increment extraMInUse when actually in use
Currently lockextra always increments extraMInUse, even if the M won't
be used (or doesn't even exist), such as in addExtraM. addExtraM fails
to decrement extraMInUse, so it stays elevated forever.
Fix this bug and simplify the model by moving extraMInUse out of
lockextra to getExtraM, where we know the M will actually be used.
While we're here, remove the nilokay argument from getExtraM, which is
always false.
Fixes #60540.
Change-Id: I7a5d97456b3bc6ea1baeb06b5b2975e3b8dd96a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/499677 Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Russ Cox [Wed, 31 May 2023 20:45:03 +0000 (16:45 -0400)]
cmd/go: delete cmd/go/internal/slices in favor of slices
Some files already use "slices", others use "cmd/go/internal/slices".
(Some files are using more than slices.Clip and must use "slices".)
Use "slices" consistently and delete cmd/go/internal/slices.
Russ Cox [Wed, 31 May 2023 14:24:23 +0000 (10:24 -0400)]
cmd/go: make toolchain less special in MVS
We were using the omission of toolchain from the MVS graph
as a signal that toolchain was not mentioned on the go get line,
but not including it in the graph causes various problems,
and it may be reintroduced to the graph during operations like
pruning conversion, after which its presence is not a good signal
about whether it was mentioned on the go get command line.
Fix all this irregularity by explicitly telling WriteGoMod whether
the command line mentioned toolchain instead.
Ian Lance Taylor [Wed, 31 May 2023 21:23:46 +0000 (14:23 -0700)]
doc/go1.21: remove math.Compare TODOs
Change-Id: I975b437240df03da84f2ce7c47f7a0097a597f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/499638 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Tue, 30 May 2023 22:13:53 +0000 (15:13 -0700)]
doc/go1.21: document type inference changes
For #39661.
For #41176.
For #51593.
For #52397.
For #57192.
For #58645.
For #58650.
For #58671.
For #59338.
For #59750.
For #60353.
Change-Id: Ib731c9f2879beb541f44cb10e40c36a8677d3ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/499282
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Ian Lance Taylor [Tue, 30 May 2023 22:19:44 +0000 (15:19 -0700)]
Revert "math: add Compare and Compare32"
This reverts CL 467515. Now that we have cmp.Compare,
we don't need math.Compare or math.Compare32 after all.
For #56491
Fixes #60519
Change-Id: I8ed33464adfc6d69bd6b328edb26aa2ee3d234d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/499416 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Eli Bendersky <eliben@google.com>
Mark Ryan [Fri, 26 May 2023 08:51:21 +0000 (10:51 +0200)]
runtime: fix alignment code in memmove_riscv64.s
The riscv64 implementation of memmove has two optimizations that are
applied when both source and destination pointers share the same alignment
but that alignment is not 8 bytes. Both optimizations attempt to align the
source and destination pointers to 8 byte boundaries before performing 8 byte
aligned loads and stores. Both optimizations are incorrect. The first
optimization is applied when the destination pointer is smaller than the source
pointer. In this case the code increments both pointers by (pointer & 3) bytes
rather than (8 - (pointer & 7)) bytes. The second optimization is applied
when the destination pointer is larger than the source pointer. In this
case the existing code decrements the pointers by (pointer & 3) bytes instead
of (pointer & 7).
This commit fixes both optimizations avoiding unaligned 8 byte accesses.
As this particular optimization is not covered by any of the existing
benchmarks a new benchmark, BenchmarkMemmoveUnalignedSrcDst,
is provided that exercises both optimizations. Results of the new
benchmark, which were run on a SiFive HiFive Unmatched A00 with 16GB of RAM
running Ubuntu 23.04 are presented below.
Ian Lance Taylor [Wed, 31 May 2023 18:51:28 +0000 (11:51 -0700)]
doc/go1.21: mention upgrade to Unicode 15.0.0
For #48621
For #55079
Change-Id: I279b4fbf07d2fa9de9577559a4e17a57f5692aa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/499618 Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Wed, 31 May 2023 18:47:14 +0000 (11:47 -0700)]
doc/go1.21: document new bytes.Buffer methods
For #53685
Change-Id: I237297d19afeb36ad738074d0c61caa7012f65ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/499617 Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Wed, 31 May 2023 18:41:31 +0000 (11:41 -0700)]
doc/go1.21: mention debug/elf changes
For #55107
For #56887
For #56892
Change-Id: Ibcca34c931ed3595d877c4573bba221dec66bb5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499616 Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Tue, 30 May 2023 22:36:16 +0000 (15:36 -0700)]
doc/go1.21: reading from debug/pe uninitialized section fails
For #47653
Change-Id: Id44c9dba58966f43f188030a53343d890a6ffde7
Reviewed-on: https://go-review.googlesource.com/c/go/+/499419
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Ian Lance Taylor [Tue, 30 May 2023 22:31:39 +0000 (15:31 -0700)]
doc/go1.21: mention that embedded files implement ReadAt
For #57803
Change-Id: I8e33f4dd3fc3071bfbf4d2848faefbe8488f5742
Reviewed-on: https://go-review.googlesource.com/c/go/+/499418
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Tue, 30 May 2023 22:27:29 +0000 (15:27 -0700)]
doc/go1.21: mention flag.BoolFunc
For #53747
Change-Id: Ia5e2f89c1184f2dfd6d672b838b0dbb579e6c954
Reviewed-on: https://go-review.googlesource.com/c/go/+/499417 Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Tue, 30 May 2023 17:42:57 +0000 (10:42 -0700)]
doc/go1.21: document io/fs formatting functions
Also document the new String methods that call them.
For #54451
Change-Id: I5cd7e0fc6c84097bba6d29c4d6012ed3c8bb1e0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499177 Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Tue, 30 May 2023 22:15:43 +0000 (15:15 -0700)]
doc/go1.21: mention directive handling in go/{ast,build}
For #56986
For #59033
Change-Id: I7d03fe34d418aff97a551b236b5d43506e402871
Reviewed-on: https://go-review.googlesource.com/c/go/+/499415
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Michael Anthony Knyszek [Mon, 22 May 2023 21:39:54 +0000 (21:39 +0000)]
runtime: fix race in BenchmarkSetType* benchmarks
Currently the BenchmarkSetType* benchmarks are racy: they call
heapBitsSetType on an allocation that might be in a span in-use for
allocation on another P. Because heap bits are bits but are written
byte-wise non-atomically (because a P assumes it has total ownership of
a span's bits), two threads can race writing the same heap bitmap byte
creating incorrect metadata.
Fix this by forcing every value we're writing heap bits for into a large
object. Large object spans will never be written to concurrently unless
they're freed first.
Also, while we're here, refactor the benchmarks a bit. Use generics to
eliminate the reflect nastiness in gc_test.go, and pass b.ResetTimer
down into the test to get slightly more accurate results.
Fixes #60050.
Change-Id: Ib7d6249b321963367c8c8ca88385386c8ae9af1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/497215 Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Russ Cox [Wed, 31 May 2023 13:57:03 +0000 (09:57 -0400)]
cmd/go: introduce WriteOpts argument for WriteGoMod
This CL is a no-op, just adding the new options and plumbing it through.
'go get' will use this option to let commitRequirements know whether
toolchain was mentioned explicitly on the command line.
Russ Cox [Fri, 26 May 2023 03:28:39 +0000 (23:28 -0400)]
cmd/go: add detection of toolchain switch loops
This happens mainly during testing because the virtual
toolchain switch is not terribly robust, and if you accidentally
try to exec "1.23" instead of "go1.23" it will let you, but it
won't work right.
Of course, although we feel pretty good about the non-test
implementation, perhaps it has a toolchain switch loop lurking too,
or perhaps one will be introduced in the future.
To handle the test bug, and just in case we have a real bug later,
add detection of toolchain switch loops with clear messages.
Also fixes a bug in setting the -lang flag properly when invoking
the Go compiler: this is the first test using 'go 1.21.x' lines
during a build.
Michael Anthony Knyszek [Fri, 26 May 2023 17:56:39 +0000 (17:56 +0000)]
runtime: make TestCPUMetricsSleep even more lenient
This test was introduced as a regression test for #60276. However, it
was quite flaky on a number of different platforms because there are
myriad ways the runtime can eat into time one might expect is completely
idle.
This change re-enables the test, but makes it much more resilient.
Because the issue we're testing for is persistent, we now require 10
consecutive failures to count. Any single success counts as a test
success. This change also makes the test's idle time bound more lenient,
allowing for a little bit of time to be eaten up. The regression we're
testing for results in nearly zero idle time being accounted for.
If this is still not good enough to eliminate flakes, this test should
just be deleted.
For #60276.
Fixes #60376.
Change-Id: Icd81f0c9970821b7f386f6d27c8a566fee4d0ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/498274
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Russ Cox [Tue, 30 May 2023 17:28:56 +0000 (13:28 -0400)]
cmd/go: scan $PATH to find version list in NewerToolchain
NewerToolchain needs a list of candidate toolchains.
Currently it always consults the module version list, using the network.
When GOTOOLCHAIN=path, it should probably not do this,
both because =path implies we don't want to use the network
and because not every released version will be in $PATH.
Instead, scan $PATH to find the available versions.
Than McIntosh [Tue, 30 May 2023 23:16:56 +0000 (19:16 -0400)]
internal/coverage/pods: sort counter files first by origin, then name
This patch fixes a problem with the way pods (clumps of related
coverage meta+counter data files) are collected, which was causing
problems for "go tool covdata subtract".
A subtract operation such as "go tool covdata subtract -i=dir1,dir2
-o=out" works by loading in all the counter data files from "dir1"
before any of the data files from "dir2" are loaded. The sorting
function in the pods code was sorting counter files for a given pod
based purely on name, which meant that differences in process ID
assignment could result in some files from "dir2" being presented
before "dir1". The fix is to change the sorting compare function to
prefer origin directory over filename.
Fixes #60526.
Change-Id: I2226ea675fc99666a9a28e6550d823bcdf2d6977
Reviewed-on: https://go-review.googlesource.com/c/go/+/499317
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Keith Randall [Tue, 30 May 2023 17:54:21 +0000 (10:54 -0700)]
doc: document new panic behavior of flag definition after Set
For #57411
Change-Id: I56c112bb03dde24c2e2643c9b72ce06158a8e717
Reviewed-on: https://go-review.googlesource.com/c/go/+/499278
TryBot-Bypass: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
Keith Randall [Tue, 30 May 2023 18:36:19 +0000 (11:36 -0700)]
doc: document change of cgocheck=2 from debug to experiment
Change-Id: I98bdfe8ab338a5b92c466a5aacfa95266171e5c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/499279 Reviewed-by: Keith Randall <khr@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Keith Randall [Tue, 30 May 2023 20:00:00 +0000 (13:00 -0700)]
doc: mention the new purego implementation of hash/maphash
Change-Id: Ieedddf52ae09cf5a8e9347f0f30aff21e8369787
Reviewed-on: https://go-review.googlesource.com/c/go/+/499281 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>
Robert Griesemer [Fri, 26 May 2023 23:27:28 +0000 (16:27 -0700)]
go/types, types2: use exact unification for component types
This change defines two unification modes used to control unification:
- assign set when unifying types involved in an assignment
- exact if set, types unify if they can be made identical
Currently, unification is inexact: when a defined type is compared
against a type literal, the underlying type of the defined type is
considered. When channel types are compared, the channel direction
is ignored. And when defined types are compared where one (or both)
are interfaces, interface unification is used.
By contrast, exact unification requires types to match exactly:
if they can be unified, the types must be identical (with suitable
type arguments).
Exact unification is required when comparing component types.
For instance, when unifying func(x P) with func(x Q), the two
signatures unify only if P is identical to Q per Go's assignment
rules.
Until now we have ignored exact unification and made due with inexact
unification everywhere, even for component types. In some cases this
led to infinite recursions in the unifier, which we guarded against
with a depth limit (and unification failure).
Go's assignmemt rules allow inexact matching at the top-level but
require exact matching for element types.
This change passes 'assign' to the unifier when unifying parameter
against argument types because those follow assignment rules.
When comparing constraints, inexact unification is used as before.
In 'assign' mode, when comparing element types, the unifyier is
called recursively, this time with the 'exact' mode set, causing
element types to be compared exactly. If unification succeeds for
element types, they are identical (with suitable type arguments).
This change fixes #60460. It also fixes a bug in the test for
issue #60377. We also don't need to rely anymore on the recursion
depth limit (a temporary fix) for #59740. Finally, because we use
exact unification when comparing element types which are channels,
errors caused by assignment failures (due to inexact inference which
succeeded when it shouldn't have) now produce the correct inference
error.
Fixes #60460.
For #60377.
For #59740.
Change-Id: Icb6a9b4dbd34294f99328a06d52135cb499cab85
Reviewed-on: https://go-review.googlesource.com/c/go/+/498895 Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Robert Griesemer [Sat, 27 May 2023 21:31:14 +0000 (14:31 -0700)]
go/types, types2: add unifyMode to unifier, pass it through
Pass a mode parameter through all unifier calls but make no use of it.
When unifying type elements (components of composite types), use emode,
which currently is set to mode.
Preparatory step to fix #60460. Factoring out this mechanical change
will make the actual fix smaller and easier to review and understand.
Because this change doesn't affect the behavior of the unifier, it is
safe.
For #60460.
Change-Id: I5b67499d93025be2128c14cc00bcc3b8cc9f44b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/498955
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Anthony Knyszek [Wed, 24 May 2023 19:53:14 +0000 (19:53 +0000)]
cmd/cgo: rewrite pointer passing rules in terms of pinning
With the introduction of runtime.Pinner, we need to update the cgo
pointer passing rules to accomodate the new functionality. These rule
changes are easier to describe if the rest of the pointer passing rules
are described in terms of pinning as well (Go memory is implicitly
pinned when a pointer to it is passed to a C function, and implicitly
unpinned when that function returns).
For #46787.
Change-Id: I263f03412bc9165f19c9ada72fb005ed0483a8ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/498116 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Russ Cox [Thu, 25 May 2023 15:59:50 +0000 (11:59 -0400)]
cmd/go: lock in new toolchain semantics
The design doc says 'toolchain' lines apply even if the default
toolchain is older than the one specified in the toolchain line.
However, that leads to various confusing behavior and security issues.
Instead, treat toolchain as a min go version that only applies
in the current module (not in dependencies).
As an example of confusing behavior / security issue, if I install
Go 1.30 and then run 'go build' in a module I've checked out,
I expect to use Go 1.30 or newer, not to silently use an older toolchain
that may have security problems fixed in Go 1.30.
Making toolchain a min establishes that guarantee.
Also clean up the tests quite a bit.
Finally drop + from the acceptable version suffixes; we use + for +auto and +path.
Russ Cox [Wed, 24 May 2023 21:37:11 +0000 (17:37 -0400)]
cmd/go: switch to newer toolchain in go get as needed
If we run 'go get go@1.40' or 'go get m@v' where m has a go.mod
that says 'go 1.40', we need to write a new go.mod that says 'go 1.40'.
But we can't be sure we know how to write a Go 1.40-compatible go.mod.
Instead, download the latest point release of Go 1.40 and invoke it to
finish the get command.
Than McIntosh [Tue, 30 May 2023 14:49:11 +0000 (10:49 -0400)]
cmd/compile: remove special treatment for cover vars in initorder
This patch reverts a portion of the changes in CL 443715, specifically
the code in initorder that treats coverage counter variables as special
with respect to init order. The special casing is no longer needed
now after a change to the way coverage instrumention is done (the go and
cover cmds now make sure that coverage variables appear first in
the compilation order).
Updates #56293.
Change-Id: Idf803ff4c1a095e88d455a6adcd63991687eb288
Reviewed-on: https://go-review.googlesource.com/c/go/+/499216
Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Than McIntosh [Tue, 30 May 2023 14:44:45 +0000 (10:44 -0400)]
cmd/{cover,go}: revise fix for pkg init order change with -cover
This patch contains a revised fix for issue #56293, switching to a
scheme in which coverage counter variables and meta-data variables are
written to a separate output file as opposed to being tacked onto the
end of an existing rewritten source file.
The advantage of writing counter vars to a separate file is that the
Go command can then present that file as the first source file to the
compiler when the package is built; this will ensure that counter
variable are treated as lexically "before" any other variable that
might call an instrumented function as part of its initializer.
Updates #56293.
Change-Id: Iccb8a6532b976d36ccbd5a2a339882d1f5d19477
Reviewed-on: https://go-review.googlesource.com/c/go/+/499215 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Ian Lance Taylor [Fri, 26 May 2023 23:22:24 +0000 (16:22 -0700)]
doc/go1.21: mention errors.ErrUnsupported
Also mention errors that implement it.
For #41198
Change-Id: I4f01b112f53b19e2494b701bb012cb2cb52f8962
Reviewed-on: https://go-review.googlesource.com/c/go/+/498775 Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Sat, 27 May 2023 00:07:49 +0000 (17:07 -0700)]
doc/go1.21: mention maps package
For #57436
Change-Id: I99e8b0819c76f1ccf12154a894c9c4c9d68124d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/498602 Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Fri, 26 May 2023 23:52:28 +0000 (16:52 -0700)]
doc/go1.21: mention multipath TCP support
For #56539
For #59166
Change-Id: Ief392464916a1a74a8fcc6c3c7bdb213e8c6ef98
Reviewed-on: https://go-review.googlesource.com/c/go/+/498601
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Bryan C. Mills [Tue, 30 May 2023 14:35:54 +0000 (10:35 -0400)]
cmd/go/internal/modload: break more cycles in readModGraph
Before CL 471595, modload.readModGraph in module with graph pruning
enabled only ever chased down transitive dependencies of unpruned
roots, so pruned dependencies couldn't cause cycles and we didn't
need to dedup them in the loading queue.
However, in 'go get' we are now passing in a set of upgraded modules
to unprune, and those upgraded modules can potentially contain cycles,
leading to an infinite loop during loading.
We have two options for a fix: we could either drop the 'unprune'
check in the enqueue operation (and instead expand the 'unprune'
requirements in a separate pass, as we do in workspace mode), or we
could check for cycles for all modules (not just the ones that are
naturally unpruned). The latter option makes it clearer that this
process must terminate, so we choose that.
(It may be possible to clean up and simplify the workspace-mode case
now that we are passing in the 'unprune' map, but for now we're
looking for a minimal fix for the Go 1.21 release.)
Mark Ryan [Wed, 24 May 2023 11:20:11 +0000 (13:20 +0200)]
internal/bytealg: fix alignment code in compare_riscv64.s
The riscv64 implementation of compare has an optimization that is
applied when both pointers share the same alignment but that alignment
is not 8 bytes. In this case it tries to align both pointers to an 8 byte boundaries,
by individually comparing the first few bytes of each buffer. Unfortunately,
the existing code is incorrect. It adjusts the pointers by the wrong number
of bytes resulting, in most cases, in pointers that are not 8 byte aligned.
This commit fixes the issue by individually comparing the first
(8 - (pointer & 7)) bytes of each buffer rather than the first
(pointer & 7) bytes.
We also remove an unnecessary immediate MOV instruction.
This particular optimization is not covered by any of the existing
benchmarks so a new benchmark, benchmarkCompareBytesBigBothUnaligned,
is provided. The benchmark tests the case where both pointers have
the same alignment but may not be 8 byte aligned. Results of the
new benchmark along with some of the existing benchmarks generated on
a SiFive HiFive Unmatched A00 with 16GB of RAM running Ubuntu 23.04
are presented below.
Change-Id: I0a2d0386d5ca1ffa249682a12ebd1533508e31e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497838 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: M Zhuo <mzh@golangcn.org> Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>
Ian Lance Taylor [Fri, 26 May 2023 21:04:37 +0000 (14:04 -0700)]
doc/go1.21: document clear builtin and init order changes
Also move all the language changes to the same part of the release notes.
For #56351
For #57411
Change-Id: Id1c51b5eb8f7d85e61a2ae44ee7d73bb13036631
Reviewed-on: https://go-review.googlesource.com/c/go/+/498755
TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Michael Pratt [Fri, 26 May 2023 19:49:22 +0000 (15:49 -0400)]
cmd/go: always track visited packages in setPGOProfilePath
Currently we only track visited (copied) packages when a copy is
required. When a copy is not required, we will rewalk each package's
entire dependency graph every time we see it, which is terribly
inefficient.
Pull the visited package check up a level so that we visit packages only
once regardless of how many times they are visited.
Ian Lance Taylor [Fri, 26 May 2023 23:03:32 +0000 (16:03 -0700)]
doc/go1.21: mention os package changes
Also mention WTF-8 support in the syscall package.
For #32558
For #58977
For #59971
Change-Id: Id1627889b5e498add498748d9bfc69fb58030b35
Reviewed-on: https://go-review.googlesource.com/c/go/+/498600 Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Fri, 26 May 2023 21:25:45 +0000 (14:25 -0700)]
doc/go1.21: mention changes to the reflect package
Added Value.Clear, deprecated SliceHeader and StringHeader.
For #55002
For #56906
Change-Id: Ib7497aff830d56fad90c31ec28596e71a448e9ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/498757 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Ian Lance Taylor [Fri, 26 May 2023 21:16:24 +0000 (14:16 -0700)]
doc/go1.21: mention regexp.MarshalText and UnmarshalText
For #46159
Change-Id: Ia9cc0827a89d362532d1a662b791de8eebbfb2fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/498756 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Ian Lance Taylor [Fri, 26 May 2023 20:45:01 +0000 (13:45 -0700)]
doc/go1.21: remove TODOs for x/ repos
Remove x/ repos changes that aren't part of the 1.21 release.
Change-Id: Ia5cbf02ed6c0cc4dc0ff80d68403723b3f9ae0ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/498596
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Dmitri Shuralyov [Fri, 26 May 2023 00:26:00 +0000 (20:26 -0400)]
cmd/internal/testdir: stop manually adding GOROOT/bin to PATH
The go command already places $GOROOT/bin at the beginning of $PATH in
the test's environment as of Go 1.19¹, so there's no need for the test
to do it anymore. Start enjoying yet another benefit of using 'go test'.
¹ See go.dev/issue/57050.
For #56844.
Change-Id: If7732cd8b8979eabf185485d3c73858a4e546d69
Reviewed-on: https://go-review.googlesource.com/c/go/+/498271 Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>