]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
11 months agodoc/go1.21: NOFRAME heuristic changes
qmuntal [Thu, 8 Jun 2023 10:39:05 +0000 (12:39 +0200)]
doc/go1.21: NOFRAME heuristic changes

For #58378

Change-Id: I960b97f33a8bf29d3a9622b58d278544d0970a38
Reviewed-on: https://go-review.googlesource.com/c/go/+/501516
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
11 months agodoc/go1.21: mention NewFile on non-blocking descriptor
Ian Lance Taylor [Thu, 8 Jun 2023 00:11:50 +0000 (17:11 -0700)]
doc/go1.21: mention NewFile on non-blocking descriptor

The returned descriptor now remains in non-blocking mode.

For #58408
For #60211

Change-Id: I88d33c180db642d055b4fed3b03a9afa02e746bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/501699
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agodoc/go1.21: mention html/template.ErrJSTemplate
Ian Lance Taylor [Thu, 8 Jun 2023 00:07:59 +0000 (17:07 -0700)]
doc/go1.21: mention html/template.ErrJSTemplate

For #59584

Change-Id: Iaa3f8b23010ad452c134ac608c63d2a41cc4e409
Reviewed-on: https://go-review.googlesource.com/c/go/+/501698
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: Roland Shoemaker <roland@golang.org>
11 months agodoc/go1.21: mention new cmp package
Ian Lance Taylor [Thu, 8 Jun 2023 00:05:11 +0000 (17:05 -0700)]
doc/go1.21: mention new cmp package

For #59488

Change-Id: I73ee4d1d8b9d8e6f0aad9e3bb98729aaa0f06a47
Reviewed-on: https://go-review.googlesource.com/c/go/+/501697
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@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>

11 months agodoc/go1.21: run relnotes again
Ian Lance Taylor [Wed, 7 Jun 2023 23:57:29 +0000 (16:57 -0700)]
doc/go1.21: run relnotes again

Fill in some of the simpler entries, leave some more TODO entries.

For #58645

Change-Id: I20eb09ba709520ab27301c568d777184a405ffdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/501695
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agocmd/compile: typo
cuiweixie [Thu, 8 Jun 2023 06:43:43 +0000 (14:43 +0800)]
cmd/compile: typo

Change-Id: I8ae86200675dcad0f1d4c9924459d8196da9740f
Reviewed-on: https://go-review.googlesource.com/c/go/+/501755
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

11 months agogo/types: fix method set computation if receiver is a named pointer
Robert Griesemer [Tue, 6 Jun 2023 20:34:39 +0000 (13:34 -0700)]
go/types: fix method set computation if receiver is a named pointer

Per the spec, methods cannot be associated with a named pointer type.
Exit early with an empty method set in this case.

This matches the corresponding check in LookupFieldOrMethod;
the check is not present in (lowercase) lookupFieldOrMethod
because it (the check) doesn't apply to struct fields.

Fixes #60634.

Change-Id: Ica6ca8be6b850ea0da6f0b441fbf5b99cb0b6b17
Reviewed-on: https://go-review.googlesource.com/c/go/+/501299
Reviewed-by: Robert Griesemer <gri@google.com>
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>

11 months agogo/printer: error out of Fprint when it would write a '//line' directive with a multi...
Bryan C. Mills [Mon, 15 May 2023 15:34:46 +0000 (11:34 -0400)]
go/printer: error out of Fprint when it would write a '//line' directive with a multiline file path

Line directives do not provide a way to escape newline characters, so
source file paths containing newlines must not be written in them.

Updates #60167.

Change-Id: I30f8b381cc7d1df6914c27591544edf424a4b634
Reviewed-on: https://go-review.googlesource.com/c/go/+/501578
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agonet/http: close response body in TestRequestBodyLimit
Damien Neil [Wed, 7 Jun 2023 21:13:55 +0000 (14:13 -0700)]
net/http: close response body in TestRequestBodyLimit

Failing to close the response body before returning leaks
the in-progress request past the test lifetime.

Fixes #60264

Change-Id: Ic327d9f8e02e87ed656324aaa042f833d9ea18ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/501309
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
11 months agospec: add temporary note to type inference section
Robert Griesemer [Wed, 7 Jun 2023 18:19:27 +0000 (11:19 -0700)]
spec: add temporary note to type inference section

The section on type inference has not been updated yet for Go 1.21.
Add a temporary note so that readers referred to this section from
the release notes are not confused.

Change-Id: Idc4c74d6d700f891c625289e873ad5aa9c2c5213
Reviewed-on: https://go-review.googlesource.com/c/go/+/501308
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>

11 months agodoc/go1.21: add release notes for parent goroutine in stack traces
Michael Anthony Knyszek [Tue, 6 Jun 2023 21:27:20 +0000 (21:27 +0000)]
doc/go1.21: add release notes for parent goroutine in stack traces

For #38651.

Change-Id: Ie73c1da0629287efda7f0c617e94a7f3a881eee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/501336
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
11 months agointernal/poll: update SOCK_CLOEXEC comment
Ian Lance Taylor [Wed, 7 Jun 2023 18:26:40 +0000 (11:26 -0700)]
internal/poll: update SOCK_CLOEXEC comment

For #45964
For #59359

Change-Id: I9f8f4c17ccd9711f81d152953a5e6aea50c6a28f
Reviewed-on: https://go-review.googlesource.com/c/go/+/501636
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

11 months agoRevert "internal/poll: remove fallback path in accept"
Ian Lance Taylor [Tue, 6 Jun 2023 17:39:21 +0000 (17:39 +0000)]
Revert "internal/poll: remove fallback path in accept"

This reverts CL 422375.

Reason for revert: We still need the fallback path on Solaris.

For #45964
For #59359

Change-Id: Ie598b9ef180708fb157080015aee44f67f6737c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/501275
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

11 months agocmd/cover: error out if a requested source file contains a newline
Bryan C. Mills [Mon, 15 May 2023 15:49:56 +0000 (11:49 -0400)]
cmd/cover: error out if a requested source file contains a newline

cmd/cover uses '//line' directives to map instrumented source files
back to the original source file and line numbers.
Line directives have no way to escape newline characters, so cmd/cover
must not be used with source file paths that contain such characters.

Updates #60167.

Change-Id: I6dc039392d59fc3a5a6121ef6ca97b0ab0da5288
Reviewed-on: https://go-review.googlesource.com/c/go/+/501577
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/cgo: error out if the source path used in line directives would contain a newline
Bryan C. Mills [Mon, 15 May 2023 16:13:25 +0000 (12:13 -0400)]
cmd/cgo: error out if the source path used in line directives would contain a newline

cmd/cgo uses '//line' directives to map generated source
files back to the original source file and line nmubers.

The line directives have no way to escape newline characters,
so cmd/cgo must not be used if the line directives would contain
such characters.

Updates #60167.

Change-Id: I8581cea74d6c08f82e86ed87127e81252e1bf78c
Reviewed-on: https://go-review.googlesource.com/c/go/+/501576
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

11 months agocmd/go: fix TestScript/build_cwd_newline with CGO_ENABLED=0
Bryan C. Mills [Fri, 12 May 2023 18:15:16 +0000 (14:15 -0400)]
cmd/go: fix TestScript/build_cwd_newline with CGO_ENABLED=0

Updates #60167.

Change-Id: I3792682e80a3c48d78a3b9e647cc968a1d5c8f2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/501575
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agocmd/dist: disable PGO for toolchain2 build
Cherry Mui [Tue, 6 Jun 2023 20:53:39 +0000 (16:53 -0400)]
cmd/dist: disable PGO for toolchain2 build

Toolchain2 is only used for building toolchain3. We don't need to
build it with PGO. And building with PGO causes packages to be
built twice (one with PGO for the compiler, one without for other
programs). Disable PGO for toolchain2.

Also, I thought cmd/dist requires toolchain2 and toolchain3
compilers are identical binaries, so they need to be built in the
same way. But it doesn't.

Change-Id: Iaf49816da3dd06db79b48482c0e2435e09b512d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/501335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

11 months agocmd/go: fix Script/build_cwd_newline test
Russ Cox [Wed, 7 Jun 2023 00:47:05 +0000 (20:47 -0400)]
cmd/go: fix Script/build_cwd_newline test

This test is fundamentally about testing cgo.
Skip on nocgo builders.
Fixes CGO_ENABLED=0 go test -run=Script/newline

Change-Id: Ic02349e0acd8cf67508c1bd788333f42b30e84fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/501395
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/go: skip TestScript/gccgo_link_ldflags on aix/ppc64
Cuong Manh Le [Wed, 7 Jun 2023 03:18:06 +0000 (10:18 +0700)]
cmd/go: skip TestScript/gccgo_link_ldflags on aix/ppc64

The gccgo on the builder is not updated to support runtime/cgo

Updates #60306

Change-Id: If0fb1ccdf589cc9741f6a065bacfa4f06e64ec15
Reviewed-on: https://go-review.googlesource.com/c/go/+/501435
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

11 months agogo/types, types2: don't crash when using trace with an invalid argument
Robert Griesemer [Wed, 7 Jun 2023 01:46:29 +0000 (18:46 -0700)]
go/types, types2: don't crash when using trace with an invalid argument

This only affects tests, typically manual tests, but when using trace
we're debugging and we don't want to crash because of trace itself.

No test because a test would cause trace output. Manually verified.

Fixes #60649.

Change-Id: I97abdb94db05774801ec5da56171f4a1aff35615
Reviewed-on: https://go-review.googlesource.com/c/go/+/501415
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

11 months agogo1.21: document net/http.ResponseController.EnableFullDuplex
Damien Neil [Tue, 6 Jun 2023 21:19:45 +0000 (14:19 -0700)]
go1.21: document net/http.ResponseController.EnableFullDuplex

For #15527
For #57786

Change-Id: I75ed0b4bac8e31fac2afef17dad708dc9a3d74e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/501300
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agocontext: add godoc links
Olivier Mengué [Mon, 5 Jun 2023 21:47:17 +0000 (23:47 +0200)]
context: add godoc links

This clarifies the ambiguity of the TODO word as raised in
golang/go#56625.
Also links the introduction text to each function.

Note: linking from Context methods documentation is blocked for now by
golang/go#59728.

Change-Id: Ie6080bd8dee3a652436b0875ddc5f452287c9493
Reviewed-on: https://go-review.googlesource.com/c/go/+/501115
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agoruntime: make GODEBUG=dontfreezetheworld=1 safer
Michael Pratt [Tue, 6 Jun 2023 17:02:29 +0000 (13:02 -0400)]
runtime: make GODEBUG=dontfreezetheworld=1 safer

GODEBUG=dontfreezetheworld=1 allows goroutines to continue execution
during fatal panic. This increases the chance that tracebackothers will
encounter running goroutines that it must skip, which is expected and
fine. However, it also introduces the risk that a goroutine transitions
from stopped to running in the middle of traceback, which is unsafe and
may cause traceback crashes.

Mitigate this by halting M execution if it naturally enters the
scheduler. This ensures that goroutines cannot transition from stopped
to running after freezetheworld. We simply deadlock rather than using
gcstopm to continue keeping disturbance to scheduler state to a minimum.

Change-Id: I9aa8d84abf038ae17142f34f4384e920b1490e81
Reviewed-on: https://go-review.googlesource.com/c/go/+/501255
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
11 months agospec: clarify min/max rules for numeric arguments (exclude NaNs)
Robert Griesemer [Fri, 2 Jun 2023 16:29:07 +0000 (09:29 -0700)]
spec: clarify min/max rules for numeric arguments (exclude NaNs)

Fixes #60570.

Change-Id: I7ef834731ea26ceee5ec9b7438fdd8323aaf828e
Reviewed-on: https://go-review.googlesource.com/c/go/+/500416
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

11 months agocmd/go: disallow package directories containing newlines
Bryan C. Mills [Fri, 12 May 2023 18:15:16 +0000 (14:15 -0400)]
cmd/go: disallow package directories containing newlines

Directory or file paths containing newlines may cause tools (such as
cmd/cgo) that emit "//line" or "#line" -directives to write part of
the path into non-comment lines in generated source code. If those
lines contain valid Go code, it may be injected into the resulting
binary.

(Note that Go import paths and file paths within module zip files
already could not contain newlines.)

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #60167.
Fixes CVE-2023-29402.

Change-Id: I64572e9f454bce7b685d00e2e6a1c96cd33d53df
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1882606
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/501226
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
11 months agocmd/go: enforce flags with non-optional arguments
Roland Shoemaker [Fri, 5 May 2023 20:10:34 +0000 (13:10 -0700)]
cmd/go: enforce flags with non-optional arguments

Enforce that linker flags which expect arguments get them, otherwise it
may be possible to smuggle unexpected flags through as the linker can
consume what looks like a flag as an argument to a preceding flag (i.e.
"-Wl,-O -Wl,-R,-bad-flag" is interpreted as "-O=-R -bad-flag"). Also be
somewhat more restrictive in the general format of some flags.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #60305
Fixes CVE-2023-29404

Change-Id: I913df78a692cee390deefc3cd7d8f5b031524fc9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1876275
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/501225
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/go,cmd/cgo: in _cgo_flags use one line per flag
Ian Lance Taylor [Thu, 4 May 2023 21:06:39 +0000 (14:06 -0700)]
cmd/go,cmd/cgo: in _cgo_flags use one line per flag

The flags that we recorded in _cgo_flags did not use any quoting,
so a flag containing embedded spaces was mishandled.
Change the _cgo_flags format to put each flag on a separate line.
That is a simple format that does not require any quoting.

As far as I can tell only cmd/go uses _cgo_flags, and it is only
used for gccgo. If this patch doesn't cause any trouble, then
in the next release we can change to only using _cgo_flags for gccgo.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #60306
Fixes CVE-2023-29405

Change-Id: I81fb5337db8a22e1f4daca22ceff4b79b96d0b4f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1875094
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/501224
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/go: document changes to go test -c and -o
Russ Cox [Mon, 5 Jun 2023 16:38:59 +0000 (12:38 -0400)]
cmd/go: document changes to go test -c and -o

This was missing from CL 466397.

For #15513.

Change-Id: I138b7d76842815f4e702d7fe551aa8968097f75b
Reviewed-on: https://go-review.googlesource.com/c/go/+/500955
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>

11 months agocmd/go: handle -C properly during toolchain switches
Russ Cox [Mon, 5 Jun 2023 15:19:03 +0000 (11:19 -0400)]
cmd/go: handle -C properly during toolchain switches

The -C dir flag was added in Go 1.20.
This CL adds a new restriction: the -C must appear as the first flag on the command line.
This restriction makes finding the -C flag robust and matches the general way
people tend to think about and use the -C flag anyway.
It may break a few scripts that have been written since Go 1.20
but hopefully they will not be hard to find and fix.
(There is no strict compatibility guarantee for the command line.)

For #57001.

Change-Id: Ice2e5982c58d41eabdaef42a80d3624cde2c9873
Reviewed-on: https://go-review.googlesource.com/c/go/+/500915
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
11 months agocmd/go: move switch-only code from select.go to switch.go
Russ Cox [Mon, 5 Jun 2023 02:49:28 +0000 (22:49 -0400)]
cmd/go: move switch-only code from select.go to switch.go

Move NewerToolchain and related code from select.go to switch.go
because it is only used for the Switch operation, not for Select.
This is a separate CL containing only the code move, separate
from any other changes.

For #57001.

Change-Id: I41cf0629b41fd55c30a1e799d857c06039ee99b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/500798
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/go: additional doc-inspired tests and bug fixes
Russ Cox [Mon, 5 Jun 2023 02:34:52 +0000 (22:34 -0400)]
cmd/go: additional doc-inspired tests and bug fixes

Additional tests and bug fixes realized while writing go.dev/doc/gotoolchain (CL 500775).

- Handle go get toolchain@go1.22 (resolve to latest patch release, same as go get go@1.22).
  (See modload/query.go and gover/mod.go.)

- Handle go get go@patch toolchain@patch.
  (See modload/query.go and gover/mod.go.)

- Remove prefix-goVERSION-suffix form for toolchain name,
  standardizing on goVERSION-suffix.
  I have no good explanation for having two forms, so simplify to one.
  (See vendor and gover.)

- Fail toolchain downloads when GOSUMDB=off.
  Because toolchain downloads cannot always be predicted
  (especially during switching rather than selection),
  they cannot be listed in go.sum.
  We rely on the checksum database for integrity of the download,
  especially if proxied. If the checksum database is disabled,
  this integrity check won't happen, so fail toolchain downloads.
  (See modfetch/sumdb.go and script/gotoolchain_net.txt)

- Use names from documentation in package toolchain
  (Select, Switch; SwitchTo renamed to Exec to avoid both names;
  reqs.go renamed to switch.go; toolchain.go renamed to select.go.)

- Make "go env GOTOOLCHAIN" and "go env -w GOTOOLCHAIN"
  work even when GOTOOLCHAIN is misconfigured.
  (See special case at top of Select in select.go.)

- Clarify what goInstallVersion does
  (report whether this is go install or go run pkg@version)
  and explain the potential version switch more clearly.
  Use the Switcher directly instead of reimplementing it.
  (See select.go.)

- Document go@ and toolchain@ forms in go help get,
  linking to go.dev/doc/toolchain.
  (See modget/get.go.)

- Update URL of documentation in $GOROOT/go.env.

For #57001.

Change-Id: I895ef3519ff95db8710ed23b36ebaf4f648120cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/500797
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>

11 months agocmd/vendor: vendor latest golang.org/x/mod
Russ Cox [Mon, 5 Jun 2023 02:33:50 +0000 (22:33 -0400)]
cmd/vendor: vendor latest golang.org/x/mod

Incorporate CL 501035 for toolchain syntax changes
and a fix to a race (harmless outside tests) in sumdb client.

go get golang.org/x/mod@62c7e578 # CL 501035
go mod tidy
go mod vendor

This CL will break the cmd/go tests. The next CL fixes them.

For #57001.

Change-Id: I1fcb9799417595ecff870367f256cbc0a488934c
Reviewed-on: https://go-review.googlesource.com/c/go/+/500796
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
11 months agoruntime: implement SUID/SGID protections
Roland Shoemaker [Tue, 9 May 2023 18:47:57 +0000 (11:47 -0700)]
runtime: implement SUID/SGID protections

On Unix platforms, the runtime previously did nothing special when a
program was run with either the SUID or SGID bits set. This can be
dangerous in certain cases, such as when dumping memory state, or
assuming the status of standard i/o file descriptors.

Taking cues from glibc, this change implements a set of protections when
a binary is run with SUID or SGID bits set (or is SUID/SGID-like). On
Linux, whether to enable these protections is determined by whether the
AT_SECURE flag is passed in the auxiliary vector. On platforms which
have the issetugid syscall (the BSDs, darwin, and Solaris/Illumos), that
is used. On the remaining platforms (currently only AIX) we check
!(getuid() == geteuid() && getgid == getegid()).

Currently when we determine a binary is "tainted" (using the glibc
terminology), we implement two specific protections:
  1. we check if the file descriptors 0, 1, and 2 are open, and if they
     are not, we open them, pointing at /dev/null (or fail).
  2. we force GOTRACKBACK=none, and generally prevent dumping of
     trackbacks and registers when a program panics/aborts.

In the future we may add additional protections.

This change requires implementing issetugid on the platforms which
support it, and implementing getuid, geteuid, getgid, and getegid on
AIX.

Thanks to Vincent Dehors from Synacktiv for reporting this issue.

Fixes #60272
Fixes CVE-2023-29403

Change-Id: I73fc93f2b7a8933c192ce3eabbf1db359db7d5fa
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1878434
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/501223
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agoruntime: skip TestCrashDumpsAllThreads with mayMoreStackPreempt
Austin Clements [Tue, 6 Jun 2023 17:07:37 +0000 (13:07 -0400)]
runtime: skip TestCrashDumpsAllThreads with mayMoreStackPreempt

This test is flaky with in mayMoreStackPreempt mode. This is probably
revealing a real bug in the scheduler, but since it seems to only
affect TestCrashDumpsAllThreads, which is itself testing a debug mode,
I don't think this is high priority.

Updates #55160.

Change-Id: Iac558c098930ad8d4392b1e82b34f55eaec77c48
Reviewed-on: https://go-review.googlesource.com/c/go/+/501229
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>

11 months agocmd/dist: share one copy of the "generated by" header string
Austin Clements [Mon, 5 Jun 2023 19:51:52 +0000 (15:51 -0400)]
cmd/dist: share one copy of the "generated by" header string

Right now, every code generator in dist has a copy of the

  // Code generated by go tool dist; DO NOT EDIT.

string. Put it in one place to make sure it doesn't diverge.

Change-Id: I8b2a1904031599d7fc128b6a5d74480dee05fc89
Reviewed-on: https://go-review.googlesource.com/c/go/+/501138
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/dist: remove deptab and cleanlist in favor of gentab
Austin Clements [Tue, 6 Jun 2023 01:48:59 +0000 (21:48 -0400)]
cmd/dist: remove deptab and cleanlist in favor of gentab

dist's deptab is a list of changes to the automatically derived set of
package dependencies. It's as old as dist itself, and the first
version of deptab in CL 5620045 was quite complex. From the beginning,
some of the entries in deptab have been for generated files that need
to be added to the dependency set because they can't be discovered if
they don't exist. gentab is also as old as dist itself, and lists the
generated dependency files.

The interaction between deptab and gentab is rather odd. gentab
contains only base file names, not whole paths. To figure out what
files to generate, dist takes a Cartesian product of deptab and gentab
and calls the generator wherever the basename of a path in deptab
matches an entry in gentab. This perhaps made sense at the time
because some of the generated files appeared in more than one package
in deptab.

These days, deptab consists exclusively of generated files because
dist can correctly derive all other dependencies, and all of the
generated files have unique paths. This makes the Cartesian product
approach needlessly complex (and so confusing!), and means that the
only purpose served by deptab is to provide full paths for generated
files.

Furthermore, in the dist clean command, it also needed to expand the
file names in gentab to complete paths, but it did so using a
different list, cleanlist, and the same Cartesian product algorithm.

This CL drops all of this complexity by putting full paths into
gentab, which lets us delete deptab and cleanlist.

Change-Id: Ie3993983734f6da3be453bb4c17a64e22dcf3e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/501137
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
11 months agocmd/dist: remove stale cleanup code
Austin Clements [Tue, 6 Jun 2023 01:30:18 +0000 (21:30 -0400)]
cmd/dist: remove stale cleanup code

dist clean has logic to delete command binaries from the cmd
directories in cleanlist. However, these days the only binary it could
possibly remove is "$GOROOT/src/cmd/cgo/cgo". This is clearly no
longer necessary, so remove this stale code.

When this logic was originally introduced in CL 5622058, it was driven
by cleantab (not cleanlist), which contained all of the cmd
directories, which were legion at the time because this was the era of
the [568][acgl] toolchain. CL 9154 deleted cleantab, and did the same
clean walk over the "cmd/" directories listed in buildorder. However,
buildorder was a list of packages necessary to build cmd/go, so the
only "cmd/" directory in buildorder at the time was "cmd/go". Hence,
at that CL, dist started deleting only a "$GOROOT/src/cmd/go/go"
binary. The modern cleanlist was introduced in CL 76021, as a list of
packages containing "generated files and commands". The only "cmd/"
directory in cleanlist the whole time has been "cmd/cgo" (and I'm
honestly not sure why cmd/cgo is in there), so since that CL dist has
only deleted "$GOROOT/src/cmd/cgo/cgo".

Change-Id: I1915eb938d1a0e22ae6a64e7648a21894d3e6502
Reviewed-on: https://go-review.googlesource.com/c/go/+/501136
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
11 months agocmd/dist: remove stale files from gentab
Austin Clements [Tue, 6 Jun 2023 00:04:31 +0000 (20:04 -0400)]
cmd/dist: remove stale files from gentab

There are several files in gentab that have a nil generator, which
means they used to be generated, but aren't any more, so dist should
delete them if it encounters them. However, cleaning only look for
these file names in the small number of directories listed in
cleanlist, and none of these files were originally generated into any
of the directories in cleanlist. Specifically, enam.c was generated
into $GOROOT/src/cmd/[568]l starting with CL 5620045 until CL 35740044
and the anames[5689].c files were generated into $GOROOT/src/liblink
starting with CL 35740044 and CL 120690043 until CL 6110. None of
these directories even exist any more, and if these files did somehow
exist, dist wouldn't delete them anyway.

Hence, we can safely remove these files from gentab.

Change-Id: Ifed322d64a7a81a76537fcd9fc7020c7aca48050
Reviewed-on: https://go-review.googlesource.com/c/go/+/501135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
11 months agogo/types, types2: handle named and literal interfaces in interface unification
Robert Griesemer [Fri, 2 Jun 2023 00:20:02 +0000 (17:20 -0700)]
go/types, types2: handle named and literal interfaces in interface unification

If we don't have exact unification, we must consider interface
unification whether one of the types is a defined (named) interface
or not. Otherwise, if one of them is named, and the other one isn't,
the code selects interface-vs-non-interface unification and possibly
uses the wrong method set as the "required" method set, leading to
(incorrect) unification failure as was the case in #60564.

We can also not simply rely on getting this right in the subsequent
switch, through the handling of *Named types.

This CL fixes this simple logic error. If there's inexact unification,
now all (non-type parameter) interface cases are handled in one place,
before the switch. After handling interfaces, we are guaranteed that
we have either no interfaces, or we have exact unification where both
types must be of the same structure.

As a consequence, we don't need special handling for named interfaces
in the *Named case of the switch anymore.

Also, move the (unbound) type parameter swap from before interface
handling to after interface handling, just before the switch which
is the code that relies on a type parameter being in x, if any.

Fixes #60564.

Change-Id: Ibf7328bece25808b8dbdb714867048b93689f219
Reviewed-on: https://go-review.googlesource.com/c/go/+/500195
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
11 months agocmd/compile: check method name in PGO devirtualization
Cherry Mui [Tue, 6 Jun 2023 02:28:48 +0000 (22:28 -0400)]
cmd/compile: check method name in PGO devirtualization

Currently, we devirtualize an interface call if the profile
indicates a concrete callee is hot on the same line, and the
concrete receiver implements the interface. But it is possible
that (likely due to another call on the same line, or possibly a
stale profile) the concrete call is to a different method.

With the current AST construction we generate correct code, as we
extract the method name from the interface call and use that to
create the concrete call. But the devirtualization decision is
based on an unrelated call in the profile.

Check the method name when finding the hottest callee, so we won't
use unrelated calls to different methods.

Change-Id: I75c026997926f21bd6cc5266d3ffe99649a9b2d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/500961
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
11 months agocmd/compile/internal/syntax: better error message when using = instead of ==
Robert Griesemer [Mon, 5 Jun 2023 16:30:58 +0000 (09:30 -0700)]
cmd/compile/internal/syntax: better error message when using = instead of ==

When = is used instead of == as part of a conditional expression,
the parser message emphasizes the LHS and RHS of = by always
parenthesizing the two sides. For example, for:

if x = y {}

the error is:

        cannot use assignment (x) = (y) as value

This is done to highlight the LHS and RHS in case of more complex
cases such as

        if x || y = z {}

which one may incorrectly read as (x) || (y == z) rather than the
correct (x || y) = z.

This CL fine-tunes the error message a bit by only adding the
parentheses if the LHS and RHS are binary expressions.

Fixes #60599.
For #23385.

Change-Id: Ida4c8d12464cc2ac15c934f24858eb6f43cf9950
Reviewed-on: https://go-review.googlesource.com/c/go/+/500975
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agocmd/go: document GOTOOLCHAIN
Russ Cox [Sat, 3 Jun 2023 21:30:47 +0000 (17:30 -0400)]
cmd/go: document GOTOOLCHAIN

For #57001.

Change-Id: I74c4abd675bd5636a029332b45ef0e6fdc36106f
Reviewed-on: https://go-review.googlesource.com/c/go/+/500795
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
11 months agocmd/compile: adjust PGO devirtualization diagnostic message
Cherry Mui [Mon, 5 Jun 2023 20:36:38 +0000 (16:36 -0400)]
cmd/compile: adjust PGO devirtualization diagnostic message

Make it more consistent with the static devirtualization
diagnostic message. Keep the print of concrete callee's method
name, as it is clearer.

Change-Id: Ibe9b40253eaff2c0071353a2b388177213488822
Reviewed-on: https://go-review.googlesource.com/c/go/+/500960
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
11 months agodoc/go1.21: document GOEXPERIMENT=loopvar and invite feedback
Russ Cox [Mon, 5 Jun 2023 17:52:19 +0000 (13:52 -0400)]
doc/go1.21: document GOEXPERIMENT=loopvar and invite feedback

For #60078.

Change-Id: I92ab1fc2f30e6bbaabd8e3e1b8834e6ddff2414d
Reviewed-on: https://go-review.googlesource.com/c/go/+/500958
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
11 months agodoc/go1.21: document forward and backward compatibility
Russ Cox [Mon, 5 Jun 2023 16:39:40 +0000 (12:39 -0400)]
doc/go1.21: document forward and backward compatibility

Also handle go test -c TODO.

For #15513.
For #56986.
For #57001.

Change-Id: I571ae25d8d8fcd44cb38ac16cdd2a1180016eb94
Reviewed-on: https://go-review.googlesource.com/c/go/+/500956
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
11 months agoruntime: skip another GDB "no such process" case
Michael Pratt [Mon, 5 Jun 2023 17:57:37 +0000 (13:57 -0400)]
runtime: skip another GDB "no such process" case

Fixes #58698.
For #50838.

Change-Id: I043c59a57707e64d444cd687f9745bf5313fb7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/500959
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
11 months agodoc/go1.21: move Ports to end
Russ Cox [Mon, 5 Jun 2023 16:42:58 +0000 (12:42 -0400)]
doc/go1.21: move Ports to end

The most important parts of almost any release notes are the
language and tool changes. Those should be the first two sections.
Instead Ports interrupts the flow with information that usually
matters only to very few users.

Move Ports to the end of the release notes.

Change-Id: I78492e91e368184fb5f8e8d44d63f35b8f14eeae
Reviewed-on: https://go-review.googlesource.com/c/go/+/500957
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agoruntime: add debugger hook for fatal signals
Alessandro Arzilli [Wed, 17 May 2023 13:33:07 +0000 (15:33 +0200)]
runtime: add debugger hook for fatal signals

On Go <= 1.20 signals that caused the program to exit would eventually
call runtime.fatal. After the changes made in go.dev/cl/462437 but it
would still be nice if debuggers (eg. Delve) had a function they could
hook to intercept fatal signals.

Change-Id: Icf2b65187f95d52e60825c84f386806a75b38f6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495736
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

11 months agodoc/go1.21: fix link in debug/elf section
Tobias Klauser [Mon, 5 Jun 2023 08:33:50 +0000 (10:33 +0200)]
doc/go1.21: fix link in debug/elf section

Change-Id: Ief3e263e6c11069abbbf4dd8ce10c317e3a1cab2
Reviewed-on: https://go-review.googlesource.com/c/go/+/500815
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

11 months agoruntime: move Segv and TgkillSegv to testprog
Cherry Mui [Fri, 2 Jun 2023 21:54:57 +0000 (17:54 -0400)]
runtime: move Segv and TgkillSegv to testprog

The non-cgo test points Segv and TgkillSegv are currently in
testprogcgo. Although the test points don't explicitly use cgo,
being a cgo program, there is still some C code that runs when
the test point is invoked, such as thread creation code.

For the cgo test points, sometimes we fail to unwind the stack if
C code is involved. For the non-cgo ones, we want to always be
able to unwind the stack, so we check for stack unwinding failures.
But if a signal is landed in the small piece of C code mentioned
above, we may still fail to unwind. Move the non-cgo test points
to a pure-Go program to avoid this problem.

May fix #52963.
Updates #59029, #59443, #59492.

Change-Id: I35d99a0dd4c7cdb627e2083d2414887a24a2822d
Reviewed-on: https://go-review.googlesource.com/c/go/+/500535
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>

11 months agosyscall: don't panic when argv is nil on freebsd
Roland Shoemaker [Fri, 2 Jun 2023 15:49:47 +0000 (08:49 -0700)]
syscall: don't panic when argv is nil on freebsd

The workaround in CL 69970044 introduced a panic when StartProcess is
called with empty argv. Check the length before trying to access it.

Change-Id: Ic948d86c7067a21c484ba24e100d1f1f80179730
Reviewed-on: https://go-review.googlesource.com/c/go/+/500415
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
11 months agogo/types, types2: fix incorrect logic in assignability check
Robert Griesemer [Thu, 25 May 2023 23:35:17 +0000 (16:35 -0700)]
go/types, types2: fix incorrect logic in assignability check

Do not return prematurely in assignableTo.

Fixes #54424.

Change-Id: I769b3b4ad9d79b7bce60b92cc59c3564117e36db
Reviewed-on: https://go-review.googlesource.com/c/go/+/498400
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
11 months agocmd/compile: allow ir.OMIN/ir.OMAX in mayCall
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>

11 months agobuiltin: add documentation for min/max
Cuong Manh Le [Fri, 26 May 2023 04:12:12 +0000 (11:12 +0700)]
builtin: add documentation for min/max

Updates #59488

Change-Id: If873b81fb7f0e28b84a3e5c2ff89426b3e289d5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/498495
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

11 months agocmd/go: maintain go and toolchain lines in go.work
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.

For #57001.

Change-Id: Id49ff7a28a969d3475c70e6a09d40d7aa529afa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/499984
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile/internal/devirtualize: devirtualize methods in other packages if current...
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.

Fixes #60561
Updates #59959

Change-Id: I48449b7d8b329d84151bd3b506b8093c262eb2a3
GitHub-Last-Rev: 2d53c55fd895ad8fefd25510a6e6969e89d54a6d
GitHub-Pull-Request: golang/go#60565
Reviewed-on: https://go-review.googlesource.com/c/go/+/500155
Run-TryBot: thepudds <thepudds1460@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: adjust pruning and switch toolchain when needed in 'go mod tidy'
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).

For #57001.

Change-Id: Ic8e9b87d5979b3a6d1ee70f1f2bf2eea46b1bb0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499676
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agocmd/go: adjust pruning and switch toolchains if needed when go get changes go version
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.

Revised from CL 498120.

For #57001.

Change-Id: Ic8994737eca4ed61ccc093a69e46f5a6caa8be87
Reviewed-on: https://go-review.googlesource.com/c/go/+/498267
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: adjust conditions in which toolchain lines are written
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.)

For #57001.

Change-Id: I415abac75d8d6de9f8ed470aab0d1ed4c225b08d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499987
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc/go1.21: document macOS and Windows requirements
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>
12 months agodoc/go1.21: document that os.TempDir now uses GetTempPath2W
qmuntal [Fri, 2 Jun 2023 08:25:20 +0000 (10:25 +0200)]
doc/go1.21: document that os.TempDir now uses GetTempPath2W

Updates #56899

Change-Id: Ibde69cd55c81ac0bb757b28b28d69463778dd117
Reviewed-on: https://go-review.googlesource.com/c/go/+/500255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agonet: filter disabled interfaces in Windows DNS client
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)

Co-authored-by: Zhiyuan Zheng <zhzy0077@hotmail.com>
GitHub-Last-Rev: db158625bb46692cbbc09e3fe4dfa023c733f4e6
GitHub-Pull-Request: golang/go#56161
Change-Id: I7becebc55c8ac612c670c533855f7e6ca397a496
Reviewed-on: https://go-review.googlesource.com/c/go/+/500375
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agogo/types, types2: remove version check for more lenient constant handling in inference
Robert Griesemer [Thu, 1 Jun 2023 23:31:15 +0000 (16:31 -0700)]
go/types, types2: remove version check for more lenient constant handling in inference

For #58671.
Fixes #60566.

Change-Id: I746f99cdfd44b204dc90350fcfb3867e9b8b1da8
Reviewed-on: https://go-review.googlesource.com/c/go/+/499997
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types, types2: report inference instead of assignment failure when types can't...
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>
12 months agocmd/api: make check even pickier about api/next/*.txt
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>
12 months agomath/big: rename Int.ToFloat64 to Float64
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>

12 months agocmd/go: return more errors from ReadModFile, loadModFile
Russ Cox [Thu, 1 Jun 2023 18:13:20 +0000 (14:13 -0400)]
cmd/go: return more errors from ReadModFile, loadModFile

Return more errors instead of base.Fatalf, so we can handle them
in the callers.

For #57001.

Change-Id: If3e63d3f64188148f5d750991f9cb1175790d89d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499983
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agodoc/go1.21: crypto release notes
Roland Shoemaker [Wed, 31 May 2023 17:35:20 +0000 (10:35 -0700)]
doc/go1.21: crypto release notes

Updates #58645

Change-Id: Ib7e2baba41bb327d8fc466afb1e117fe2f22e1c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/499637
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>

12 months agogo/types, types2: use exact matching when unifying constraint method signatures
Robert Griesemer [Thu, 1 Jun 2023 17:16:01 +0000 (10:16 -0700)]
go/types, types2: use exact matching when unifying constraint method signatures

Fixes #60556.

Change-Id: I203a0bc79eff607654c3e8350d259e694cb035b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/499995
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agocmd/go: add gover.Max and gover.MaxToolchain
Russ Cox [Thu, 1 Jun 2023 18:11:27 +0000 (14:11 -0400)]
cmd/go: add gover.Max and gover.MaxToolchain

I've inlined these by hand enough times now.

For #57001.

Change-Id: Ia274bd444f12b07ce14eeb2b5a66546880db8f77
Reviewed-on: https://go-review.googlesource.com/c/go/+/499982
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/go: add base.Error and base.Fatal
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.)

For #57001.

Change-Id: I9613653b94808224146077c30d22f814d4e19eed
Reviewed-on: https://go-review.googlesource.com/c/go/+/499980
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/go: move CreateWorkFile from modload to workcmd
Russ Cox [Thu, 1 Jun 2023 16:59:36 +0000 (12:59 -0400)]
cmd/go: move CreateWorkFile from modload to workcmd

In workcmd it can deal with automatic version switching.

For #57001.

Change-Id: I5027690cf744d6d73f87e837c76ea7083ed56aba
Reviewed-on: https://go-review.googlesource.com/c/go/+/499979
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/go: move version constants from modload to gover
Russ Cox [Thu, 1 Jun 2023 16:55:58 +0000 (12:55 -0400)]
cmd/go: move version constants from modload to gover

For #57001.

Change-Id: Ia76478b8eaa934b7e1dc1e9cd7fe8a2428fc291a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499978
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agoapi: promote next to go1.21
Michael Anthony Knyszek [Thu, 1 Jun 2023 19:22:00 +0000 (19:22 +0000)]
api: promote next to go1.21

Change-Id: I30cbd14bd2b3903d7960c5d860d76ce7f3d4730a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499981
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

12 months agoruntime: update skips for TestGdbBacktrace
Michael Pratt [Thu, 1 Jun 2023 16:34:20 +0000 (12:34 -0400)]
runtime: update skips for TestGdbBacktrace

One issue simply has a reworded message, probably from a new version of
GDB. Another is a new issue.

Fixes #60553.
Fixes #58698.
Updates #39204.

Change-Id: I8389aa981fab5421f57ee761bfb5e1dd237709ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/499975
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
12 months agocmd/internal/obj/arm: handle HAUTO etc. in addpool
Cherry Mui [Mon, 23 Jan 2023 18:31:00 +0000 (13:31 -0500)]
cmd/internal/obj/arm: handle HAUTO etc. in addpool

HAUTO should be handled the same way as other stack offsets for
adding to constant pool. Add the missing cases.

Fixes #57955.

Change-Id: If7fc82cafb2bbf0a6121e73e353b8825cb36b5bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/463138
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

12 months agocmd/internal/testdir: pass if GOEXPERIMENT=cgocheck2 is set
Austin Clements [Wed, 31 May 2023 16:32:29 +0000 (12:32 -0400)]
cmd/internal/testdir: pass if GOEXPERIMENT=cgocheck2 is set

Some testdir tests fail if GOEXPERIMENT=cgocheck2 is set. Fix this by
skipping these tests.

Change-Id: I58d4ef0cceb86bcf93220b4a44de9b9dc4879b16
Reviewed-on: https://go-review.googlesource.com/c/go/+/499675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
12 months agocmd/cgo/internal/testerrors: pass if GOEXPERIMENT=cgocheck2 is set
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>
12 months agocmd/link/internal/ld: pass correct offset to codesign.Sign
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.

Fixes #59555

Change-Id: Iad88f142705949dcc0b192b811337df9b4be08cf
GitHub-Last-Rev: 37a048d58e01a3befa4db574e5fb48ab8d6013a1
GitHub-Pull-Request: golang/go#59581
Reviewed-on: https://go-review.googlesource.com/c/go/+/484015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

12 months agodoc/go1.21: correct links in go/build note
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>
12 months agodoc/go1.21: fix io/fs.ReadDirFS link formatting
Tobias Klauser [Thu, 1 Jun 2023 13:12:42 +0000 (15:12 +0200)]
doc/go1.21: fix io/fs.ReadDirFS link formatting

Change-Id: I348ac0c0e098f027b8d608a260ee9437d2b77539
Reviewed-on: https://go-review.googlesource.com/c/go/+/499835
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
12 months agocmd/go: propagate gover.TooNewError from modload.LoadModGraph
Bryan C. Mills [Wed, 31 May 2023 19:17:14 +0000 (15:17 -0400)]
cmd/go: propagate gover.TooNewError from modload.LoadModGraph

For #57001.

Change-Id: I639190b5f035139ba42a93ca03dd8a4c747556ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/499678
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
12 months agodoc: remove relnote TODO by merging with another section
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>
12 months agodoc/go1.21: reformat flag init change note
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>
12 months agodoc/go1.21: remove some references to reverted CLs
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>
12 months agodoc/go1.21: fix type in closing tag
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>
12 months agodoc: add release note for go:wasmimport
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>
12 months agocmd/go/internal/toolchain: avoid importing modcmd
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.

For #57001.

Change-Id: I9694706d7225b269f26dc68814894613a3329abb
Reviewed-on: https://go-review.googlesource.com/c/go/+/499316
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
12 months agocmd/go: fix TestScript/gotoolchain_net when $PATH contains golang.org/dl/go1.20.1
Bryan C. Mills [Thu, 1 Jun 2023 14:13:11 +0000 (10:13 -0400)]
cmd/go: fix TestScript/gotoolchain_net when $PATH contains golang.org/dl/go1.20.1

For #57001.

Change-Id: Idcc291c872864bcce7e6d411cdd208db3b331282
Reviewed-on: https://go-review.googlesource.com/c/go/+/499855
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
12 months agodoc: add release note for cgo error on methods on C types
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>

12 months agoruntime: only increment extraMInUse when actually in use
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>

12 months agodoc/go1.21: document PGO GA and devirtualization
Michael Pratt [Thu, 25 May 2023 17:57:25 +0000 (13:57 -0400)]
doc/go1.21: document PGO GA and devirtualization

For #59959.
For #58645.

Change-Id: I574153ef2fd61a5e90ec281fca065c42fce22cc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/498263
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc/go1.21: document that os.DirFS implements fs.Read{File,Dir}FS
Tobias Klauser [Wed, 31 May 2023 21:35:14 +0000 (23:35 +0200)]
doc/go1.21: document that os.DirFS implements fs.Read{File,Dir}FS

Also add a missing </a> in the preceding section.

For #53761

Change-Id: I8e64b86b5b32067f954d58cf9adf86cb4d2eeb2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/499735
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
12 months agocmd/go: delete cmd/go/internal/slices in favor of slices
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.

Change-Id: I69ec680106ad2924276f7473e6547a3a907efc96
Reviewed-on: https://go-review.googlesource.com/c/go/+/499715
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/go: make toolchain less special in MVS
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.

For #57001.

Change-Id: I74084637c177c30918fdb114a0d9030cdee7324e
Reviewed-on: https://go-review.googlesource.com/c/go/+/499575
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agogo/types, types2: better error message for some inference failures
Robert Griesemer [Wed, 31 May 2023 22:15:13 +0000 (15:15 -0700)]
go/types, types2: better error message for some inference failures

For a unification failure involving a constraint, rather than just
reporting (for instance)

        S does not match []E

now report the inferred type for the type parameter, use spec
terminology when referring to the constraint, and print the
constraint in full:

        S (type func()) does not satisfy ~[]E

There's more we can do, but this is better than what we had.

For #60542.

Change-Id: I033369fa0dfc475f0ec0da0582e8cbefb109f3cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/499639
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agodoc/go1.21: remove math.Compare TODOs
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>

12 months agogo1.21.html: describe testing/slogtest package
Jonathan Amsterdam [Fri, 26 May 2023 15:32:40 +0000 (11:32 -0400)]
go1.21.html: describe testing/slogtest package

Change-Id: I734aae67d410073056388852cd94776c7483b4b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/498273
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>

12 months agodoc/go1.21: document type inference changes
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>
12 months agodoc/go1.21: mention improvement to C-to-Go calls
Michael Pratt [Wed, 31 May 2023 21:12:58 +0000 (17:12 -0400)]
doc/go1.21: mention improvement to C-to-Go calls

For #51676.
For #58645.

Change-Id: I9045051b5a25c6dfc833eef13e6c105a0d8ae763
Reviewed-on: https://go-review.googlesource.com/c/go/+/499716
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>