1
0
mirror of https://github.com/golang/go synced 2024-09-29 21:24:30 -06:00
Commit Graph

43299 Commits

Author SHA1 Message Date
Bryan C. Mills
e2a9ea035d cmd/go/internal/modload: suppress the 'go mod init' hint for GOROOT more aggressively
Previously, we suppressed a `to create a module there, run: … go mod
init' warning only if the config file itself (such as .git/config) was
found in GOROOT. However, our release tarballs don't include the
.git/config, so that case was not encountered, and the warning could
occur based on a config file found in some parent directory (outside
of GOROOT entirely).

Instead, skip the directory walk completely if the working directory
is anywhere in GOROOT.

Fixes #34191

Change-Id: I9f774901bfbb53b700407c4882f37d6339d023fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/223340
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-03-13 20:43:12 +00:00
Josh Bleecher Snyder
cbcb031fe8 cmd/compile: more minor cleanup in shortcircuitBlock
Continue to simplify, rename for clarity,
improve docs, and reduce variable scope.

This is in preparation for this function becoming
more complicated.

Passes toolstash-check.

Updates #37608

Change-Id: I630a4e07c92297c46d18aea69ec29852d6371ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/222919
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:43:47 +00:00
Josh Bleecher Snyder
4ad643d208 cmd/compile: remove loop in shortcircuit
shortcircuitBlock contained a loop to handle blocks like

b: <- p q
  v = Phi true false
If v -> t u

in a single execution.
This change makes shortcircuitBlock do it in two instead,
one for each constant phi arg.

Motivation: Upcoming changes will expand the range of
blocks that the shortcircuit pass can handle.
Those changes need to understand what the CFG
will look like after the rewrite in shortcircuitBlock.
Making shortcircuitBlock do only a single CFG
modification at a time significantly simplifies that code.

In theory, this is less efficient, but not measurably so.
There is minor, unimportant churn in the generated code.

Updates #37608

Change-Id: Ia6dce7011e3e19b546ed1e176bd407575a0ab837
Reviewed-on: https://go-review.googlesource.com/c/go/+/222918
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:42:14 +00:00
Josh Bleecher Snyder
74bc90a9a8 cmd/compile: rename a local variable in shortcircuitBlock
v is pretty generic. Subsequent changes will make this function
more complicated, so rename it now, independently, for easier review.

v is the control value for the block (or its underlying phi);
call it ctl.

Passes toolstash-check.

Updates #37608

Change-Id: I3fbae3344f1c95aff0a69c1e4f61ef637a54774e
Reviewed-on: https://go-review.googlesource.com/c/go/+/222917
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:41:40 +00:00
Cherry Zhang
0e06775eeb [dev.link] cmd/link: don't truncate external relocation type
In CL 222244, we store external relocations in the same format as
Go object files. In Go object file format, the relocation type is
a uint8. However, for external relocations the type may not
always fit in a uint8. Truncating it will result in a bad
relocation. Fix this by storing the external reloc type on the
side. (An alternative is to extend the Go object file format to
use a uint16, but it is not necessary for Go relocations and
will waste some binary size.)

Fix ARM build.

Change-Id: I343e240d38ee0e2cc91e0e7754d03b19b525a014
Reviewed-on: https://go-review.googlesource.com/c/go/+/223338
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 19:28:06 +00:00
Russ Cox
be72e3c3ff misc/spectre: add spectre index test
Test for CL 222660.

Change-Id: I1dae41a9746dfc4144a0d29c02201de8ecd216fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/222978
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:06:00 +00:00
Russ Cox
fc8a6336d1 cmd/asm, cmd/compile, runtime: add -spectre=ret mode
This commit extends the -spectre flag to cmd/asm and adds
a new Spectre mitigation mode "ret", which enables the use
of retpolines.

Retpolines prevent speculation about the target of an indirect
jump or call and are described in more detail here:
https://support.google.com/faqs/answer/7625886

Change-Id: I4f2cb982fa94e44d91e49bd98974fd125619c93a
Reviewed-on: https://go-review.googlesource.com/c/go/+/222661
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:05:54 +00:00
Russ Cox
877ef86bec cmd/compile: add spectre mitigation mode enabled by -spectre
This commit adds a new cmd/compile flag -spectre,
which accepts a comma-separated list of possible
Spectre mitigations to apply, or the empty string (none),
or "all". The only known mitigation right now is "index",
which uses conditional moves to ensure that x86-64 CPUs
do not speculate past index bounds checks.

Speculating past index bounds checks may be problematic
on systems running privileged servers that accept requests
from untrusted users who can execute their own programs
on the same machine. (And some more constraints that
make it even more unlikely in practice.)

The cases this protects against are analogous to the ones
Microsoft explains in the "Array out of bounds load/store feeding ..."
sections here:
https://docs.microsoft.com/en-us/cpp/security/developer-guidance-speculative-execution?view=vs-2019#array-out-of-bounds-load-feeding-an-indirect-branch

Change-Id: Ib7532d7e12466b17e04c4e2075c2a456dc98f610
Reviewed-on: https://go-review.googlesource.com/c/go/+/222660
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-13 19:05:46 +00:00
Cherry Zhang
440852c464 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: I2ae070c60c011779a0f0a1344f5b6d45ef10d8a1
2020-03-13 14:45:05 -04:00
Cherry Zhang
e5f7a8334a [dev.link] cmd/link: convert dope to new style
Also convert a manually managed array to slice.

Change-Id: I7d0dd3d5f569ab237893f589b6022f0f351bca16
Reviewed-on: https://go-review.googlesource.com/c/go/+/223337
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 17:26:32 +00:00
Keith Randall
d84cbec890 cmd/compile: convert 386 port to use addressing modes pass
Update #36468

Change-Id: Idfdb845d097994689be450d6e8a57fa9adb57166
Reviewed-on: https://go-review.googlesource.com/c/go/+/222782
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-03-13 17:00:54 +00:00
zikaeroh
c3b9042132 cmd/cover: skip function declarations with blank names
Function declarations with blank ("_") names do not introduce a binding,
and therefore cannot be referenced or executed (in fact, they do not
make it into the final compiled binary at all). As such, counters
defined while annotating their bodies will always be zero.

These types of functions are commonly used to create compile-time
checks (e.g., stringer) which are not expected to be executed.

Skip over these functions when annotating a file, preventing the unused
counters from being generated and appearing as uncovered lines in
coverage reports.

Fixes #36264

Change-Id: I6b516cf43c430a6248d68d5f483a3902253fbdab
Reviewed-on: https://go-review.googlesource.com/c/go/+/223117
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-13 14:29:27 +00:00
zikaeroh
c6bcdeafd2 cmd/go: check for 'svn' binary in PATH in TestAccidentalGitCheckout
This test requires subversion to run, but does not check to see if it's
available before running as it does for git.

Call testenv.MustHaveExecPath to check beforehand to allow the test to
be skipped if the svn binary does not exist.

Change-Id: I16ae104621b221fc6e96f6c7dcd71bf406caa0c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/223082
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-13 13:52:49 +00:00
Lynn Boger
9d67a94217 cmd/internal/obj/ppc64: clean up some opcodes
This does some clean up of the ppc64 opcodes to remove names
from the opcode list that don't actually assemble. At one time
names were added to this list to represent opcode "classes" to
organize other opcodes that have the same set of operand
combinations. Since this is not documented, it is confusing as
to which opcodes can be used in an asm file and which can't, and
which opcodes should be supported in the disassembler. It is
clearer for the user if the list of Go opcodes are all opcodes
that can be assembled with names that match the ppc64 opcode
where possible.

I found this when trying to use Go opcode XXLAND in an asm file
which seems like it should map to ppc64 xxland but when used it
gets this error:

go tool asm test_xxland.s
asm: bad r/r, r/r/r or r/r/r/r opcode XXLAND
asm: assembly failed

This change removes the opcodes that are only used for opcode
"classes" and fixes the case statement where they are referenced.
This also fixes XXLAND and XXPERM which are opcodes that should
assemble to their corresponding ppc64 opcode but do not.

Change-Id: I52300db6b22f7f8b3dd3491c3f35a384b943352c
Reviewed-on: https://go-review.googlesource.com/c/go/+/223138
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-13 11:41:22 +00:00
Cherry Zhang
cf5c718cba [dev.link] cmd/link: experiment new reloc accessors in deadcode pass
There is a small speedup:

(linking cmd/compile)

name       old time/op    new time/op    delta
Deadcode     57.1ms ± 1%    53.5ms ± 1%   -6.44%  (p=0.008 n=5+5)

With this, we don't need a slice to read the relocations, reduce
some allocations.

name       old alloc/op   new alloc/op   delta
Deadcode     4.16MB ± 0%    3.84MB ± 0%   -7.85%  (p=0.008 n=5+5)

Change-Id: Icd41c05682ba3f293a8cb9d2fe818e39d7276e5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/222244
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 01:19:15 +00:00
Cherry Zhang
c951514da9 [dev.link] cmd/internal/goobj2, cmd/link: experiment another way of accessing relocations
Use a different mechanism to access relocations from the object
files, and use it in the stack bounds check pass. This shows some
speedup.

(linking cmd/compile)
Dostkcheck     76.9ms ± 1%    55.1ms ± 1%  -28.36%  (p=0.008 n=5+5)

Change-Id: I2ac42da515dccd64719fb557ffff6cdc69e4319b
Reviewed-on: https://go-review.googlesource.com/c/go/+/222240
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 01:04:29 +00:00
Ian Lance Taylor
85e87f9d81 time: stop referring to timerproc in comment
The timerproc function has been removed.

Fixes #37774

Change-Id: Ice5e1d8fec91cd6ee7f032e0d21e8315a26bc6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/222783
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2020-03-13 00:19:08 +00:00
Johan Jansson
1f231d74f6 runtime: emit more specific errors from checkptr
Update error messages for pointer alignment checks and pointer
arithmetic checks so that each type of error has a unique error
message.

Fixes #37488

Change-Id: Ida2c2fa3f041a3307d665879a463f9e8f2c1fd03
Reviewed-on: https://go-review.googlesource.com/c/go/+/223037
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 23:45:51 +00:00
Ian Lance Taylor
5d70cb0667 runtime: leave cleantimers early if G is being preempted
The cleantimers can run for a while in some unlikely cases.
If the GC is trying to preempt the G, it is forced to wait as the
G is holding timersLock. To avoid introducing a GC delay,
return from cleantimers if the G has a preemption request.

Fixes #37779

Change-Id: Id9a567f991e26668e2292eefc39e2edc56efa4e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/223122
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-12 23:17:02 +00:00
David Chase
29b36a88ab cmd/objdump: guard against out-of-range lines from directives.
//line bogo.go:9999999 will cause 'go tool objdump' to crash
unless bogo.go has that many lines.  Guard the array index
and return innocuous values (nil, nil) from the file cache.

Fixes #36683

Change-Id: I4a9f8444dc611654d270cc876e8848dfd2f84770
Reviewed-on: https://go-review.googlesource.com/c/go/+/223081
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-12 20:40:54 +00:00
Walt Della
e221a75dea cmd/go: improve pseudo-version timestamp error
The previous "invalid pseudo-version: does not match version-control
timestamp" error message used a different timestamp format than the
format used in go.mod and go.sum. For cut-and-paste-ability this patch
makes the two consistent.

Fixes #36974

Change-Id: I21f344ab9898cc584c0bcf4a75d74275a703c650
Reviewed-on: https://go-review.googlesource.com/c/go/+/217437
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-03-12 20:00:02 +00:00
Than McIntosh
ad92148058 [dev.link] cmd/link: demote DWARF line symbols to anonymous aux
Convert DWARF .debug_line symbols to anonymous aux syms, so as
to save space in object files and reduce the number of symbols
that have to be added to the linker's lookup tables.

Change-Id: I5b350f036e21a7a7128cb08148ab7c243aaf0d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/223018
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 18:56:25 +00:00
Than McIntosh
c44af2d4a2 [dev.link] cmd/internal/obj: add dump of aux symbols for -S=2
For compiler developers interested in seeing DWARF generation details,
this patch provides symbol "debug asm" dumps for DWARF aux symbols
when -S=2 is in effect.

Change-Id: I5a0b6b65ce7b708948cbbf23c6b0d279bd4f8d9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/223017
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 18:56:18 +00:00
Than McIntosh
8634642f9a [dev.link] cmd/link: demote dwarf {range,loc} sub-symbols to aux
When the compiler emits DWARF for a function F, in addition to the
text symbol for F, it emits a set of sibling or child symbols that
carry the various DWARF bits for F (for example, go.info.F,
go.ranges.F, go.loc.F, and so on).

Prior to the linker modernization work, name lookup was the way you
made your way from a function symbol to one of its child DWARF
symbols. We now have a new mechanism (aux symbols), so there is really
no need for the DWARF sub-symbols to be named or to be dupok.

This patch converts DWARF "range" and "loc" sub-symbols to be pure aux
syms: unnamed, and connected to their parent text symbol only via aux
data. This should presumably have performance benefits in that we add
fewer symbols to the linker lookup tables.

Other related DWARF sub-symbols (ex: go.line.*) will be handled in a
subsequent patch.

Change-Id: Iae3ec2d42452962d4afc1df4a1bd89ccdeadc6e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/222673
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 18:56:09 +00:00
Than McIntosh
a6ae6d35e6 [dev.link] cmd/link: remove unnecessary file processing from writelines
The linker DWARF-gen's line table writing routine contains a loop that
walks all abstract function DIEs looking for files that aren't
referenced in concrete function DIEs. Turns out this loop is no longer
necessary, most likely because the compiler emits an explicit DWARF
file table into the object file.

This patch removes the offending loop. This is a prelude to some
additional work that will hopefully get rid of file renumbering in
writelines altogether (still WIP).

Change-Id: I3b3a9acce1bae7dda878ab6de2d3436de302712e
Reviewed-on: https://go-review.googlesource.com/c/go/+/223145
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-12 18:36:55 +00:00
Bryan C. Mills
c4113b64c2 cmd/go: fix test failures with -count=2
In each test, either set the -n flag to avoid writing build artifacts
to the cache, or set GOCACHE explicitly to point to a clean cache.

Tested manually with 'go test -count=2 cmd/go'.

Fixes #37820

Change-Id: I24403e738b1a10d5fe9dc8d98ef27a76ebe2704a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223140
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 17:46:03 +00:00
David Chase
040855e39b test: restore no-gogcflags build shortcut, save time
With a clean cache on a laptop
before change
time go run run.go -- . fixedbugs
  real	2m10.195s
  user	3m16.547s
  sys	1m52.939s

Or, before, directly after make.bash (the actual use case we care about)
time go run run.go -- . fixedbugs
  real	2m8.704s
  user	3m12.327s
  sys	1m49.123s

after change
time go run run.go -- . fixedbugs
  real	1m38.915s
  user	2m38.389s
  sys	1m8.490s

Tests, fortunately, still seem to pass.

Latest version of this takes the slow route for cross-compilation, which includes wasm.

Change-Id: Iad19951612defa96c4e9830bce920c5e8733834a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223083
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-12 17:37:13 +00:00
Cherry Zhang
2a5bf32638 [dev.link] cmd/link: refer to .got instead of .got.plt on S390X
S390X uses .got instead of .got.plt. It is changed accidentally
in CL 222977. This CL fixes it.

Also, on S390X, we need to set the relocation "variant" of
R_PCREL relocation. In the old code AddPCRelPlus has the magic.
Here we use the equivalent R_PCRELDBL, as the loader doesn't
have variant.

Fix S390X build.

Change-Id: I388e16f02a0568d70287aa9a132fd42b442e3905
Reviewed-on: https://go-review.googlesource.com/c/go/+/223143
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 15:50:31 +00:00
Bryan C. Mills
938ad552cd cmd/go: add missing newline to "go" line in cache key
This was missed in CL 223139. It doesn't seem to affect correctness,
but might be confusing if we need to debug the cache key.

Updates #37804

Change-Id: I979efa68381cf79a7e246581510c90a724be6cd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/223144
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 15:06:36 +00:00
Bryan C. Mills
c95708462f cmd/go: include the go language version in cache keys
Fixes #37804

Change-Id: I4381dc5c58cfd467506d3d73fbd19c2c7257338e
Reviewed-on: https://go-review.googlesource.com/c/go/+/223139
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-03-12 14:07:16 +00:00
David Howden
139a79dc37 cmd/go/internal/auth: fix .netrc lookup for URLs with specified port
The .netrc spec [1] defines credentials based on "machine name", so remove specified ports
from URL before looking for a match.

[1] https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html

Fixes #37130

Change-Id: Iab993afba26c927454d6166111ad1e1a53dbce43
Reviewed-on: https://go-review.googlesource.com/c/go/+/218418
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-12 12:58:31 +00:00
Rob Pike
65bd07611c io: add a comment about how to turn a Reader into ByteReader
Offered as an alternative to CL 221380, which was more
tutorial than necessary.

Update #37344

Change-Id: Ide673b0b97983c2c2319a9311dc3d0a10567e6c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/223097
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-12 01:31:41 +00:00
Cherry Zhang
a3e965ce8a [dev.link] cmd/link: convert doelf to new style
Change-Id: I448fe632ae73ddcb79c05793c96f48e358060305
Reviewed-on: https://go-review.googlesource.com/c/go/+/222977
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-11 23:24:00 +00:00
Than McIntosh
67d93cfd35 cmd/internal/objabi: rerun stringer for sym kind
Regenerate symkind_string.go, since it has become a bit out of date.

Change-Id: I57abf67aab8fe4e4a94fb5e45b9bc4c4005cbae3
Reviewed-on: https://go-review.googlesource.com/c/go/+/223079
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-11 22:32:55 +00:00
Than McIntosh
a8e8e05ed1 [dev.link] cmd/internal/objabi: rerun stringer for sym kind
Regenerate this file, since has become a bit out of date.

Change-Id: I4bfa3820f23fb9df36f9a48e63898f4c5de8b31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223058
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-11 22:31:19 +00:00
Than McIntosh
e440f05251 [dev.link] cmd/link: remove legacy newdie function
Remove the linker's "newdie" function (no longer called).

Change-Id: Ide8be6019f512339b8356b0af812426f353af47d
Reviewed-on: https://go-review.googlesource.com/c/go/+/223057
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-11 22:31:11 +00:00
Tamir Duberstein
251f3e5b9c runtime/pprof: document that debug=0 emits proto
Updates #16093.

Change-Id: I629b3d44d6b2083f5e62701cc0c23fe2362502d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/222676
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-03-11 22:12:58 +00:00
Cuong Manh Le
235a7c57be cmd/compile: remove guard for OCOMPLEX in evconst
After CL 166983, the guard for OCOMPLEX in evconst is not necessary
anymore.

Passes toolstash-check.

Change-Id: I1d4a9b447bad9ba0289fc7f997febc0e0b4167ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/214837
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-03-11 20:17:30 +00:00
Filippo Valsorda
efc832b8de crypto/tls: add {SignatureScheme,CurveID,ClientAuthType}.String()
Fixes #35499

Change-Id: Ieb487782f389f6d80e8f68ee980e584d906cb4da
Reviewed-on: https://go-review.googlesource.com/c/go/+/208226
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2020-03-11 20:02:18 +00:00
Robert Griesemer
f6a0d72385 cmd/compile/internal/syntax: various cleanups following CL 221603
1) Introduced setLit method to uniformly set the scanner state for
   literals instead of directly manipulating the scanner fields.

2) Use a local variable 'ok' to track validity of literals instead
   of relying on the side-effect of error reporters setting s.bad.
   More code but clearer because it is local and explicit.

3) s/litname/baseName/ and use this function uniformly, also for
   escapes. Consequently we now report always "hexadecimal" and
   not "hex" (in the case of invalid escapes).

4) Added TestDirectives verifying that we get the correct directive
   string (even if that string contains '%').

Verified that lines/s parsing performance is unchanged by comparing

go test -run StdLib -fast -skip "syntax/(scanner|scanner_test)\.go"

before and after (no relevant difference).

Change-Id: I143e4648fdaa31d1c365fb794a1cae4bc1c3f5ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/222258
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-03-11 19:59:39 +00:00
Bryan C. Mills
eafb4d8f8f cmd/internal/moddeps: set GO111MODULE explicitly for moddeps_test 'go' commands
This fixes observed failures using the following steps to reproduce:

	go env -w GO111MODULE=off
	go test cmd/internal/moddeps

Fixes #37749

Change-Id: I7761f0b20266ac911ad19a724ba2551beca3f267
Reviewed-on: https://go-review.googlesource.com/c/go/+/222674
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-03-11 18:47:13 +00:00
Jay Conrod
576fa69277 cmd/go: extract module zip files in place
Previously, we extracted module zip files to temporary directories
with random names, then renamed them to their final locations. This
failed with ERROR_ACCESS_DENIED on Windows if any file in the
temporary was open. Antivirus programs did this occasionally. Retrying
the rename did not work (CL 220978).

With this change, we extract module zip files in place. We create a
.partial file alongside the .lock file to indicate a directory is not
fully populated, and we delete this at the end of the process.

Updates #36568

Change-Id: I75c09df879a602841f3459322c021896292b2fdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/221157
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-03-11 17:31:14 +00:00
Jay Conrod
093049b370 cmd/go: make module zip extraction more robust
Currently, we extract module zip files to temporary directories, then
atomically rename them into place. On Windows, this can fail with
ERROR_ACCESS_DENIED if another process (antivirus) has files open
before the rename. In CL 220978, we repeated the rename operation in a
loop over 500 ms, but this didn't solve the problem for everyone.

A better solution will extract module zip files to their permanent
locations in the cache and will keep a ".partial" marker file,
indicating when a module hasn't been fully extracted (CL 221157).
This approach is not safe if current versions of Go access the module
cache concurrently, since the module directory is detected with a
single os.Stat.

In the interim, this CL makes two changes:

1. Flaky file system operations are repeated over 2000 ms to reduce
the chance of this error occurring.
2. cmd/go will now check for .partial files created by future
versions. If a .partial file is found, it will lock the lock file,
then remove the .partial file and directory if needed.

After some time has passed and Go versions lacking this CL are no
longer supported, we can start extracting module zip files in place.

Updates #36568

Change-Id: I467ee11aa59a90b63cf0e3e761c4fec89d57d3b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/221820
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-11 17:31:00 +00:00
Bryan C. Mills
cf82feabb6 net: use t.Deadline instead of an arbitrary read deadline in TestDialParallelSpuriousConnection
Also increase the default deadline to 5s, since it empirically
doesn't need to be short and 1s seems to be too slow on some platforms.

Fixes #37795

Change-Id: Ie6bf3916b107401235a1fa8cb0f22c4a98eb2dae
Reviewed-on: https://go-review.googlesource.com/c/go/+/222959
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-03-11 16:49:13 +00:00
Josh Bleecher Snyder
211ee9f07c cmd/compile: use a bytes.Buffer to format symbols
No significant compiler speed changes,
but some minor memory savings.

Passes toolstash-check.

name        old alloc/op      new alloc/op      delta
Template         36.3MB ± 0%       36.2MB ± 0%  -0.25%  (p=0.008 n=5+5)
Unicode          28.3MB ± 0%       28.2MB ± 0%  -0.16%  (p=0.008 n=5+5)
GoTypes           122MB ± 0%        121MB ± 0%  -0.39%  (p=0.008 n=5+5)
Compiler          568MB ± 0%        566MB ± 0%  -0.21%  (p=0.008 n=5+5)
SSA              1.95GB ± 0%       1.95GB ± 0%  -0.08%  (p=0.008 n=5+5)
Flate            22.8MB ± 0%       22.8MB ± 0%  -0.21%  (p=0.008 n=5+5)
GoParser         28.0MB ± 0%       27.9MB ± 0%  -0.38%  (p=0.008 n=5+5)
Reflect          78.6MB ± 0%       78.3MB ± 0%  -0.33%  (p=0.008 n=5+5)
Tar              34.1MB ± 0%       34.1MB ± 0%  -0.19%  (p=0.008 n=5+5)
XML              44.3MB ± 0%       44.2MB ± 0%  -0.19%  (p=0.008 n=5+5)
[Geo mean]       79.9MB            79.7MB       -0.24%

name        old allocs/op     new allocs/op     delta
Template           363k ± 0%         359k ± 0%  -1.21%  (p=0.008 n=5+5)
Unicode            329k ± 0%         326k ± 0%  -0.90%  (p=0.008 n=5+5)
GoTypes           1.28M ± 0%        1.25M ± 0%  -2.62%  (p=0.008 n=5+5)
Compiler          5.39M ± 0%        5.31M ± 0%  -1.45%  (p=0.008 n=5+5)
SSA               18.1M ± 0%        17.9M ± 0%  -0.78%  (p=0.008 n=5+5)
Flate              228k ± 0%         226k ± 0%  -0.97%  (p=0.008 n=5+5)
GoParser           295k ± 0%         288k ± 0%  -2.26%  (p=0.008 n=5+5)
Reflect            949k ± 0%         932k ± 0%  -1.74%  (p=0.008 n=5+5)
Tar                336k ± 0%         332k ± 0%  -1.12%  (p=0.008 n=5+5)
XML                417k ± 0%         413k ± 0%  -1.10%  (p=0.008 n=5+5)
[Geo mean]         818k              806k       -1.42%

Change-Id: Ibdb94650a761edec17d8eba0abdfb70a8a495da9
Reviewed-on: https://go-review.googlesource.com/c/go/+/222920
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-03-11 16:29:44 +00:00
Russ Cox
b136f0c17b cmd/compile: fix buggy AMD64 rewrite from CL 213058
CL 213058's "bonus optimization I noticed while working on this"
turns out to be buggy. It would be correct for CMP, but not TEST.
Fix it to use TEST semantics instead.

This was breaking compilation with the upcoming Spectre mode.

Change-Id: If2d4c3798ed182f35f0244febe74e68c61e4c61b
Reviewed-on: https://go-review.googlesource.com/c/go/+/222853
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-11 16:17:24 +00:00
Russ Cox
96dc04412d test/run: handle asmcheck -gcflags= commands better
The default is for later flags to override earlier ones,
so if the asmcheck set flags, it lost the important -S=2.

Change-Id: Id538254908d658da2acb55157ac4f6fa44f6a467
Reviewed-on: https://go-review.googlesource.com/c/go/+/222820
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-11 16:17:18 +00:00
Russ Cox
801a9d9a0c test/codegen: mention in README that tests only run on Linux without -all_codegen
This took me a while to figure out. The relevant code is in
test/run.go (note the "linux" hard-coded strings):

	var arch, subarch, os string
	switch {
	case archspec[2] != "": // 3 components: "linux/386/sse2"
		os, arch, subarch = archspec[0], archspec[1][1:], archspec[2][1:]
	case archspec[1] != "": // 2 components: "386/sse2"
		os, arch, subarch = "linux", archspec[0], archspec[1][1:]
	default: // 1 component: "386"
		os, arch, subarch = "linux", archspec[0], ""
		if arch == "wasm" {
			os = "js"
		}
	}

Change-Id: I92ba280025d2072e17532a5e43cf1d676789c167
Reviewed-on: https://go-review.googlesource.com/c/go/+/222819
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-11 16:17:08 +00:00
Bryan C. Mills
0e3ace42f5 net/http: use t.Deadline instead of an arbitrary timeout in TestServerConnState
Updates #37322

Change-Id: I3b8369cd9e0ed5e4b3136cedaa2f70698ead2270
Reviewed-on: https://go-review.googlesource.com/c/go/+/222957
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-03-11 15:55:54 +00:00
Bryan C. Mills
035c018d40 runtime: skip TestSignalIgnoreSIGTRAP on known-flaky OpenBSD builders
This test is flaky, and the cause is suspected to be an OpenBSD kernel bug.
Since there is no obvious workaround on the Go side, skip the test on
builders whose versions are known to be affected.

Fixes #17496

Change-Id: Ifa70061eb429e1d949f0fa8a9e25d177afc5c488
Reviewed-on: https://go-review.googlesource.com/c/go/+/222856
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-03-11 15:05:56 +00:00