]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years agoREADME.md: update links to go.dev
Jero Bado [Tue, 1 Feb 2022 23:22:31 +0000 (23:22 +0000)]
README.md: update links to go.dev

Fixes #50916.

Change-Id: I51f3269b7a0793a3002eef83de1d871111fc3cdc
GitHub-Last-Rev: fc8c183ac7fa84d6caefdf49ed1d8cac19d7744f
GitHub-Pull-Request: golang/go#50919
Reviewed-on: https://go-review.googlesource.com/c/go/+/381962
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>

2 years agointernal/reflectlite: fix name of type parameter
zhouguangyuan [Sat, 19 Mar 2022 18:10:17 +0000 (02:10 +0800)]
internal/reflectlite: fix name of type parameter

CL 372774 is for reflect, this CL is for internal/reflectlite.

Updates #50208

Change-Id: Ib7e8b1bc031feab218d1addd78388fcfe9b675b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/393918
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>

2 years agocmd/compile/internal/riscv64: add initial spill support
Meng Zhuo [Sun, 31 Oct 2021 13:12:45 +0000 (21:12 +0800)]
cmd/compile/internal/riscv64: add initial spill support

This CL adds some initial support for spilling and reloading
registers in the new ABI for RISCV64.

Change-Id: I5e2b4d93c33c528809d569e5a442bb302074be78
Reviewed-on: https://go-review.googlesource.com/c/go/+/360215
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: pre init shapeMap
cuiweixie [Wed, 12 Jan 2022 12:01:26 +0000 (12:01 +0000)]
cmd/compile: pre init shapeMap

Change-Id: I4fea927b9d34e7bf382ddf148a787c1558176f2f
GitHub-Last-Rev: ff1fa78a3601243092f84a69e7332ec2ba9ec05a
GitHub-Pull-Request: golang/go#50568
Reviewed-on: https://go-review.googlesource.com/c/go/+/377994
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

2 years agocmd/compile/internal: add ABI register info for riscv64
Meng Zhuo [Thu, 28 Oct 2021 07:22:26 +0000 (15:22 +0800)]
cmd/compile/internal: add ABI register info for riscv64

This CL adds register information for riscv64

Updates #40724

Change-Id: If2275d9135596ff856d096881e4fe8bd1eeaacb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/359337
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: remove n.Diag() deadcode paths
Cuong Manh Le [Fri, 18 Mar 2022 17:34:26 +0000 (00:34 +0700)]
cmd/compile: remove n.Diag() deadcode paths

CL 392918 changed n.Diag() to always return false, we can now get rid
of all its deadcode paths.

Updates #51691

Change-Id: I64c07970493e7bdcf89df9508ce88132ef4aa4d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/393915
Trust: 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>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: remove t.Broke() deadcode paths
Cuong Manh Le [Fri, 18 Mar 2022 17:23:33 +0000 (00:23 +0700)]
cmd/compile: remove t.Broke() deadcode paths

CL 392918 changed t.Broke() to always return false, we can now get rid
of all its deadcode paths.

Updates #51691

Change-Id: I0a2a13def07364e780e4785621690452948e219a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393914
Trust: 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>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: diagnose unset GOROOT when built with -trimpath
Bryan C. Mills [Fri, 11 Mar 2022 04:40:10 +0000 (23:40 -0500)]
cmd/go: diagnose unset GOROOT when built with -trimpath

For #51483

Change-Id: I4546c20cf968b595020a1eba888fe1d9a1c6cfc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/391811
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Bryan Mills <bcmills@google.com>

2 years agocmd/go: include the "-trimpath" flag in the stamped build settings
Bryan C. Mills [Wed, 9 Mar 2022 17:01:16 +0000 (12:01 -0500)]
cmd/go: include the "-trimpath" flag in the stamped build settings

The -trimpath flag has a strong effect on the resulting binary:
in particular, it determines whether runtime.GOROOT can report
a meaningful path in the absence of an explicit GOROOT environment variable.

For #51461

Change-Id: Id0d55572c0a0a4e2e4724363ed80dfa05b202186
Reviewed-on: https://go-review.googlesource.com/c/go/+/391810
Trust: 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>

2 years agocmd/go: stamp build settings for binaries in cmd
Bryan C. Mills [Tue, 8 Mar 2022 22:01:12 +0000 (17:01 -0500)]
cmd/go: stamp build settings for binaries in cmd

Also update cmd/dist to avoid setting gcflags and ldflags explicitly
when the set of flags to be set is empty (a verbose way of specifying
the default behavior).

Stamping was disabled for the Go standard library in CL 356014 due to
the cmd/dist flags causing cmd/go to (correctly) report the resulting
binaries as stale.

With cmd/dist fixed, we can also remove the special case in cmd/go,
which will allow tests of binaries in 'cmd' to read the build info
embedded in the test binary. That build info may be useful to
determine (say) whether runtime.GOROOT ought to work without GOROOT
set in the environment.

For #51483
Updates #37475

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

2 years agocmd/go/internal/test: ensure that build.ToolDir is accurate in tests
Bryan C. Mills [Fri, 11 Mar 2022 04:38:25 +0000 (23:38 -0500)]
cmd/go/internal/test: ensure that build.ToolDir is accurate in tests

This fixes a build failure due to inability to locate the "vet" tool
when the test binary is built with -trimpath.

Updates #51461

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

2 years agogo/build: avoid setting Default.GOROOT when runtime.GOROOT() is empty
Bryan C. Mills [Tue, 8 Mar 2022 21:29:00 +0000 (16:29 -0500)]
go/build: avoid setting Default.GOROOT when runtime.GOROOT() is empty

Previously, we called path.Clean on the value of runtime.GOROOT() even
if it was empty, which would set it explicitly to ".".
That would cause (*Context).importGo to assume that errors resolving
paths in GOROOT are fatal and return early:
https://cs.opensource.google/go/go/+/master:src/go/build/build.go;l=1121-1127;drc=38174b3a3514629b84dcd76878b2f536b189dd7b

If we instead leave it empty (and are in module mode), then importGo
will fall back to letting the 'go' command resolve the path, which may
succeed if the 'go' command can infer the correct GOROOT (from its own
stamped-in default GOROOT or executable path).

Fixes #51483

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

2 years agointernal/testenv: add GOROOT and use it to fix tests broken with -trimpath
Bryan C. Mills [Wed, 9 Mar 2022 22:19:23 +0000 (17:19 -0500)]
internal/testenv: add GOROOT and use it to fix tests broken with -trimpath

This fixes many (but not all) of the tests that currently fail
(due to a bogus path reported by runtime.GOROOT) when run with
'go test -trimpath std cmd'.

Updates #51461

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

2 years agocmd/link: avoid stamping runtime.defaultGOROOT when paths are being trimmed
Bryan C. Mills [Tue, 15 Mar 2022 20:37:50 +0000 (16:37 -0400)]
cmd/link: avoid stamping runtime.defaultGOROOT when paths are being trimmed

Previously, runtime.GOROOT() would return the string "go" in a binary
build with -trimpath. This change stamps the empty string instead,
using a sentinel value passed from cmd/go that looks like the GOROOT
environment variable (either "$GOROOT" or "%GOROOT%", depending on the
platform).

Fixes #51461

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

2 years agointernal/buildcfg: initialize GOROOT to runtime.GOROOT
Bryan C. Mills [Tue, 15 Mar 2022 20:31:02 +0000 (16:31 -0400)]
internal/buildcfg: initialize GOROOT to runtime.GOROOT

In the beginning the Go compiler was in C, and C had a function
'getgoroot' that returned GOROOT from either the environment or a
generated constant. 'getgoroot' was mechanically converted to Go
(as obj.Getgoroot) in CL 3046.

obj.Getgoroot begat obj.GOROOT. obj.GOROOT begat objabi.GOROOT,
which begat buildcfg.GOROOT.

As far as I can tell, today's buildcfg.GOROOT is functionally
identical to runtime.GOROOT(). Let's reduce some complexity by
defining it in those terms.

While we're thinking about buildcfg.GOROOT, also check whether it is
non-empty: if the toolchain is built with -trimpath, the value of
GOROOT might not be valid or meaningful if the user invokes
cmd/compile or cmd/link directly, or via a build tool other than
cmd/go that doesn't care as much about GOROOT. (As of CL 390024,
runtime.GOROOT will return the empty string instead of a bogus one
when built with -trimpath.)

For #51461.

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

2 years agocmd/go: avoid stamping VCS metadata in test binaries
Bryan C. Mills [Fri, 18 Mar 2022 15:40:34 +0000 (11:40 -0400)]
cmd/go: avoid stamping VCS metadata in test binaries

Invoking a VCS tool requires that the VCS tool be installed, and also
adds latency to build commands. Unfortunately, we had been mistakenly
loading VCS metadata for tests of "main" packages.

Users almost never care about versioning for test binaries, because
'go test' runs the test in the source tree and test binaries are only
rarely used outside of 'go test'. So the user already knows exactly
which version the test is built against, because the source code is
right there — it's not worth the overhead to stamp.

Fixes #51723.

Change-Id: I96f191c5a765f5183e5e10b6dfb75a0381c99814
Reviewed-on: https://go-review.googlesource.com/c/go/+/393894
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotime: fix zoneinfo.zip locating logic when built with -trimpath
Bryan C. Mills [Thu, 10 Mar 2022 05:19:05 +0000 (00:19 -0500)]
time: fix zoneinfo.zip locating logic when built with -trimpath

When the test binary is built with the -trimpath flag,
runtime.GOROOT() is invalid, and must not be used to locate
GOROOT/lib/time/zoneinfo.zip. (We can use other sources instead.)

However, the test for the package expects zoneinfo.zip to definitely
exist. 'go test' runs the test binary in the directory containing its
source code — in this case GOROOT/src/time — so we can use that
information to find the zoneinfo.zip file when runtime.GOROOT isn't
available.

For #51483

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

2 years agosort: generate generic variants with E rather than Elem
Ian Lance Taylor [Fri, 18 Mar 2022 00:55:59 +0000 (17:55 -0700)]
sort: generate generic variants with E rather than Elem

For #51698

Change-Id: Ifc5bef2cc41b163644ac80ace7c1470c8a130467
Reviewed-on: https://go-review.googlesource.com/c/go/+/393700
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky‎ <eliben@golang.org>
2 years agocmd/compile: pointers to notinheap types need their own shape
Keith Randall [Fri, 18 Mar 2022 17:46:15 +0000 (10:46 -0700)]
cmd/compile: pointers to notinheap types need their own shape

They should not share a shape with regular pointers. We could coalesce
multiple pointer-to-not-in-heap types, but doesn't seem worth it - just
make them fully stenciled.

Fixes #51733

Change-Id: Ie8158177226fbc46a798e71c51897a82f15153df
Reviewed-on: https://go-review.googlesource.com/c/go/+/393895
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd: update vendored pprof
Heschi Kreinick [Wed, 16 Mar 2022 22:17:58 +0000 (18:17 -0400)]
cmd: update vendored pprof

  go get github.com/google/pprof@latest
  go mod vendor

Plus a tiny change to the pprof command to match an upstream interface
change.

Updates #36905.

Change-Id: I4c7bbe8c317a6eeb217fce971b208f96ab0727fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/393370
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoall: delete ARM64 non-register ABI fallback path
Cherry Mui [Fri, 18 Mar 2022 17:04:08 +0000 (13:04 -0400)]
all: delete ARM64 non-register ABI fallback path

Change-Id: I3996fb31789a1f8559348e059cf371774e548a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/393875
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/go: run 'go help documentation' through gofmt in TestDocsUpToDate
Russ Cox [Fri, 4 Feb 2022 16:55:33 +0000 (11:55 -0500)]
cmd/go: run 'go help documentation' through gofmt in TestDocsUpToDate

mkalldocs.sh runs gofmt on the output, but the test does not.
If go help documentation and gofmt disagree, the test will fail.
Fix that.

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

2 years agointernal/diff: add, replacing cmd/internal/diff
Russ Cox [Sat, 29 Jan 2022 21:13:12 +0000 (16:13 -0500)]
internal/diff: add, replacing cmd/internal/diff

This is an in-process (non-exec'ing) replacement for cmd/internal/diff.
It uses an O(n log n) algorithm instead of the O(n²) algorithm
in standard diff binaries. It does not produce the absolute
shortest diffs, but the results are often more meaningful
than the standard diff, because it doesn't try to align
random blank lines or other noise.

Adding so that tests inside std (especially go/printer)
can print diffs.

Replacing cmd/internal/diff because we don't need two.

Change-Id: I9155dd925e4a813f5bfa84a8ad3dec8ffdbf8550
Reviewed-on: https://go-review.googlesource.com/c/go/+/384255
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>

2 years agointernal/abi, internal/buildcfg: always enable register ABI on ARM64
Cherry Mui [Wed, 2 Mar 2022 16:59:48 +0000 (11:59 -0500)]
internal/abi, internal/buildcfg: always enable register ABI on ARM64

In last cycle we developed register ABI for ARM64, enabled by
default as a GOEXPERIMENT. This cycle we turn it on all the time.
Later CLs will clean up fallback code.

To support in-development platforms (e.g. RISC-V), separate the
boolean variables for in-development platforms and always-on
platforms.

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

2 years agointernal/buildcfg: extract logic specific to cmd/go
Bryan C. Mills [Wed, 16 Mar 2022 20:25:47 +0000 (16:25 -0400)]
internal/buildcfg: extract logic specific to cmd/go

cmd/go/internal/cfg duplicates many of the fields of
internal/buildcfg, but initializes them from a Go environment file in
addition to the usual process environment.

internal/buildcfg doesn't (and shouldn't) know or care about that
environment file, but prior to this CL it exposed hooks for
cmd/go/internal/cfg to write data back to internal/buildcfg to
incorporate information from the file. It also produced quirky
GOEXPERIMENT strings when a non-trivial default was overridden,
seemingly so that 'go env' would produce those same quirky strings in
edge-cases where they are needed.

This change reverses that information flow: internal/buildcfg now
exports a structured type with methods — instead of top-level
functions communicating through global state — so that cmd/go can
utilize its marshaling and unmarshaling functionality without also
needing to write results back into buildcfg package state.

The quirks specific to 'go env' have been eliminated by distinguishing
between the raw GOEXPERIMENT value set by the user (which is what we
should report from 'go env') and the cleaned, canonical equivalent
(which is what we should use in the build cache key).

For #51461.

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

2 years agoreflect, runtime: drop RegabiArgs conditions
Cherry Mui [Wed, 16 Mar 2022 16:12:50 +0000 (12:12 -0400)]
reflect, runtime: drop RegabiArgs conditions

With the previous CL, internal/abi.IntArgRegs and FloatArgRegs
is controlled by RegabiArgs (or always enabled), so there is no
need to check for that goexperiment.

There are a few places we guard register-ABI specific code and
tests with the RegabiArgs flag. Switch to checking for the number
of argument registers instead.

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

2 years agoall: delete regabireflect goexperiment
Cherry Mui [Tue, 15 Mar 2022 17:27:53 +0000 (13:27 -0400)]
all: delete regabireflect goexperiment

regabireflect goexperiment was helpful in the register ABI
development, to control code paths for reflect calls, before the
compiler can generate register ABI everywhere. It is not necessary
for now. Drop it.

Change-Id: I2731197d2f496e29616c426a01045c9b685946a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/393362
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agosyscall: use bytealg.IndexByte in clen
Tobias Klauser [Fri, 18 Mar 2022 10:49:40 +0000 (11:49 +0100)]
syscall: use bytealg.IndexByte in clen

Change-Id: Ib3f92ea8371a13471acf9304dc9db66c0aae9bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/393756
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoA+C: update Changkun Ou's email
Changkun Ou [Fri, 26 Nov 2021 09:12:39 +0000 (10:12 +0100)]
A+C: update Changkun Ou's email

Add my current public email in both A+C, but keep old one too.
Add my @changkun.de email to CONTRIBUTORS.

Change-Id: Ic5a585582a5f5142fbdd0a132235c19f05d9e680
Reviewed-on: https://go-review.googlesource.com/c/go/+/367116
Run-TryBot: Changkun Ou <mail@changkun.de>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ben Shi <powerman1st@163.com>
2 years agoruntime: allow TestCtrlHandler to run in ConPTY
Nuno Cruces [Thu, 17 Mar 2022 16:38:00 +0000 (16:38 +0000)]
runtime: allow TestCtrlHandler to run in ConPTY

Fixes #51602. Previous test would not run in a pseudo-console (ConPTY).

New test avoids taskkill entirely by having the child request its own
console window be closed.

Verified that this runs locally (within a real console), over SSH
(within a pseudo-console), and that it breaks if #41884 were reverted.

Change-Id: If868b92ec36647e5d0e4107e29a2a6e048d35ced
GitHub-Last-Rev: b1421e4bed2dc729c266928f002b39374d7e391a
GitHub-Pull-Request: golang/go#51681
Reviewed-on: https://go-review.googlesource.com/c/go/+/392874
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>

2 years agosyscall: unskip TestDirentRepeat on freebsd
Tobias Klauser [Thu, 17 Mar 2022 23:01:24 +0000 (00:01 +0100)]
syscall: unskip TestDirentRepeat on freebsd

TestDirentRepeat fails on FreeBSD 11, but seems to pass on newer
versions. Go 1.18 is the last release to support FreeBSD 11 per
https://golang.org/doc/go1.18#freebsd and there are no FreeBSD 11
builders anymore. Thus unskip TestDirentRepeat to verify the issue is
indeed fixed on FreeBSD 12 and later.

For #31416

Change-Id: I189ef06719ff830ffe2e402c74a75874c9e5b97b
Reviewed-on: https://go-review.googlesource.com/c/go/+/393618
Trust: 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@golang.org>
2 years agoruntime/cgo: remove memset in _cgo_sys_thread_start on freebsd/arm
Tobias Klauser [Thu, 17 Mar 2022 21:39:53 +0000 (22:39 +0100)]
runtime/cgo: remove memset in _cgo_sys_thread_start on freebsd/arm

pthread_attr_init on freebsd properly initializes the pthread_attr,
there is no need to zero it before the call. The comment and code were
probably copied from the linux/arm implementation.

This aligns the implementation on freebsd/arm with the implementation on
other freebsd architectures.

Fixes #44248

Change-Id: If82ebb115b877b6c6f4862018a9419ba8d870f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/393617
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>

2 years agosyscall: optimize UTF16{,Ptr}FromString
Tobias Klauser [Thu, 17 Mar 2022 10:41:24 +0000 (11:41 +0100)]
syscall: optimize UTF16{,Ptr}FromString

Use bytealg.IndexByteString in UTF16FromString instead of an open-coded
loop.

Change-Id: I366448382f2d0adeca6b254131e0087a1f489258
Reviewed-on: https://go-review.googlesource.com/c/go/+/393614
Trust: 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@golang.org>
2 years agocrypto/x509: return err ans1.Marshal gives an error
cuiweixie [Tue, 1 Feb 2022 00:36:33 +0000 (00:36 +0000)]
crypto/x509: return err ans1.Marshal gives an error

Fixes #50663

Change-Id: I18754922bf139049443c0395eaa1606049df1331
GitHub-Last-Rev: 57ff5ddfe39c211ccff60aa74a30f97ddf7015fb
GitHub-Pull-Request: golang/go#50667
Reviewed-on: https://go-review.googlesource.com/c/go/+/379094
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoA+C: add PlanetScale, Inc.
Matt Layher [Thu, 17 Mar 2022 23:26:55 +0000 (19:26 -0400)]
A+C: add PlanetScale, Inc.

Change-Id: Ide2567dc66e55880b938b5814879f012c88159b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/393697
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Matt Layher <mdlayher@gmail.com>

2 years agoruntime: call testenv.MustHaveCGO in a couple of tests
Ian Lance Taylor [Wed, 16 Mar 2022 04:05:11 +0000 (21:05 -0700)]
runtime: call testenv.MustHaveCGO in a couple of tests

Fixes #51695

Change-Id: Icfe9d26ecc28a7db9040d50d4661cf9e8245471e
Reviewed-on: https://go-review.googlesource.com/c/go/+/392916
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agonet/rpc: reduce the execution of reflect and decode
fangguizhen [Thu, 27 May 2021 16:11:52 +0000 (16:11 +0000)]
net/rpc: reduce the execution of reflect and decode

Change-Id: Ief4b5e1c2d1002392901124c0694afe58c271573
GitHub-Last-Rev: e3b8a60377becfc9c30178d7ae6131d7a4b82dde
GitHub-Pull-Request: golang/go#46421
Reviewed-on: https://go-review.googlesource.com/c/go/+/323014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

2 years agoall: update vendored x dependencies for Go 1.19 development cycle
Heschi Kreinick [Wed, 16 Mar 2022 22:04:43 +0000 (18:04 -0400)]
all: update vendored x dependencies for Go 1.19 development cycle

Generated with x/build/cmd/updatestd.

Updates #36905.

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

2 years agocmd/doc: use the 'go' command from buildCtx.GOROOT, not whatever is in $PATH
Bryan C. Mills [Wed, 16 Mar 2022 18:45:42 +0000 (14:45 -0400)]
cmd/doc: use the 'go' command from buildCtx.GOROOT, not whatever is in $PATH

For #51483.

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

2 years agocmd/doc: use 'go env' to identify GOROOT if it isn't otherwise known
Bryan C. Mills [Thu, 10 Mar 2022 19:58:02 +0000 (14:58 -0500)]
cmd/doc: use 'go env' to identify GOROOT if it isn't otherwise known

Updates #51483.

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

2 years agoruntime/debug: do not require a GOROOT/src prefix in TestStack
Bryan C. Mills [Fri, 11 Mar 2022 04:57:57 +0000 (23:57 -0500)]
runtime/debug: do not require a GOROOT/src prefix in TestStack

When paths are trimmed, the reported file locations begin with the
package import path (not GOROOT/src).

Updates #51461.

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

2 years agocrypto/x509: fix Certificate.Verify crash
Brad Fitzpatrick [Thu, 17 Mar 2022 16:39:46 +0000 (09:39 -0700)]
crypto/x509: fix Certificate.Verify crash

(Primarily from Josh)

Fixes #51759

Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com>
Change-Id: I0a6f2623b57750abd13d5e194b5c6ffa3be6bf72
Reviewed-on: https://go-review.googlesource.com/c/go/+/393655
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan...
fanzha02 [Mon, 7 Jun 2021 06:24:45 +0000 (14:24 +0800)]
cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled

When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

Change-Id: I6281e77f6ba581d7008d610f0b24316078b6e746
Reviewed-on: https://go-review.googlesource.com/c/go/+/393315
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2 years agoRevert "cmd/compile: set conversions to unsafe.Pointer as an escaping operation when...
Fannie Zhang [Wed, 16 Mar 2022 12:08:54 +0000 (12:08 +0000)]
Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled"

This reverts commit 5fd0ed7aaf39f783ea6f505a3f2ac7d9da7cb03b.

Reason for revert: <The internal information in commit message is not removed.>

Change-Id: Id6845a9c8114ac71c56a1007a4d133a560a37fbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/393314
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2 years agotext/scanner: guard against installed IsIdentRune that accepts EOF
Robert Griesemer [Wed, 16 Mar 2022 04:44:37 +0000 (21:44 -0700)]
text/scanner: guard against installed IsIdentRune that accepts EOF

IsIdentRune may be installed by a client of the scanner. If the
installed function accepts EOF as a valid identifier rune, Scan
calls may not terminate.

Check for EOF when a user-defined IsIdentRune is used.

Fixes #50909.

Change-Id: Ib104b03ee59e2d58faa71f227c3b51ba424f7f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/393254
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoos: raise open file rlimit at startup
Russ Cox [Mon, 14 Mar 2022 15:27:46 +0000 (11:27 -0400)]
os: raise open file rlimit at startup

Some systems set an artificially low soft limit on open file count,
for compatibility with code that uses select and its hard-coded
maximum file descriptor (limited by the size of fd_set).

Go does not use select, so it should not be subject to these limits.
On some systems the limit is 256, which is very easy to run into, even
in simple programs like gofmt when they parallelize walking a file tree.

After a long discussion on go.dev/issue/46279, we decided the best
approach was for Go to raise the limit unconditionally for itself, and
then leave old software to set the limit back as needed. Code that
really wants Go to leave the limit alone can set the hard limit, which
Go of course has no choice but to respect.

Take 2, after CL 392415 was rolled back for macOS and OpenBSD failures.
The macOS failures should be handled by the new call to sysctl("kern.maxfilesperproc"),
and the OpenBSD failures are handled by skipping the test (and filing #51713).

Fixes #46279.

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

2 years agosyscall: allow EINVAL in TestSCMCredentials
Josh Bleecher Snyder [Wed, 16 Mar 2022 21:25:50 +0000 (14:25 -0700)]
syscall: allow EINVAL in TestSCMCredentials

This can occur on NixOS.

Change-Id: I0571b0cc5345d01396dca6a4116aa1024c390a5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393437
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agosyscall: call ABI0 exitsyscall on Plan 9/AMD64
Cherry Mui [Wed, 16 Mar 2022 23:21:49 +0000 (19:21 -0400)]
syscall: call ABI0 exitsyscall on Plan 9/AMD64

CL 376356 changes syscall.Syscall to call ABIInternal entersyscall
and exitsyscall. As mentioned in the CL description, it is
important to call entersyscall without ABI wrapper, but it is not
important to call exitsyscall this way. In fact, it is actually
problematic -- on Plan 9, syscall may clobber our fixed G register,
and we did not restore it. This CL changes it back to ABI0
exitsyscall, which will restore the G register through the wrapper.

Should fix Plan 9/AMD64 build.

Change-Id: I1f03d553f03e7b9f36d64686f20f2b2df0a0bf79
Reviewed-on: https://go-review.googlesource.com/c/go/+/393494
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: remove typecheckdef and Name.Walkdef
Matthew Dempsky [Wed, 16 Mar 2022 05:44:31 +0000 (22:44 -0700)]
cmd/compile: remove typecheckdef and Name.Walkdef

The only remaining use for typecheckdef after CL 393256 is to
typecheck the ONAME node that represents function names, so we might
as well just move that code into tcFunc instead.

Updates #51691.

Change-Id: Icbca51d4b0fb33c90faa95f16254c7171b171d8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393367
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agoall: update vendored golang.org/x/tools
Robert Findley [Wed, 16 Mar 2022 22:42:57 +0000 (18:42 -0400)]
all: update vendored golang.org/x/tools

Update the vendored golang.org/x/tools to pick up the fix for #51717.

This also picks up some changes to support Fuzz tests in the tests
analyzer, but they are currently still guarded by an internal flag.

Fixes #51717
Updates #36905

Change-Id: Ibcd5006624dd9cd9797c811093985e8775c57d51
Reviewed-on: https://go-review.googlesource.com/c/go/+/393373
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: allow noop conversions when comparing expressions
Keith Randall [Wed, 16 Mar 2022 16:24:06 +0000 (09:24 -0700)]
cmd/compile: allow noop conversions when comparing expressions

Allows mapclear optimization to trigger in more cases, including
some generic instantiations.

Fixes #51699

Change-Id: Ic54f7686e5fcb8fbcad640aa77ed326d7338b938
Reviewed-on: https://go-review.googlesource.com/c/go/+/393434
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/api: remove debug print
Russ Cox [Wed, 16 Mar 2022 16:27:07 +0000 (12:27 -0400)]
cmd/api: remove debug print

Left over from CL 392414.

Change-Id: I32ff1d660ba03d6c2005ad247e2129daf83aac04
Reviewed-on: https://go-review.googlesource.com/c/go/+/393361
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years agocmd/link: mark unexported methods for plugins
Cherry Mui [Wed, 16 Mar 2022 17:07:57 +0000 (13:07 -0400)]
cmd/link: mark unexported methods for plugins

When plugin is used, we already mark all exported methods
reachable. However, when the plugin and the host program share
a common package, an unexported method could also be reachable
from both the plugin and the host via interfaces. We need to mark
them as well.

Fixes #51621.

Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agocmd/compile: remove unused code from typecheckdef
Matthew Dempsky [Wed, 16 Mar 2022 06:07:41 +0000 (23:07 -0700)]
cmd/compile: remove unused code from typecheckdef

typecheckdef used to be used to handle references to package-level
declarations that hadn't yet been typechecked yet. It's no longer
needed, as the current IR frontends construct package-level
declarations with proper types upfront.

Exception: this code is still used for compiler-generated function
declarations, so that code needs to be kept. Eventually that code can
be moved elsewhere, but for now this CL makes it obvious that the rest
of the code paths really are unused.

Updates #51691.

Change-Id: I5322edb686aaf5dc4627288f3d9ba910a017b41d
Reviewed-on: https://go-review.googlesource.com/c/go/+/393256
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agocmd/compile: remove OIOTA
Matthew Dempsky [Wed, 16 Mar 2022 05:49:12 +0000 (22:49 -0700)]
cmd/compile: remove OIOTA

OIOTA used to be used to represent "iota" in the pre-typechecked IR,
before we knew whether it was safe to replace it with a constant
(because it could be redefined as a global symbol later).

However, now types2 handles constant folding, including handling of
"iota". So this can go away.

Updates #51691.

Change-Id: I3cec45b22c4c8f1c357dcc4003292c21ae32aa90
Reviewed-on: https://go-review.googlesource.com/c/go/+/393255
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agocmd/compile: Fatalf in Type.SetBroke(true) and Node.SetDiag(true)
Matthew Dempsky [Wed, 16 Mar 2022 05:34:19 +0000 (22:34 -0700)]
cmd/compile: Fatalf in Type.SetBroke(true) and Node.SetDiag(true)

Type.Broke and Node.Diag were used in the legacy typechecker to allow
reporting of multiple errors in a compilation unit, while suppressing
unhelpful follow-on errors. However, that's no longer needed now that
types2 handles (most) user-visible diagnostics.

Updates #51691.

Change-Id: I919c1598d8acebe5703939256bdca3e8d021f7ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/392918
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agocmd/compile: detect invalid NIH conversions within unified IR
Matthew Dempsky [Wed, 16 Mar 2022 05:25:36 +0000 (22:25 -0700)]
cmd/compile: detect invalid NIH conversions within unified IR

Unified IR currently relies on typecheck to diagnose invalid
//go:notinheap conversions, which prevents removing all of
its (otherwise) dead error-reporting code.

This CL updates the unified IR reader to instead proactively diagnose
these invalid conversions. This logic can be removed again once #46731
is implemented, but in the mean time it allows progress on #51691.

Updates #46731.
Updates #51691.

Change-Id: Ifae81aaad770209ec7a67bc10b55660f291e403e
Reviewed-on: https://go-review.googlesource.com/c/go/+/392917
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agogo/internal/srcimporter: use the 'go' command from the Importer's GOROOT
Bryan C. Mills [Fri, 11 Mar 2022 03:56:00 +0000 (22:56 -0500)]
go/internal/srcimporter: use the 'go' command from the Importer's GOROOT

We have no guarantee in general that there is any 'go' command in
$PATH at all, let alone the correct one. However, we can expect that
if a 'go' command is not in scope, the Importer should have a correct
GOROOT setting: otherwise, it would not be able to import anything
from 'std' at all.

Given that information, when we run `go tool cgo` we should use
GOROOT/bin/go specifically, not whatever 'go' we find in $PATH.

This fixes a failure in go/types.TestStdlib that manifests as a
timeout in when the 'go' command is not present in $PATH, due to
repeated retries for every package that transitively depends on
runtime/cgo.

For #51461

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

2 years agofmt, strconv: document use of Unicode replacement character in %q
Russ Cox [Tue, 8 Mar 2022 14:51:29 +0000 (09:51 -0500)]
fmt, strconv: document use of Unicode replacement character in %q

Fixes #51526.

Change-Id: I365a763454bd201f804df29f800416b1731b8ebc
Reviewed-on: https://go-review.googlesource.com/c/go/+/390436
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: ensure that Getwd returns absolute path
Kir Kolyshkin [Mon, 21 Feb 2022 22:54:05 +0000 (14:54 -0800)]
syscall: ensure that Getwd returns absolute path

Since Linux kernel 2.6.36, the pathname returned by the getcwd() system
call can be prefixed with the string "(unreachable)" in some cases [1].

Getcwd should return an absolute path, and doing otherwise is a
conformance issue; it also can be dangerous, since the path returned
can be an existing relative path.

Fix by returning ENOENT in case the path is not absolute. This is
essentially the same as what glibc does (since [2]).

[1] https://man7.org/linux/man-pages/man2/getcwd.2.html#BUGS
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94

Change-Id: I444c80eb3c836ff7d32c64c8b65d5112fa8c710f
Reviewed-on: https://go-review.googlesource.com/c/go/+/387174
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/txtar: bring back to main repo, for tests in std
Russ Cox [Sat, 29 Jan 2022 20:58:19 +0000 (15:58 -0500)]
internal/txtar: bring back to main repo, for tests in std

This used to be cmd/go/internal/txtar,
and then it was moved to golang.org/x/tools/txtar
and revendored from there into cmd/vendor/golang.org/x/tools/txtar.

We have a use for txtar in a new test in the standard library,
which cannot access cmd/vendor. But we also don't really want
to vendor it into the standard library as is, because that would
be the first vendoring of x/tools in std, and it would be better
to keep std separate from x/tools, even for testing.

Instead, since a little copying is better than a little dependency,
just make a copy in internal/txtar. The package does not change.

Having done that, replace the uses in cmd/go so that there's
only one copy in the main repo.

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

2 years agosyscall: call ABIInternal entersyscall on register ABI platforms
Cherry Mui [Fri, 7 Jan 2022 17:13:31 +0000 (12:13 -0500)]
syscall: call ABIInternal entersyscall on register ABI platforms

Currently, when register ABI is used, syscall.Syscall calls
entersyscall via a wrapper, so the actual entersyscall records the
caller PC and SP of the wrapper. At the point of the actual
syscall, the wrapper frame is gone, so the recorded PC and SP are
technically invalid. Furthermore, in some functions on some
platforms (e.g. Syscall9 on NetBSD/AMD64), that frame is
overwritten. If we unwind the stack from the recorded syscallpc
and syscallsp, it may go wrong. Fix this by calling the
ABIInternal function directly.

exitsyscall calls are changed as well. It doesn't really matter,
just changed for consistency.

Change-Id: Iead8dd22cf32b05e382414fef664b7c4c1719b7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/376356
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoruntime/pprof: do not require a GOROOT/src prefix in tests
Bryan C. Mills [Thu, 10 Mar 2022 15:41:54 +0000 (10:41 -0500)]
runtime/pprof: do not require a GOROOT/src prefix in tests

When paths are trimmed, the reported file locations begin with the
package import path (not GOROOT/src).

Updates #51461

Change-Id: Idbd408a02e8d03329d10e30b0b08263e69e66285
Reviewed-on: https://go-review.googlesource.com/c/go/+/391812
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan...
fanzha02 [Mon, 7 Jun 2021 06:24:45 +0000 (14:24 +0800)]
cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled

When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

CustomizedGitHooks: yes
Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87
Reviewed-on: https://go-review.googlesource.com/c/go/+/325629
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agocmd/link: default generic ABI compression for ELF
Meng Zhuo [Wed, 26 Jan 2022 02:23:48 +0000 (10:23 +0800)]
cmd/link: default generic ABI compression for ELF

This CL change all debug dwarf headers to generic ABI
"Compression header" for ELF
(http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header)

Fixes #50796

Change-Id: I188625e596f11cd120dbd802ac2d79341d5eaf41
Reviewed-on: https://go-review.googlesource.com/c/go/+/380755
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agogo/types: return Universe for (*Package)(nil).Scope()
Matthew Dempsky [Tue, 15 Feb 2022 01:20:48 +0000 (17:20 -0800)]
go/types: return Universe for (*Package)(nil).Scope()

Port of go.dev/cl/325469.

Fixes #46594.

Change-Id: I4bcdafecaa86885360599c204678871646bb221b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385997
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, cmd/compile: remove unused Interface.obj field
Matthew Dempsky [Wed, 2 Feb 2022 01:45:28 +0000 (17:45 -0800)]
go/types, cmd/compile: remove unused Interface.obj field

Change-Id: I6d0f629f9c7379074a03c8f13b99924d872872a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/385996
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agoreflect: avoid panic in reflect.Kind.String for negative Kind
Russ Cox [Tue, 15 Mar 2022 17:36:10 +0000 (13:36 -0400)]
reflect: avoid panic in reflect.Kind.String for negative Kind

Kind(-1).String() used to panic; let's not.

Change-Id: I1dfc0e3298beb37d77713d8327579bbde90dd156
Reviewed-on: https://go-review.googlesource.com/c/go/+/393015
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/asm: support -d=pctab flag
Cherry Mui [Fri, 25 Feb 2022 04:44:05 +0000 (23:44 -0500)]
cmd/asm: support -d=pctab flag

To debug PC data generation.

Change-Id: Id7ac8d607cc27ad52db490bd758c3a768c3e1df2
Reviewed-on: https://go-review.googlesource.com/c/go/+/388015
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoRevert "os: raise open file rlimit at startup"
Bryan Mills [Tue, 15 Mar 2022 17:49:01 +0000 (17:49 +0000)]
Revert "os: raise open file rlimit at startup"

This reverts CL 392415.

Reason for revert: new test is failing on at least darwin-amd64-10_14, darwin-amd64-10_15, and openbsd-arm64-jsing.

Updates #46279.

Change-Id: I2890b72f8ee74f31000d65f7d47b5bb0ed5d6007
Reviewed-on: https://go-review.googlesource.com/c/go/+/393016
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agocompress/gzip: add example of compressing reader
Ian Lance Taylor [Wed, 2 Mar 2022 23:49:27 +0000 (15:49 -0800)]
compress/gzip: add example of compressing reader

For #51092

Change-Id: If0a233651ac75f113569ddfffd056084f6092564
Reviewed-on: https://go-review.googlesource.com/c/go/+/389514
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: document that 'go run' strips debug info
Ian Lance Taylor [Mon, 14 Mar 2022 17:29:51 +0000 (10:29 -0700)]
cmd/go: document that 'go run' strips debug info

Change-Id: Ie7293a33862853ac56ee0a9017b201d8ff0ba1f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/392574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agoall: untab /* */ doc comments
Russ Cox [Thu, 3 Feb 2022 16:50:45 +0000 (11:50 -0500)]
all: untab /* */ doc comments

A long time ago, gofmt insisted on inserting tabs in /* */ comments
at the top level of the file, like this:

/*
Package doc comment.
*/
package p

Gofmt still insists on the tab for comments not at top level,
but it has relaxed the rules about top-level comments.
A few very old doc comments are indented, left over from the old rule.

We are considering formatting doc comments, and so to make
everything consistent, standardize on unindented doc comments
by removing tabs in the few doc comments that are still indented this way.

Also update some cmd/gofmt testdata to match.

Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/384261
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agointernal/cpu: don't run SSE3 disable test if GOAMD64>1
Keith Randall [Tue, 15 Mar 2022 15:56:07 +0000 (08:56 -0700)]
internal/cpu: don't run SSE3 disable test if GOAMD64>1

That feature can't be disabled if the microarchitectural version
requires it.

Change-Id: Iad8aaa8089d2f023e9ae5044c6da33224499f09b
Reviewed-on: https://go-review.googlesource.com/c/go/+/392994
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos: raise open file rlimit at startup
Russ Cox [Mon, 14 Mar 2022 15:27:46 +0000 (11:27 -0400)]
os: raise open file rlimit at startup

Some systems set an artificially low soft limit on open file count,
for compatibility with code that uses select and its hard-coded
maximum file descriptor (limited by the size of fd_set).

Go does not use select, so it should not be subject to these limits.
On some systems the limit is 256, which is very easy to run into, even
in simple programs like gofmt when they parallelize walking a file tree.

After a long discussion on go.dev/issue/46279, we decided the best
approach was for Go to raise the limit unconditionally for itself, and
then leave old software to set the limit back as needed. Code that
really wants Go to leave the limit alone can set the hard limit, which
Go of course has no choice but to respect.

Fixes #46279.

Change-Id: Id6107503437d47a870a41be25e822fc79cea08b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/392415
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/compile: fix PrefetchStreamed builtin implementation on PPC64
Archana R [Mon, 7 Mar 2022 07:54:14 +0000 (01:54 -0600)]
cmd/compile: fix PrefetchStreamed builtin implementation on PPC64

This CL fixes encoding of PrefetchStreamed on PPC64 to be consistent
with what is implemented on AMD64 and ARM64 platforms which is
prefetchNTA (prefetch non-temporal access). Looking at the definition
of prefetchNTA, the closest corresponding Touch hint (TH) value to be
used on PPC64 is 16 that states that the address is accessed in a
transient manner. Current usage of TH=8 may cause degraded
performance.

Change-Id: I393bf5a9b971a22f632b3cbfb4fa659062af9a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/390316
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: add race annotations to Windows ReadFile and WriteFile
Ian Lance Taylor [Tue, 15 Mar 2022 00:39:35 +0000 (17:39 -0700)]
syscall: add race annotations to Windows ReadFile and WriteFile

For #51618
Fixes #51673

Change-Id: Ie63408d62303293d80afed8d5cf1cb164a8abecc
Reviewed-on: https://go-review.googlesource.com/c/go/+/392774
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/internal/obj/arm64: add TRN1 and TRN2 instructions support
fanzha02 [Mon, 14 Mar 2022 02:40:25 +0000 (02:40 +0000)]
cmd/internal/obj/arm64: add TRN1 and TRN2 instructions support

Add test cases.

Fixes #51628

Change-Id: I433367d87e6bb5da5579c4be540079b92701c1fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/392294
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Fannie Zhang <Fannie.Zhang@arm.com>

2 years agocmd/internal/obj/arm64: refactor the handling of shifted RSP
eric fang [Tue, 20 Apr 2021 02:46:33 +0000 (02:46 +0000)]
cmd/internal/obj/arm64: refactor the handling of shifted RSP

Some arithmetic operation instructions such as ADD and SUB support two
formats of left shift (<<) operation, namely shifted register format and
extended register format. And the encoding, supported registers and shifted
amount are both different.

The assembly parser doesn't distinguish them and parses them into TYPE_SHIFT
type, because the parser can't tell them apart and in most cases extended
left-shift can be replaced by shifted left-shift. The only exception is
when the second source register or the destination register is RSP.

This CL converts this case into the extended format in the preprocess stage,
which helps to simplify some of the logic of the new assembler implementation
and also makes this situation look more reasonable.

Change-Id: I2cd7d2d663b38a7ba77a9fef1092708b8cb9bc3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/311709
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agotext/template/parse: allow space after continue or break
Rob Pike [Mon, 14 Mar 2022 23:21:08 +0000 (10:21 +1100)]
text/template/parse: allow space after continue or break

Trivial fix: We must skip space after either of these keywords
before we expect a closing delimiter.

Also delete the stutter-generating extra 'in' in the error message.
(See what I did there?)

Fixes #51670

Change-Id: If5415632c36eaac6699bdc0aa6ce18be956c9b53
Reviewed-on: https://go-review.googlesource.com/c/go/+/392615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: disable rewrite loop detector for deadcode-only changes
Keith Randall [Mon, 14 Mar 2022 22:17:43 +0000 (15:17 -0700)]
cmd/compile: disable rewrite loop detector for deadcode-only changes

We're guaranteed we won't infinite loop on deadcode-only changes,
because each change converts valid -> invalid, and there are only a
finite number of valid values.

The loops this test is looking for are those generated by rule
applications, so it isn't useful to check for loops when rules aren't
involved.

Fixes #51639

Change-Id: Idf1abeab9d47baafddc3a1197d5064faaf07ef78
Reviewed-on: https://go-review.googlesource.com/c/go/+/392760
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

2 years agocmd/api: require proposal # for new API features
Russ Cox [Mon, 14 Mar 2022 15:03:23 +0000 (11:03 -0400)]
cmd/api: require proposal # for new API features

Having the proposal numbers recorded in the API files
should help significantly when it comes time to audit
the new API additions at the end of each release cycle.

Change-Id: Id18e8cbdf892228a10ac17e4e21c7e17de5d4ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/392414
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/cpu: disallow disabling options that are required for microarch
Keith Randall [Thu, 10 Mar 2022 23:26:22 +0000 (15:26 -0800)]
internal/cpu: disallow disabling options that are required for microarch

e.g., if GOAMD64=v3, don't allow GODEBUG=cpu.XXX=off for XXX which
are required for v3.

Change-Id: Ib58a4c8b13c5464ba476448ba44bbb261218787c
Reviewed-on: https://go-review.googlesource.com/c/go/+/391694
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
2 years agogo/types, types2: use correct underlying type in union set computation
Robert Griesemer [Mon, 14 Mar 2022 17:45:16 +0000 (10:45 -0700)]
go/types, types2: use correct underlying type in union set computation

Fixes #51658.

Change-Id: Ibf415d7e12849b8f50b58d74713613d4e65bc347
Reviewed-on: https://go-review.googlesource.com/c/go/+/392575
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile: fix wrong dict param when getting dict type
Cuong Manh Le [Sat, 12 Mar 2022 17:04:46 +0000 (00:04 +0700)]
cmd/compile: fix wrong dict param when getting dict type

CL 338129 added getDictionaryType to get the dictionary type from the
specified dict param, but still using the one in info.dictParam, which
is wrong.

Fixes #51413

Change-Id: Ie13460c1e5751c4c5fc44479a44f6eed8b3b06e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/391994
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agocmd/go: use testGOROOT in TestListTemplateContextFunction
Bryan C. Mills [Thu, 10 Mar 2022 20:09:17 +0000 (15:09 -0500)]
cmd/go: use testGOROOT in TestListTemplateContextFunction

This test uses testgo to run 'go list', so it should use the correct
GOROOT for testgo. (This may be particularly relevant when the test
binary itself is build with -trimpath, in which case runtime.GOROOT()
is not valid.)

Updates #51483

Change-Id: I79b310f88e3a200122d6289073df1385e3e97cca
Reviewed-on: https://go-review.googlesource.com/c/go/+/391801
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>

2 years agogo/build: set PWD for go subcommands
Bryan C. Mills [Wed, 9 Mar 2022 22:17:40 +0000 (17:17 -0500)]
go/build: set PWD for go subcommands

Since these commands already include an explicit Env field,
they will not be fixed automatically by proposal #50599.

Change-Id: Ia8157a71cf0cfe208bdc0da9aef54be3d26c795f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391804
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>

2 years agodebug/buildinfo: use testenv.GoToolPath in tests instead of resolving "go" from ...
Bryan C. Mills [Thu, 10 Mar 2022 20:28:10 +0000 (15:28 -0500)]
debug/buildinfo: use testenv.GoToolPath in tests instead of resolving "go" from $PATH

Updates #37475.

Change-Id: I8c3237438da3e9521ce3be26a0b5d5ca36944b17
Reviewed-on: https://go-review.googlesource.com/c/go/+/391803
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>

2 years agocmd/compile: remove unified IR stmtTypeDeclHack
Cuong Manh Le [Sun, 13 Mar 2022 15:38:15 +0000 (22:38 +0700)]
cmd/compile: remove unified IR stmtTypeDeclHack

After CL 385998, unified IR quirks mode was gone, it's time to remove
stmtTypeDeclHack, too.

Change-Id: Id73dd1d6c11b91c0c6c6cbe85f1b06977a9876d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/392214
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agonet/url: add OmitHost bool to url.URL
Uzondu Enudeme [Wed, 9 Mar 2022 23:08:52 +0000 (00:08 +0100)]
net/url: add OmitHost bool to url.URL

Previously, myscheme:/path and myscheme:///path were treated as the same URL
although materially different. The distinction made clear by RFC 3986 sec. 5.3 where
a different recomposition behavior is expected when a URI reference has an undefined
host(authority) as in myscheme:/path vs. one with an empty host(authority)
as in myscheme:///path.

This change fixes the Parse/String roundtrip limitation for URLs with an undefined
host and a single slash.

Fixes #46059

Change-Id: I1b8d6042135513616374ff8c8dfb1cdb640f8efe
Reviewed-on: https://go-review.googlesource.com/c/go/+/391294
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/pprof: use syscall.RUSAGE_SELF
Tobias Klauser [Fri, 11 Mar 2022 07:20:55 +0000 (08:20 +0100)]
runtime/pprof: use syscall.RUSAGE_SELF

Change-Id: Idc37429de5a48e708eda868ca7fa26b28620bac0
Reviewed-on: https://go-review.googlesource.com/c/go/+/391854
Trust: 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@golang.org>
2 years agosyscall: add race annotations to Pread and Pwrite
Ian Lance Taylor [Sat, 12 Mar 2022 02:29:37 +0000 (18:29 -0800)]
syscall: add race annotations to Pread and Pwrite

Fixes #51618

Change-Id: Ife894d8c313dce8c4929f40fa0ac90a069f77a89
Reviewed-on: https://go-review.googlesource.com/c/go/+/391954
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agoencoding/hex: implement Decode with a lookup table
eh-steve [Fri, 11 Mar 2022 21:14:27 +0000 (21:14 +0000)]
encoding/hex: implement Decode with a lookup table

Implement hex decode using a 256 byte lookup table instead of branching logic.

In happy flow, uses 3x 64 byte (or 5x 32 byte) cache lines.

name             old time/op    new time/op    delta
Decode/256-64       223ns ± 3%     135ns ± 2%  -39.64%  (p=0.000 n=8+8)
Decode/1024-64      872ns ± 2%     512ns ± 2%  -41.25%  (p=0.000 n=8+8)
Decode/4096-64     3.43µs ± 1%    2.01µs ± 2%  -41.31%  (p=0.001 n=7+7)
Decode/16384-64    13.9µs ± 1%     8.0µs ± 1%  -42.69%  (p=0.000 n=8+7)

name             old speed      new speed      delta
Decode/256-64    1.15GB/s ± 3%  1.90GB/s ± 2%  +65.66%  (p=0.000 n=8+8)
Decode/1024-64   1.17GB/s ± 2%  2.00GB/s ± 2%  +70.22%  (p=0.000 n=8+8)
Decode/4096-64   1.20GB/s ± 1%  2.04GB/s ± 2%  +70.39%  (p=0.001 n=7+7)
Decode/16384-64  1.18GB/s ± 1%  2.06GB/s ± 1%  +74.49%  (p=0.000 n=8+7)

Also reduces amd64 object size by 766 bytes, despite the extra RODATA due to removal of `fromHexChar()` and duplicated inlined versions of it and simplification of `Decode()`.

Change-Id: I0988c7a30562ec154eff11db6e27954e0ce2b611
GitHub-Last-Rev: 64818018afc83ab07ec128a46aaea6a16f11400e
GitHub-Pull-Request: golang/go#51432
Reviewed-on: https://go-review.googlesource.com/c/go/+/390037
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/asm: add support for bdnz/bdz extended mnemonics on PPC64
Paul E. Murphy [Mon, 25 Oct 2021 21:51:55 +0000 (16:51 -0500)]
cmd/asm: add support for bdnz/bdz extended mnemonics on PPC64

Support BDNZ and BDZ mnemonics, they are commonly used
POWER instructions. The raw BC mnemonic is not easy
to read.

Likewise, cleanup code surrounding these changes.

Change-Id: I72f1dad5013f7856bd0dd320bfb17b5a9f3c69ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/390696
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/pprof, syscall: report MaxRSS on all unix platforms
Tobias Klauser [Thu, 10 Mar 2022 08:28:09 +0000 (09:28 +0100)]
runtime/pprof, syscall: report MaxRSS on all unix platforms

All unix platforms currently supported by Go provide the getrusage
syscall. On aix and solaris the Getrusage syscall wrapper is not
available yet, so add and use it to report MaxRSS in memory profiles.

Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/391434
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agospec: various minor clarifications
Robert Griesemer [Fri, 11 Mar 2022 01:40:01 +0000 (17:40 -0800)]
spec: various minor clarifications

- Allow for a type parameter as length/capacity to make.
- Be slightly more precise in prose for append.
- Add a couple of links.

Change-Id: Ib97e528bab1ab55d271beeeb53d9bb7a07047b9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/391754
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agospec: clean up intro and replace bolded text with prose
Robert Griesemer [Thu, 10 Mar 2022 02:36:53 +0000 (18:36 -0800)]
spec: clean up intro and replace bolded text with prose

- Remove "Draft" disclaimer. We're not done but the spec
  is in usable shape with respect to generics features.

- Remove section on "Earlier version" and fold information
  into the "Intro" section.

- Remove caveat for shifts: the rules for arithmetic operators
  on type parameters apply for them as well.

- Simply state that we don't support arguments of type parameter
  type for the built-ins real, imag, and complex.

Fixes #51182.

Change-Id: I6df1427de685cfe7055b64e91753aa7ebff70565
Reviewed-on: https://go-review.googlesource.com/c/go/+/391695
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/compile/internal/amd64: fix "missing objdump" skip in TestGoAMD64v1
Bryan C. Mills [Fri, 11 Mar 2022 04:30:07 +0000 (23:30 -0500)]
cmd/compile/internal/amd64: fix "missing objdump" skip in TestGoAMD64v1

The skip was erroneously applied to errors from the call to StdoutPipe
instead of Start, and even then was a bit too broad.

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

2 years agocmd/go: use the correct gofmt binary in TestScript/fmt_load_errors
Bryan C. Mills [Thu, 10 Mar 2022 22:21:40 +0000 (17:21 -0500)]
cmd/go: use the correct gofmt binary in TestScript/fmt_load_errors

Otherwise, this test may fail when GOROOT/bin is not in $PATH.

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

2 years agocmd/compile: fix re-export closure
Cuong Manh Le [Thu, 10 Mar 2022 16:41:56 +0000 (23:41 +0700)]
cmd/compile: fix re-export closure

For hidden closure built during stenciling to implement a function
instantiation, the function may come from other package, not local
package, which causes the ICE for code that re-export the hidden closure
after inlining.

To fix it, use the closure package for export writer when writing out
the closure itself.

Fixes #51423

Change-Id: I23b067ba14e2d602a0fc3b2e99bd9317afbe53ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/391574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>