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

47258 Commits

Author SHA1 Message Date
Dilyn Corner
9f2a71b6e7 make.bash: this change modifies Go to correctly select a dyamic linker
Alpine Linux is not the only musl-based Linux distribution. Checking for
/etc/alpine-release excludes many other distributions (Oasis, KISS,
Sabotage, sta.li). Not having the correct GO_LDSO set during go builds will
result in the wrong linker/loader on nonalpine musl systems for pie builds.
Instead, the dynamic loader should be checked for every system and set. This
results in the correct dynamic linker being found on glibc systems
(/lib/ld-linux-x86-64.so.2) and musl systems (/lib/ld-musl-x84_64.so.1).

Fixes #45034

Change-Id: I4c9389abc759aa34431dc6c781022636b81d6910
GitHub-Last-Rev: e17b9eb106
GitHub-Pull-Request: golang/go#45036
Reviewed-on: https://go-review.googlesource.com/c/go/+/301989
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
2021-03-19 22:32:03 +00:00
Bryan C. Mills
3b0d28808d cmd/go: assume Go 1.16 instead of Go 1.11 for dependencies that lack explicit 'go' directives
Fixes #45109
Updates #44976
Updates #36876

Change-Id: Icb00f8b6e0d4e076d82da1697e7058b9e7603916
Reviewed-on: https://go-review.googlesource.com/c/go/+/303229
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-19 19:59:56 +00:00
Bryan C. Mills
1c590661e7 testing: allow parallel-subtest goroutines to exit when the subtest is complete
Fixes #45127
Updates #38768

Change-Id: I7f41901d5bcc07741ac9f5f2a24d2b07ef633cb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/303330
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-19 17:34:25 +00:00
Antonio Garcia
482903150d syscall: fix typo in exec_windows_test.go
nothign -> nothing

Change-Id: I3f5cf20cc094d280f6cafa179eaefd745874dec1
GitHub-Last-Rev: a4cf42f275
GitHub-Pull-Request: golang/go#45118
Reviewed-on: https://go-review.googlesource.com/c/go/+/303269
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-19 17:31:59 +00:00
Michael Anthony Knyszek
836dbdb15b runtime: mark Windows' address-taken asm routines as ABIInternal
In the runtime there are Windows-specific assembly routines that are
address-taken via funcPC and are not intended to be called through a
wrapper. Mark them as ABIInternal so that we don't grab the wrapper,
because that will break in all sorts of contexts.

For #40724.
For #44065.

Change-Id: I12a728786786f423e5b229f8622e4a80ec27a31c
Reviewed-on: https://go-review.googlesource.com/c/go/+/302109
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-19 17:08:02 +00:00
Michael Anthony Knyszek
4deaa6a178 runtime: call nanotimeQPC from nanotime1 without a wrapper
This changes makes it so that nanotimeQPC calls nanotime1 without an ABI
wrapper by specifying the ABIInternal version directly. The reason why
this is necessary is because ABI wrappers typically require additional
stack space, and nanotimeQPC is used deep within nosplit contexts,
and with the ABI wrappers now enabled, this exhausts the stack guard
space held for nosplit functions. Rather than increase the stack guard,
we choose to do this.

For #40724.

Change-Id: Ia9173ca903335a9d6f380f57f4a45e49b58da6bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/303069
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-19 17:07:35 +00:00
Emmanuel T Odeke
e58fb90c75 net/http: make ExampleGet show StatusCode checks for non-1XX,2XX responses
Updates ExampleGet to show how to handle bad responses with non-1XX,2XX
status codes. Given that the canonical examples are copied, we need
to have them properly check against failures. This is a bug I've seen
often in the wild, that's exacerbated when for example unmarshalling
JSON or even protobufs, and no errors are returned by the decoders,
so code fails silently after making a request for example to a gateway
that they were unauthorized to access.

Fixes #39778

Change-Id: I1cd688f2fab47581c8cf228235d3662b4c8e4315
Reviewed-on: https://go-review.googlesource.com/c/go/+/299609
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-03-19 16:12:45 +00:00
Emmanuel T Odeke
a937729c2c net/http: mention NewRequestWithContext+Client.Do for custom contexts
Adds mentions of NewRequestWithContext and *Client.Do as prescriptions
for how to use a specified context.Context, to the docs of:
* (*Client).Get
* (*Client).Head
* (*Client).Post
* (*Client).PostForm
* Get
* Head
* Post
* PostForm

given that we can't remove those convenience functions, nor
change the method signatures, except for Go2.

Fixes #35562

Change-Id: I4859e6757e7f958c9067ac4ef15881cfba7d1f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/299610
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-03-19 16:11:47 +00:00
Paul E. Murphy
196b104bc1 cmd/internal/obj/ppc64: consolidate memory classifications
Several classifications exist only to help disambiguate an
implied register (i.e $0/R0 as the implied second register
argument when loading constants, or pseudo-registers used
exclusively by the assembler front-end).

The register determination is folded into getimpliedreg. The
classifications and their related optab entries are removed
or updated.

Change-Id: Iffb167aa9fa57fbc1a537c79fbdfb36cb38f9d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/301789
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
2021-03-19 14:27:48 +00:00
Agniva De Sarker
ed3ae9a340 cmd/doc: properly display interface methods
Previously, we used to call doc.ToText to print each comment
in a comment group attached to an interface method. This broke any
preformatted code block attached to the comment, and displayed everything
aligned to a single column. Additionally, the name of the interface
also wasn't displayed which didn't show which interface
the method belonged to.

To fix this, we print the entire interface node using format.Node
which takes care of displaying the comments correctly, and we also
filter out the methods that don't match, so that the method can be
displayed as belonging to an interface.

As an example, previously it would show:

// Comment before exported method.
//
// // Code block showing how to use ExportedMethod
// func DoSomething() error {
// ExportedMethod()
// return nil
// }
func ExportedMethod()  // Comment on line with exported method.

Now, it shows:

type ExportedInterface interface {
	// Comment before exported method.
	//
	//	// Code block showing how to use ExportedMethod
	//	func DoSomething() error {
	//		ExportedMethod()
	//		return nil
	//	}
	ExportedMethod() // Comment on line with exported method.

}

Fixes #43188

Change-Id: I28099fe4aab35e08049b2616a3506240f57133cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/279433
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
2021-03-19 03:05:26 +00:00
fanzha02
9136d958ab cmd/asm: complete the support for VDUP on arm64
"VMOV Vn.<T>[index], Vn" is equivalent to "VDUP Vn.<T>[index], Vn", and
the latter has a higher priority in the disassembler than the former.
But the assembler doesn't support to encode this combination of VDUP,
this leads to an inconsistency between assembler and disassembler.

For example, if we assemble "VMOV V20.S[0], V20" to hex then decode it,
we'll get "VDUP V20.S[0], V20".

  VMOV V20.S[0], V20 -> 9406045e -> VDUP V20.S[0], V20 -> error

But we cannot assemble this VDUP again.

Similar reason for "VDUP Rn, Vd.<T>". This CL completes the support for
VDUP.

This patch is a copy of CL 276092. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: I8f8d86cf1911d5b16bb40d189f1dc34b24416aaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/302929
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-19 01:38:59 +00:00
Tao Qingyun
6704843202 testing: update helperNames just before checking it
parent's helperNames has not been set when frameSkip called, moving
helperNames initilazing to frameSkip.

Fixes #44887

Change-Id: I5107c5951033e5e47d1ac441eac3ba5344a7bdc0
GitHub-Last-Rev: 44b90b2e2e
GitHub-Pull-Request: golang/go#45071
Reviewed-on: https://go-review.googlesource.com/c/go/+/302469
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-19 01:04:37 +00:00
Ian Lance Taylor
dcc96e4b94 io/ioutil: use correct Go version in redirection comments
Change-Id: I282f428137ca3360a58167c94e26f3dfdf59fb63
Reviewed-on: https://go-review.googlesource.com/c/go/+/302756
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-19 01:02:56 +00:00
Dan Scales
90b1ed1602 cmd/compile: get untyped constants working in generic functions
types2 will give us a constant with a type T, if an untyped constant is
used with another operand of type T (in a provably correct way). When we
substitute in the type args during stenciling, we now know the real type
of the constant. We may then need to change the BasicLit.val to be the
correct type (e.g. convert an int64Val constant to a floatVal constant).
Otherwise, later parts of the compiler will be confused.

Updated tests list.go and double.go with uses of untyped constants.

Change-Id: I9966bbb0dea3a7de1c5a6420f8ad8af9ca84a33e
Reviewed-on: https://go-review.googlesource.com/c/go/+/303089
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-18 22:18:32 +00:00
Austin Clements
095ba22597 cmd/internal/objabi,runtime: simplify sys.GOEXPERIMENT parsing
Previously, the runtime had to understand the full syntax of the
GOEXPERIMENT environment variable. Now, sys.GOEXPERIMENT is the
pre-processed experiment list produced by objabi, so we can simplify
the runtime parser.

Change-Id: I0d113a4347dde50a35b8b1f2b0110c88fe802921
Reviewed-on: https://go-review.googlesource.com/c/go/+/303049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 21:27:24 +00:00
Austin Clements
0c93b16d01 cmd: move experiment flags into objabi.Experiment
This moves all remaining GOEXPERIMENT flags into the objabi.Experiment
struct, drops the "_enabled" from their name, and makes them all bool
typed.

We also drop DebugFlags.Fieldtrack because the previous CL shifted the
one test that used it to use GOEXPERIMENT instead.

Change-Id: I3406fe62b1c300bb4caeaffa6ca5ce56a70497fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/302389
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-03-18 21:27:23 +00:00
Austin Clements
d3ab6b5049 test: switch fieldtrack test to use GOEXPERIMENT
Now that we can set GOEXPERIMENT at build time, we no longer need
-d=fieldtrack in the compiler to enabled field tracking at build time.
Switch the one test that uses -d=fieldtrack to use GOEXPERIMENT
instead so we can eliminate this debug flag and centralize on
GOEXPERIMENT.

Updates #42681.

Change-Id: I14c352c9a97187b9c5ec8027ff672d685f22f543
Reviewed-on: https://go-review.googlesource.com/c/go/+/302969
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-03-18 21:27:21 +00:00
Michael Anthony Knyszek
bdbba22404 reflect: add tests for reflect.Value.Call for the new ABI
This change adds tests for reflect.Value.Call for calling functions
using the new register-based ABI.

For #40724.

Change-Id: Ia9afd43e26dd80c7e36dd135a5b71acce8074801
Reviewed-on: https://go-review.googlesource.com/c/go/+/299269
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 21:22:04 +00:00
Elvina Yakubova
79d03ad739 runtime/pprof: move common code to writeProfileInternal function
This patch provides changes according to TODO. Since writeMutex and
writeBlock functions have a lot of code in common, it is better to
move this code to one function.

Change-Id: I81aaad067b0cb1647824909f3b5f6861add3a7ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/280152
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-03-18 21:10:31 +00:00
Paul E. Murphy
e4253cd023 cmd/link: Add section data slice to Archrelocvariant
PPC64 needs to preserve bits when applying some relocations. DS form
relocations must preserve the lower two bits, and thus needs to inspect
the section data as it streams out.

Similarly, the overflow checking requires inspecting the primary
opcode to see if the value is sign or zero extended.

The existing PPC64 code no longer works as the slice returned by
(loader*).Data is cleared as we layout the symbol and process
relocations.  This data is always the section undergoing relocation,
thus we can directly inspect the contents to preserve bits or
check for overflows.

Change-Id: I239211f7e5e96208673663b6553b3017adae7e01
Reviewed-on: https://go-review.googlesource.com/c/go/+/300555
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-18 19:15:12 +00:00
Robert Griesemer
b95e4b7850 go/types: minor simplification in assignableTo (cleanup)
Also, clarify doc string.

Change-Id: If1c5f8e29e2c2080dd899ef76196e97b7b992389
Reviewed-on: https://go-review.googlesource.com/c/go/+/302758
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-18 18:50:58 +00:00
Dan Scales
f47fab938e cmd/compile: remove unneeded calls to typecheck in noder2
Remove unneeded calls to typecheck in noder2 associated with g.use() and
g.obj(). These routines are already setting the types2-derived type
correctly for ONAME nodes, and there is no typechecker1-related
transformations related to ONAME nodes, other than making sure that
newly created closure variables have their type set.

Tested through normal -G=3 testing in all.bash (all of go/tests).

Change-Id: I1b790ab9948959685fca3a768401458201833671
Reviewed-on: https://go-review.googlesource.com/c/go/+/303029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-03-18 17:14:39 +00:00
Austin Clements
eaa1ddee84 all: explode GOEXPERIMENT=regabi into 5 sub-experiments
This separates GOEXPERIMENT=regabi into five sub-experiments:
regabiwrappers, regabig, regabireflect, regabidefer, and regabiargs.
Setting GOEXPERIMENT=regabi now implies the working subset of these
(currently, regabiwrappers, regabig, and regabireflect).

This simplifies testing, helps derisk the register ABI project,
and will also help with performance comparisons.

This replaces the -abiwrap flag to the compiler and linker with
the regabiwrappers experiment.

As part of this, regabiargs now enables registers for all calls
in the compiler. Previously, this was statically disabled in
regabiEnabledForAllCompilation, but now that we can control it
independently, this isn't necessary.

For #40724.

Change-Id: I5171e60cda6789031f2ef034cc2e7c5d62459122
Reviewed-on: https://go-review.googlesource.com/c/go/+/302070
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-03-18 16:51:27 +00:00
Austin Clements
c71acbfe83 test: make nosplit test invariant to ABI wrappers
Currently, the nosplit test disables ABI wrapper generation because it
generates a main.main in assembly, and so the ABI wrapper for calling
from runtime.main to main.main counts against the nosplit limit, which
cases some of the tests to fail.

Fix this by first entering ABI0 in a splittable context and then
calling from there into the test entry point, since this doesn't
introduce an ABI wrapper.

While we're here, this CL removes the test's check for the
framepointer experiment. That's now statically enabled, so it doesn't
appear in the experiment line, and enabling any other experiment
causes the test to think that the framepointer experiment *isn't*
enabled.

For #40724.

Change-Id: I6291eb9391f129779e726c5fc8c41b7b4a14eeb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302772
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-18 16:51:25 +00:00
Austin Clements
af4388aee1 cmd/internal/objabi: support boolean GOEXPERIMENTs
Currently, objabi exports GOEXPERIMENT flags as ints that are either 0
or 1. Since the dawn of time, there's been a comment saying that we
*could* support general integers here, but it's never happened and all
the "== 0" and "!= 0" and "== 1" are driving me crazy and are making
the code harder to read and maintain. Hence, this CL adds support for
boolean GOEXPERIMENT flags. We'll introduce some bool-typed flags in
the next CL.

Change-Id: I7813400db130a9b8f71a644fe7912808dbe645bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/302069
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:24 +00:00
Austin Clements
6461d74bf2 cmd/dist: build bootstrap without GOEXPERIMENT
Currently, dist attempts to build the bootstrap with the GOEXPERIMENT
set in the environment. However, the logic is incomplete and notably
requires a hack to enable the appropriate build tags for
GOEXPERIMENT=regabi. Without this hack, the build becomes skewed
between a compiler that uses regabi and a runtime that doesn't when
building toolchain2.

We could try to improve the GOEXPERIMENT processing in cmd/dist, but
it will always chase cmd/internal/objabi and it's quite difficult to
share the logic with objabi because of the constraints on building
cmd/dist.

Instead, we switch to building go_bootstrap without any GOEXPERIMENT
and only start using GOEXPERIMENT once we have a working, modern
cmd/go (which has all the GOEXPERIMENT logic in it). We also build
toolchain1 without any GOEXPERIMENT set, in case the bootstrap
toolchain is recent enough to understand build-time GOEXPERIMENT
settings.

As part of this, we make GOEXPERIMENT=none mean "no experiments". This
is necessary since, now that we support setting GOEXPERIMENT at build
time, we need an explicit way to say "ignore all baked-in experiments".

For #40724.

Change-Id: I115399579b766a7a8b2f352f7e5efea5305666cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/302050
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:22 +00:00
Austin Clements
06ca809410 cmd/internal/objabi: centralize GOEXPERIMENT parsing
objabi parses GOEXPERIMENT, but most of the consumers look at the raw
GOEXPERIMENT string that objabi gets from the environment. Centralize
this logic by only exposing the parsed GOEXPERIMENT value from objabi.
This sets us up for the next few changes. It also has the nice but
mostly useless property that the order of experiment names will be
canonicalized in build cache hashes.

After this, the only remaining place that looks at raw GOEXPERIMENT is
cmd/dist, which we'll fix in the next CL.

For #40724.

Change-Id: Idb150f848e17c184fae91372ca8b361591472f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/302049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:20 +00:00
Michael Matloob
b7cb92ad12 cmd/go: remove renameio package and its last usage
The last primary usage of renameio was the WriteFile in
modfetch.WriteDiskCache. Because it's not guaranteed that the fsync in
WriteDiskCache will eliminate file corruption, and it slows down tests
on Macs significantly, inline that last usage, removing the fsync.

Also, remove the uses of renameio.Pattern. The ziphash file is no
longer written to a temporary location before being copied to its
final location, so that usage can just be cut. The remaining use is
for the zipfile . Remove the first because the files are no longer
written using the pattern anyway, so that the pattern variable has no
effect. Replace it with a local pattern variable that is also passed
to os.CreateTemp.

Change-Id: Icf3adabf2a26c37b82afa1d07f821a46b30d69ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/301889
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 15:45:32 +00:00
Bryan C. Mills
e726e2a608 cmd/go: suppress errors for 'go get' of module paths that are also constrained-out packages
Fixes #33526

Change-Id: Iedd2d6dbe440499bf074ac632513319a22f2d648
Reviewed-on: https://go-review.googlesource.com/c/go/+/297009
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-18 14:43:33 +00:00
Andy Pan
6b6ea3271f cmd/go: use the global rooted path name
Change-Id: I4a450af5f35f0ad4e4652789f1eda4d3171610e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/302852
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
2021-03-18 14:20:08 +00:00
Cherry Zhang
db4adb1a9b cmd/link: print symbol versions in stack bound check
When the stack bound check fails, print the call chain with
symbol versions (along with the names). Now that we have ABI
wrappers and wrappers do consume stack space, it is clearer to
distinguish the wrappers vs. the underlying functions.

Change-Id: Id1d922e3e7934b31317f233aff3d9667b6ac90c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302869
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-18 14:09:57 +00:00
Richard Pickering
9de49ae01a crypto/rsa: correct EncryptOAEP doc comment
Fixes #44777

Corrected the documentation comment on the EncryptOAEP function from
'if a given public key is used to decrypt two types of messages' to
'if a given public key is used to encrypt two types of messages'.

Change-Id: I02aff90d0414960eae72352c0e4d8ba2e8f8eca6
GitHub-Last-Rev: ea28663f87
GitHub-Pull-Request: golang/go#45032
Reviewed-on: https://go-review.googlesource.com/c/go/+/301714
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-03-18 13:31:52 +00:00
Rabin Gaire
732ea4c2dc sort: add example tests for SearchFloat64s and SearchInts
Change-Id: I5fa4773467e3f515250deead72fdce3e4bd0973b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275457
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-03-18 08:25:24 +00:00
Joel Sing
c2d625168f cmd/compile,cmd/internal/obj/riscv: load >32-bit constants from memory for riscv64
Follow what MIPS does and load >32-bit constants from memory using two instructions,
rather than generating a four to six instruction sequence. This removes more than 2,500
instructions from the Go binary. This also makes it possible to load >32-bit constants
via a single assembly instruction, if required.

Change-Id: Ie679a0754071e6d8c52fe0d027f00eb241b3a758
Reviewed-on: https://go-review.googlesource.com/c/go/+/302609
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 04:17:00 +00:00
Joel Sing
42c25e65f3 cmd/compile: actually intrinsify runtime/internal/atomic.{And,Or}{8,} on RISCV64
Actually enable intrinsics for runtime/internal/atomic.{And,Or}{8,} on RISCV64.
This seems to have been lost when CL 268098 was rebased.

Change-Id: If072daa79c8964b186c127d5e065a7cc9e23ba27
Reviewed-on: https://go-review.googlesource.com/c/go/+/302229
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 03:52:02 +00:00
Joel Sing
6517844129 cmd/compile: use a single const MOV operand for riscv64
Most platforms only use a single MOV const operand - remove the MOV{B,H,W}const
operands from riscv64 and consistently use MOVDconst instead. The implementation
of all four is the same and there is no benefit gained from having multiple const
operands (in fact it requires a lot more rewrite rules).

Change-Id: I0ba7d7554e371a1de762ef5f3745e9c0c30d41ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/302610
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 03:42:56 +00:00
fanzha02
f5e6d3e879 cmd/compile: add rewrite rules for conditional instructions on arm64
This CL adds rewrite rules for CSETM, CSINC, CSINV, and CSNEG. By adding
these rules, we can save one instruction.

For example,

  func test(cond bool, a int) int {
    if cond {
      a++
    }
    return a
  }

Before:

  MOVD "".a+8(RSP), R0
  ADD $1, R0, R1
  MOVBU "".cond(RSP), R2
  CMPW $0, R2
  CSEL NE, R1, R0, R0

After:

  MOVBU "".cond(RSP), R0
  CMPW $0, R0
  MOVD "".a+8(RSP), R0
  CSINC EQ, R0, R0, R0

This patch is a copy of CL 285694. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: Ic1a79e8b8ece409b533becfcb7950f11e7b76f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/302231
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-03-18 01:46:58 +00:00
Robert Griesemer
51e4bb236c cmd/compile/internal/types2: delay recording types of untyped operands when checking against type parameters
Don't eagerly record the target type for an untyped operand if the
target type is just one of possibly many types in the type list of
a type parameter. Instead, record expression type only after we
checked that all types in the type list are ok.

Also, update assertion in Checker.recordTypeAndValue since (currently),
a type parameter is not considered a const type. We may change that,
eventually.

This is a temporary (but working) solution. Eventually we should
copy the approach taken in go/types.

Fixes #45096.

Change-Id: Icf61ee893aca6ead32bfc45ee5831572e672357b
Reviewed-on: https://go-review.googlesource.com/c/go/+/302755
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 00:23:25 +00:00
Robert Griesemer
2583c1b4df go/types: add test case for issue #45096
This verifies that issue #45096 is not an issue for go/types.

Updates #45096.

Change-Id: I4e987b5d4928f0c864d0d2c0379149443beb4d5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/302754
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-18 00:08:55 +00:00
Tobias Klauser
f38b6428a2 crypto/rand, internal/syscall/unix: add support for getentropy syscall on darwin
The getentropy syscall is available on macOS since version 10.12, which
is the minimum required version since Go 1.15.

Change-Id: I294259af0b11df9669e4dc5fa891d2f2f039d91a
Reviewed-on: https://go-review.googlesource.com/c/go/+/302489
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 22:14:28 +00:00
Ian Lance Taylor
f82ce7fb23 cmd/link: improve nonexistent package error message
Change-Id: I207541efa6a34bc21e7a00584376622b59e2bf6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302749
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 21:48:40 +00:00
Bryan C. Mills
7e00049b55 cmd/go: only add a 'go' directive to the main module when the go.mod file will be written
Then, write the 'go.mod' file with that version before further
processing. That way, if the command errors out due to a change in
behavior, the reason for the change in behavior will be visible in the
file diffs.

If the 'go.mod' file cannot be written (due to -mod=readonly or
-mod=vendor), assume Go 1.11 instead of the current Go release.
(cmd/go has added 'go' directives automatically, including in 'go mod
init', since Go 1.12.)

For #44976

Change-Id: If9d4af557366f134f40ce4c5638688ba3bab8380
Reviewed-on: https://go-review.googlesource.com/c/go/+/302051
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-03-17 21:24:05 +00:00
Andrey Bokhanko
4313c28861 cmd/cgo: check whether C compiler exists
Currently we print a cryptic message if a C compiler doesn't exist.
This patch adds more graceful handling.

Fixes #44271

Change-Id: I44f16ef6eb2853fee22fa1d996e41ec6c9ee82f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/301249
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-03-17 20:29:22 +00:00
Andy Pan
a5df88355c time: check int64 overflow in Time.addSec
Change-Id: Ibbed54239228e7ea31ef5978d427425899c3b943
Reviewed-on: https://go-review.googlesource.com/c/go/+/300890
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Baokun Lee <bk@golangcn.org>
2021-03-17 19:48:52 +00:00
Ian Lance Taylor
5423f6023c test: add bug that failed when run with gccgo
Change-Id: Ie52d70d2ae8a21acacf0745a4093650b03ac43f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302371
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-17 19:15:18 +00:00
Cherry Zhang
8628bf9a97 cmd/compile: resurrect clobberdead mode
This CL resurrects the clobberdead debugging mode (CL 23924).
When -clobberdead flag is set (TODO: make it GOEXPERIMENT?), the
compiler inserts code that clobbers all dead stack slots that
contains pointers.

Mark windows syscall functions cgo_unsafe_args, as the code
actually does that, by taking the address of one argument and
passing it to cgocall.

Change-Id: Ie09a015f4bd14ae6053cc707866e30ae509b9d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/301791
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-17 17:50:50 +00:00
Rob Findley
0bd308ff27 go/parser: avoid formatting a panic message if an assertion succeeds
tryResolve is an extremely hot method on the parser. Eliminating this
formatting led to a 20% performance improvement in BenchmarkParse.

Change-Id: Idf8850404bd72d45d1351356427a85086422ea68
Reviewed-on: https://go-review.googlesource.com/c/go/+/302629
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-17 17:13:50 +00:00
Dan Scales
70d54df4f6 cmd/compile: getting more built-ins to work with generics
For Builtin ops, we currently stay with using the old
typechecker to transform the call to a more specific expression
and possibly use more specific ops. However, for a bunch of the
ops, we delay calling the old typechecker if any of the args have
type params, for a variety of reasons.

In the near future, we will start creating separate functions that do
the same transformations as the old typechecker for calls, builtins,
indexing, comparisons, etc. These functions can then be called at noder
time for nodes with no type params, and at stenciling time for nodes
with type params.

Remove unnecessary calls to types1 typechecker for most kinds of
statements (still need it for SendStmt, AssignStmt, ReturnStmt, and
SelectStmt). In particular, we don't need it for RangeStmt, and this
avoids some complaints by the types1 typechecker on generic code.

Other small changes:
 - Fix check on whether to delay calling types1-typechecker on type
   conversions. Should check if HasTParam is true, rather than if the
   type is directly a TYPEPARAM.

 - Don't call types1-typechecker on an indexing operation if the left
   operand has a typeparam in its type and is not obviously a TMAP,
   TSLICE, or TARRAY. As above, we will eventually have to create a new
   function that can do the required transformations (for complicated
   cases) at noder time or stenciling time.

 - Copy n.BuiltinOp in subster.node()

 - The complex arithmetic example in absdiff.go now works.

 - Added new tests double.go and append.go

 - Added new example with a new() call in settable.go

Change-Id: I8f377afb6126cab1826bd3c2732aa8cdf1f7e0b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/301951
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-17 16:53:00 +00:00
Johan Brandhorst
2f3db220d1 crypto/tls: remove flaky cancellation test
This will be reintroduced again once the source of the
flakiness has been determined and fixed.

Fixes #45084

Change-Id: I6677b27fcd71e8c9bb8edbe8e3be70e5a271ebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/302569
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 16:19:21 +00:00
Agniva De Sarker
72b501cb03 compress/lzw: add Reset method to Reader and Writer
We add a Reset method which clears any internal state of an encoder
or a decoder to let it be reused again as a new Writer or Reader respectively.

We also export the encoder and decoder structs, renaming them
to be Reader and Writer, and we guarantee that the underlying types
from the constructors will always be Reader and Writer respectively.

Benchmark results by reusing the encoder:
on cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz

name                 time/op
Decoder/1e4-8          93.6µs ± 1%
Decoder/1e-Reuse4-8    87.7µs ± 1%
Decoder/1e5-8           877µs ± 1%
Decoder/1e-Reuse5-8     860µs ± 3%
Decoder/1e6-8          8.79ms ± 1%
Decoder/1e-Reuse6-8    8.82ms ± 4%
Encoder/1e4-8           168µs ± 2%
Encoder/1e-Reuse4-8     160µs ± 1%
Encoder/1e5-8          1.64ms ± 1%
Encoder/1e-Reuse5-8    1.61ms ± 2%
Encoder/1e6-8          16.2ms ± 6%
Encoder/1e-Reuse6-8    15.8ms ± 2%

name                 speed
Decoder/1e4-8         107MB/s ± 1%
Decoder/1e-Reuse4-8   114MB/s ± 1%
Decoder/1e5-8         114MB/s ± 1%
Decoder/1e-Reuse5-8   116MB/s ± 3%
Decoder/1e6-8         114MB/s ± 1%
Decoder/1e-Reuse6-8   113MB/s ± 5%
Encoder/1e4-8        59.7MB/s ± 2%
Encoder/1e-Reuse4-8  62.4MB/s ± 1%
Encoder/1e5-8        61.1MB/s ± 1%
Encoder/1e-Reuse5-8  62.0MB/s ± 2%
Encoder/1e6-8        61.7MB/s ± 5%
Encoder/1e-Reuse6-8  63.4MB/s ± 2%

name                 alloc/op
Decoder/1e4-8          21.8kB ± 0%
Decoder/1e-Reuse4-8     50.0B ± 0%
Decoder/1e5-8          21.8kB ± 0%
Decoder/1e-Reuse5-8     70.4B ± 2%
Decoder/1e6-8          21.9kB ± 0%
Decoder/1e-Reuse6-8      271B ± 3%
Encoder/1e4-8          77.9kB ± 0%
Encoder/1e-Reuse4-8    4.17kB ± 0%
Encoder/1e5-8          77.9kB ± 0%
Encoder/1e-Reuse5-8    4.27kB ± 0%
Encoder/1e6-8          77.9kB ± 0%
Encoder/1e-Reuse6-8    5.22kB ± 0%

name                 allocs/op
Decoder/1e4-8            2.00 ± 0%
Decoder/1e-Reuse4-8      1.00 ± 0%
Decoder/1e5-8            2.00 ± 0%
Decoder/1e-Reuse5-8      1.00 ± 0%
Decoder/1e6-8            2.00 ± 0%
Decoder/1e-Reuse6-8      1.00 ± 0%
Encoder/1e4-8            3.00 ± 0%
Encoder/1e-Reuse4-8      2.00 ± 0%
Encoder/1e5-8            3.00 ± 0%
Encoder/1e-Reuse5-8      2.00 ± 0%
Encoder/1e6-8            3.00 ± 0%
Encoder/1e-Reuse6-8      2.00 ± 0%

Fixes #26535

Change-Id: Icde613fea6234a5bdce95f1e49910f5687e30b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/273667
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2021-03-17 07:01:00 +00:00