]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agoarchive/zip: prevent preallocation check from overflowing
Roland Shoemaker [Wed, 18 Aug 2021 18:49:29 +0000 (11:49 -0700)]
archive/zip: prevent preallocation check from overflowing

If the indicated directory size in the archive header is so large that
subtracting it from the archive size overflows a uint64, the check that
the indicated number of files in the archive can be effectively
bypassed. Prevent this from happening by checking that the indicated
directory size is less than the size of the archive.

Thanks to the OSS-Fuzz project for discovering this issue and to
Emmanuel Odeke for reporting it.

Fixes #47801
Fixes CVE-2021-39293

Change-Id: Ifade26b98a40f3b37398ca86bd5252d12394dd24
Reviewed-on: https://go-review.googlesource.com/c/go/+/343434
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
3 years agocrypto/rand, internal/syscall/unix: don't use getentropy on iOS
Tobias Klauser [Thu, 19 Aug 2021 14:36:38 +0000 (16:36 +0200)]
crypto/rand, internal/syscall/unix: don't use getentropy on iOS

CL 302489 switched crypto/rand to use getentropy on darwin, however this
function is not available on iOS. Enable getentropy only on macOS and
disable it on iOS.

Fixes #47812

Change-Id: Ib7ba5d77346aee87904bb93d60cacc845f5c0089
Reviewed-on: https://go-review.googlesource.com/c/go/+/343609
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: use typeAndStr directly in signatslice
Cuong Manh Le [Thu, 19 Aug 2021 10:01:26 +0000 (17:01 +0700)]
cmd/compile: use typeAndStr directly in signatslice

Currently, we store *types.Type in signatslice, then convert it to
typeAndStr during write runtime type process.

Instead, we can just store typeAndStr directly in signatslice when
adding type to signatset. Not a big win, but simplify the code a bit.

Change-Id: Ie1c8cfa5141da32b6ec3ce5844ba150d2765fe90
Reviewed-on: https://go-review.googlesource.com/c/go/+/343529
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/asm/internal/arch: adds the missing type check for arm64 SXTB extension
eric fang [Mon, 16 Aug 2021 06:41:15 +0000 (06:41 +0000)]
cmd/asm/internal/arch: adds the missing type check for arm64 SXTB extension

Operands of memory type do not support SXTB extension. This CL adds this
missing check.

Change-Id: I1fa438dd314fc8aeb889637079cc67b538e83a89
Reviewed-on: https://go-review.googlesource.com/c/go/+/342769
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agocmd/internal/obj/arm64: disable the pre and post index formats for pseudo registers
eric fang [Mon, 16 Aug 2021 07:25:29 +0000 (07:25 +0000)]
cmd/internal/obj/arm64: disable the pre and post index formats for pseudo registers

When using the FP or SP pseudo-register to load or store, pre-index and post-index formats
are not supported because the RSP and pseudo registers are not allowed to be modified in this
way. This CL deletes the related entries in optab and adds a few test cases.

Change-Id: Ie30d27d0e7b959242f0e6298b950489669d07989
Reviewed-on: https://go-review.googlesource.com/c/go/+/342770
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: eric fang <eric.fang@arm.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agocmd/dist: remove unused variables
Manlio Perillo [Fri, 21 May 2021 20:21:09 +0000 (22:21 +0200)]
cmd/dist: remove unused variables

Remove the unused defaultcflags and defaultldflags variables.

Reported by staticcheck.

Change-Id: Icc42f2e670496dbe2ffb26abe25128d8e53e2a6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/321931
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: Tobias Klauser <tobias.klauser@gmail.com>
3 years agosyscall: add SyscallN
Changkun Ou [Thu, 22 Jul 2021 15:50:42 +0000 (17:50 +0200)]
syscall: add SyscallN

This CL adds a new syscall.SyscallN API.

The proposal discussion also suggests the API should not only for
Windows but other platforms. However, the existing API set already
contain differences between platforms, hence the CL only implements
the Windows platform.

Moreover, although the API offers variadic parameters, the permitted
parameters remains up to a limit, which is selected as 42, and arguably
large enough.

Fixes #46552

Change-Id: I66b49988a304d9fc178c7cd5de46d0b75e167a4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/336550
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: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

3 years agocmd/compile: prevent duplicated works in WriteRuntimeTypes
Cuong Manh Le [Tue, 8 Jun 2021 12:28:45 +0000 (19:28 +0700)]
cmd/compile: prevent duplicated works in WriteRuntimeTypes

While processing signatset, the entry is deleted immediately after being
pushed to signatslice. Then calling writeType may add the same type
to signatset again. That would add more works, though not a big impact
to the performace, since when writeType is guarded by s.Siggen() check.

Instead, we should keep the entry in signatset, so written type will
never be added again.

This change does not affect compiler performace, but help debugging
issue like one in #46386 easier.

Change-Id: Iddafe773885fa21cb7003ba27ddf9554fc3f297d
Reviewed-on: https://go-review.googlesource.com/c/go/+/326029
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoreflect: add test for invalid conversion
Keith Randall [Wed, 18 Aug 2021 16:38:19 +0000 (09:38 -0700)]
reflect: add test for invalid conversion

Conversion between slices with different element types is not allowed.
Previously (1.8 <= goversion <= 1.16), this conversion was allowed
if the base types were from different packages and had identical names.

Update #47785

Change-Id: I359de5b6fe3ff35bdbf9ab5a13902a0f820cac66
Reviewed-on: https://go-review.googlesource.com/c/go/+/343329
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/types2: return an error from Instantiate
Robert Findley [Fri, 13 Aug 2021 19:52:12 +0000 (15:52 -0400)]
cmd/compile/internal/types2: return an error from Instantiate

Change Instantiate to be a function (not a method) and return an error.
Introduce an ArgumentError type to report information about which type
argument led to an error during verification.

This resolves a few concerns with the current API:
 - The Checker method set was previously just Files. It is somewhat odd
   to add an additional method for instantiation. Passing the checker as
   an argument seems cleaner.
 - pos, posList, and verify were bound together. In cases where no
   verification is required, the call site was somewhat cluttered.
 - Callers will likely want to access structured information about why
   type information is invalid, and also may not have access to position
   information. Returning an argument index solves both these problems;
   if callers want to associate errors with an argument position, they
   can do this via the resulting index.

We may want to make the first argument an opaque environment rather than
a Checker.

Change-Id: I3bc56d205c13d832b538401a4c91d3917c041225
Reviewed-on: https://go-review.googlesource.com/c/go/+/342152
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoio: unexport internal methods
Roger Peppe [Wed, 11 Aug 2021 11:14:41 +0000 (12:14 +0100)]
io: unexport internal methods

The methods on the pipe type don't need to be exported. Doing so sets
a bad precedent that it's OK to export methods to indicate an internal
public API.  That's not a good idea in general, because exported methods
increase cognitive load when reading code: the reader needs to consider
whether the exported method might be used via some external interface
or reflection.

Change-Id: Ib13f1b3f9fe0ff251628f31b776182a0953268ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/341409
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Trust: Daniel Martí <mvdan@mvdan.cc>

3 years agoarchive/tar: unexport internal methods
Roger Peppe [Wed, 11 Aug 2021 11:50:34 +0000 (12:50 +0100)]
archive/tar: unexport internal methods

Many of the methods inside the archive/tar package don't need to be
exported. Doing so sets a bad precedent that it's OK to export methods
to indicate an internal public API.  That's not a good idea in general,
because exported methods increase cognitive load when reading code:
the reader needs to consider whether the exported method might be used
via some external interface or reflection.

This CL should have no externally visible behaviour changes at all.

Change-Id: I94a63de5e6a28e9ac8a283325217349ebce4f308
Reviewed-on: https://go-review.googlesource.com/c/go/+/341410
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Trust: Joe Tsai <joetsai@digital-static.net>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agocmd/compile: add support for //go:nointerface for -G=3
Matthew Dempsky [Wed, 18 Aug 2021 21:36:45 +0000 (14:36 -0700)]
cmd/compile: add support for //go:nointerface for -G=3

This is used within Google's internal code repo, so getting it working
is a pre-req for enabling -G=3 by default.

Change-Id: Icbc570948c852ca09cdb2a59f778140f620244b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/343429
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile/internal/dwarfgen: use src.Pos.Rel{Filename,Line,Col} consistently
Matthew Dempsky [Wed, 18 Aug 2021 21:42:12 +0000 (14:42 -0700)]
cmd/compile/internal/dwarfgen: use src.Pos.Rel{Filename,Line,Col} consistently

It appears that this code predates golang.org/cl/96535, which added
RelCol to support /*line*/ directives.

Change-Id: Ib79cebc1be53af706e84e8799eeea81ef8c81c8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/343430
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile: only use dictionaries for conversions to type parameters
Keith Randall [Tue, 17 Aug 2021 17:40:44 +0000 (10:40 -0700)]
cmd/compile: only use dictionaries for conversions to type parameters

Conversions to regular concrete types should not be rewritten during
stenciling.

Fixes #47740

Change-Id: I2b45e22f962dcd2e18bd6cc876ebc0f850860822
Reviewed-on: https://go-review.googlesource.com/c/go/+/342989
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile/internal/types2: change Checker.verify to return an error
Robert Findley [Fri, 13 Aug 2021 17:15:15 +0000 (13:15 -0400)]
cmd/compile/internal/types2: change Checker.verify to return an error

In preparation for upcoming API changes, change the internal API for
verification of type arguments to return an error and argument index,
and use this to lift up error reporting into Instantiate.

Change-Id: I88b1e64dd9055c4c20c0db49c96c79c5da894450
Reviewed-on: https://go-review.googlesource.com/c/go/+/342151
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile/internal/types2: no need to validate substituted instances
Robert Findley [Fri, 13 Aug 2021 19:03:14 +0000 (15:03 -0400)]
cmd/compile/internal/types2: no need to validate substituted instances

When substituting a type instance, we rely on the instance being
expanded and do not call validType, so there is need to depend on
subster.pos for error reporting or to use subst.check for creating the
new Named type. Errors will be reported for the unsubstituted instance.

This is a superficial change, but justifies some later simplification
where we don't have access to pos or check.

Change-Id: I1f3f12aa245d821512c6242ad829c940f20afae4
Reviewed-on: https://go-review.googlesource.com/c/go/+/342150
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: only sort methods/interfaces during export for -d=unifiedquirks
Matthew Dempsky [Wed, 18 Aug 2021 20:10:04 +0000 (13:10 -0700)]
cmd/compile: only sort methods/interfaces during export for -d=unifiedquirks

These sorts are only important for 'toolstash -cmp' testing of unified
IR against -G=0 mode, but they were added before I added
-d=unifiedquirks to allow altering small "don't care" output details
like this.

This CL should help mitigate issues with #44195 until package
objectpath is updated and deployed.

Change-Id: Ia3dcf359481ff7abad5ddfca8e673fd2bb30ae01
Reviewed-on: https://go-review.googlesource.com/c/go/+/343390
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile/internal/types2: consolidate verification logic
Robert Findley [Fri, 13 Aug 2021 17:52:55 +0000 (13:52 -0400)]
cmd/compile/internal/types2: consolidate verification logic

Change an internal call of instantiateLazy to call Instantiate, so that
we can consolidate the logic for invoking verification.

This made verification of signatures lazy, which is not necessary but
should be harmless.

Change-Id: I2e59b04ac859e08c2e2910ded3c183093d1e34a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/342149
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile/internal/types2: clean up panics in instantiation
Robert Findley [Fri, 13 Aug 2021 16:03:29 +0000 (12:03 -0400)]
cmd/compile/internal/types2: clean up panics in instantiation

Clean up a few issues related to panicking during invalid instantiation.
 - Panic early in instantiateLazy when check == nil and verify == true.
   Otherwise, we would panic at check.later.
 - Always panic when check == nil and verify == true, even if targs is
   of incorrect length. This is more consistent behavior.
 - Lift the check for len(posList) <= len(targs) out of
   Checker.instantiate. This is the only reason why posList is passed to
   that function, and doing this allows us to eliminate posList from
   instance. At this point instance is close to being unnecessary, so
   update a TODO to this effect.

Change-Id: Id5f44cbb1a5897aef10ce2a573aa78acd7ae4026
Reviewed-on: https://go-review.googlesource.com/c/go/+/341862
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/go/internal/work/exec: throw an error when buildP is negative
Yuki Osaki [Wed, 18 Aug 2021 05:05:55 +0000 (05:05 +0000)]
cmd/go/internal/work/exec: throw an error when buildP is negative

Fixed a problem where an error would not occur
when a negative value was specified for the p flag.

`go build -p=0`
now should throw an error.

this is my first pr to this project.
If there's anything I'm missing, please let me know 🙏
Fixes #46686

Change-Id: I3b19773ef095fad0e0419100d317727c2268699a
GitHub-Last-Rev: e5c57804d9995f5c858aa42d9de21b25de246eb5
GitHub-Pull-Request: golang/go#47360
Reviewed-on: https://go-review.googlesource.com/c/go/+/336751
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go/testdata/script: fix test script added by CL 334873
Tobias Klauser [Wed, 18 Aug 2021 07:03:44 +0000 (09:03 +0200)]
cmd/go/testdata/script: fix test script added by CL 334873

CL 334873 added the net/http import to the wrong section in
test_vet.txt. Correct this to fix the longtest builders.

Change-Id: If28409ad1c2ed3bd3a2922fc20d5e534c30fa249
Reviewed-on: https://go-review.googlesource.com/c/go/+/343169
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agopath/filepath: change IsAbs to treat \\host\share as an absolute path
Yasuhiro Matsumoto [Thu, 15 Jul 2021 14:53:47 +0000 (23:53 +0900)]
path/filepath: change IsAbs to treat \\host\share as an absolute path

Fixes #47123

Change-Id: I2226b8a9ea24cd88171acfbaffea2566309416de
Reviewed-on: https://go-review.googlesource.com/c/go/+/334809
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
3 years agoruntime: use RDCYCLE for cputicks on riscv64
Meng Zhuo [Tue, 6 Jul 2021 07:17:07 +0000 (07:17 +0000)]
runtime: use RDCYCLE for cputicks on riscv64

Use RDCYCLE instruction instead of RDTIME emulation

Change-Id: Id7b3de42a36d2d1b163c39cc79870eee7c840ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/332954
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/arm64: don't use REGTMP when moving C_AACON2 to a register
eric fang [Mon, 21 Jun 2021 08:17:35 +0000 (08:17 +0000)]
cmd/internal/obj/arm64: don't use REGTMP when moving C_AACON2 to a register

MOVD $C_AACON2(Rf), Rt is encoded as ADD $C_AACON2_high_12_bits, Rf, REGTMP +
ADD $C_AACON2_low_12_bits, REGTMP, Rt. Actually REGTMP is not necessary here,
we can use Rt directly, so it becomes ADD $C_AACON2_high_12_bits, Rf, Rt +
ADD $C_AACON2_low_12_bits, Rt, Rt.

Change-Id: I90b7718b5fb0ab9f3ea28511f42946a6bdccfef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/329751
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>

3 years agocmd/internal/obj/arm64: fix the encoding error when operating with ZR
eric fang [Mon, 21 Jun 2021 03:04:42 +0000 (03:04 +0000)]
cmd/internal/obj/arm64: fix the encoding error when operating with ZR

Some arm64 instructions accept ZR as its destination register, such as MOVD,
AND, ADD etc. although it doesn't seem to make much sense, but we should
make sure the encoding is correct. However there exists some encoding mistakes
in the current assembler, they are:
1, 'MOVD $1, ZR' is incorrectly encoded as 'MOVD $1, ZR' + '0x00000000'.
2, 'AND $1, R2, ZR' is incorrectly encoded as 'MOVD $1, R27' + 'AND R27, R2, ZR' +
   '0x00000000'.
3, 'AND $1, ZR' is incorrectly encoded as 'AND $1, ZR, RSP'.

Obviously the first two encoding errors can cause SIGILL, and the third one will
rewrite RSP.

At the same time, I found some weird encodings but they don't cause errors.
4, 'MOVD $0x0001000100010001, ZR' is encoded as 'MOVW $1, ZR' + 'MOVKW $(1<<16), ZR'.
5, 'AND $0x0001000100010001, R2, ZR' is encoded as 'MOVD $1, R27' + 'MOVK $(1<<16), R27' +
   'MOVK $(1<<32), R27'.

Some of these issues also apply to 32-bit versions of these instructions.

These problems are not very complicated, and are basically caused by the improper
adaptation of the class of the constant to the entry in the optab. But the relationship
between these constant classes is a bit complicated, so I don't know how to deal with
issue 4 and 5, because they won't cause errors, so this CL didn't deal with them.

This CL fixed the first three issues.
Issue 1:
  before: 'MOVD $1, ZR' => 'MOVD $1, ZR' + '0x00000000'.
  after:  'MOVD $1, ZR' => 'MOVD $1, ZR'.
Issue 2:
  before: 'AND $1, R2, ZR' => 'MOVD $1, R27' + 'AND R27, R2, ZR' + '0x00000000'.
  after:  'AND $1, R2, ZR' => 'ORR $1, ZR, R27' + 'AND R27, R2, ZR'.
Issue 3:
  before: 'AND $1, ZR' => 'AND $1, ZR, RSP'.
  after:  'AND $1, ZR' => 'ORR $1, ZR, R27' + 'AND R27, ZR, ZR'.

Change-Id: I3c889079229f847b863ad56c88966be12d947202
Reviewed-on: https://go-review.googlesource.com/c/go/+/329750
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/link: do not use GO_LDSO when cross compile
Cherry Mui [Tue, 17 Aug 2021 21:21:03 +0000 (17:21 -0400)]
cmd/link: do not use GO_LDSO when cross compile

GO_LDSO is a setting that is set when the toolchain is build. It
only makes sense to use it on the host platform. Do not use it
when targetting a different platform.

In the past it was not a problem as GO_LDSO was almost always
unset. Now, with CL 301989 it is almost always set (maybe we want
to revisit it).

Fixes #47760.

Change-Id: I2704b9968781f46e2d2f8624090db19689b1a32f
Reviewed-on: https://go-review.googlesource.com/c/go/+/343010
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/go: make mod init disallow invalid major version suffixes
Paschalis Tsilias [Tue, 2 Feb 2021 13:25:21 +0000 (15:25 +0200)]
cmd/go: make mod init disallow invalid major version suffixes

This CL reuses the SplitPathVersion function from the module package to
detect invalid major version suffixes and return a relevant error
message along with a suggested fix.

Fixes #44052
Fixes #46085

Change-Id: I6c06f31a134e864a1d9b6e00c048ca1c59b4365e
Reviewed-on: https://go-review.googlesource.com/c/go/+/288712
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go/internal/test: add an all sentinel to -vet
Colin Arnott [Sun, 18 Jul 2021 08:12:23 +0000 (08:12 +0000)]
cmd/go/internal/test: add an all sentinel to -vet

The vet flag either accepts a list of vets to run, or a distinguished
value, off, to disable vet during test. By default only 100% reliable
checks are run, thus there is no way to run all vets. This change adds
another distinguished value, all, that runs every vet, by passing no
flags.

During development it was discovered that parsing of the -vet flag value
is problematic, in that it accepts deprecated flags like -all. The root
cause is detailed in #47309, but for now passing distinguished values
(all, off) and anything else returns an error.

Fixes #45963

Change-Id: I39fafb7d717dad51b507d560b3f6e604510a2881
Reviewed-on: https://go-review.googlesource.com/c/go/+/334873
Trust: Than McIntosh <thanm@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: go test flag -failfast should be cacheable
kezhao [Wed, 28 Jul 2021 02:06:10 +0000 (02:06 +0000)]
cmd/go: go test flag -failfast should be cacheable

Add failfast to cacheable list and update docs

Fixes #47355

Change-Id: I75b371c45b80a3b179ff070b7b9d092a504380c0
GitHub-Last-Rev: abe61fd48c01fab4ef5ea5db013dcce4ead09c6f
GitHub-Pull-Request: golang/go#47371
Reviewed-on: https://go-review.googlesource.com/c/go/+/337229
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: fix method lookup for type-parameter based types
Robert Griesemer [Tue, 17 Aug 2021 18:55:39 +0000 (11:55 -0700)]
go/types: fix method lookup for type-parameter based types

This is a clean port of CL 342990.

Fixes #47747.

Change-Id: I2e86fb8b70d42a220ac1ba25798d9e58227ba5f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/342991
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: fix method lookup for type-parameter based types
Robert Griesemer [Tue, 17 Aug 2021 18:45:05 +0000 (11:45 -0700)]
cmd/compile/internal/types2: fix method lookup for type-parameter based types

Pointers to type parameters don't have methods, but pointers to
defined types whose underlying types are type parameters may have
methods. Fix the respective test.

For #47747.

Change-Id: I1de47be094ed9297f0e7782538011657c37c5adc
Reviewed-on: https://go-review.googlesource.com/c/go/+/342990
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/trace: use newTaskDesc to create taskDesc
Leonard Wang [Mon, 19 Jul 2021 16:05:16 +0000 (00:05 +0800)]
cmd/trace: use newTaskDesc to create taskDesc

Change-Id: I9bec8e2c4a9e1b9aa2baf883504200b5674844f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/335609
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>

3 years agocmd/link: remove elfwritedynentsym
Cherry Mui [Tue, 15 Jun 2021 17:47:03 +0000 (13:47 -0400)]
cmd/link: remove elfwritedynentsym

elfwritedynentsym and elfWriteDynEntSym are identical.

Change-Id: I893a9a65fdc496f98ba6e66c2bf1ed8dd52f52fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/342709
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agoall: fix typos
Yasuhiro Matsumoto [Fri, 23 Jul 2021 13:28:26 +0000 (22:28 +0900)]
all: fix typos

Change-Id: I83180c472db8795803c1b9be3a33f35959e4dcc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/336889
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/compile: fix CONVIFACE case converting interface to empty interface
Dan Scales [Fri, 13 Aug 2021 00:08:49 +0000 (17:08 -0700)]
cmd/compile: fix CONVIFACE case converting interface to empty interface

We need an extra case in convertToDictionary. In the case of an operand
which is an interface and converting to an empty interface, we don't
want to get the run-time type from the dictionary (which would be the
run-time type of the interface). We want to do a type-assert to the
empty interface.

Change-Id: I414247210168153151272fab198bfe82ad7b1567
Reviewed-on: https://go-review.googlesource.com/c/go/+/342009
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agocmd/compile/internal/types2: allow composite literals of type parameter type
Robert Griesemer [Tue, 17 Aug 2021 01:06:18 +0000 (18:06 -0700)]
cmd/compile/internal/types2: allow composite literals of type parameter type

Change-Id: Iaaa2a3b462da6b121f13a10595950a8502b5f271
Reviewed-on: https://go-review.googlesource.com/c/go/+/342690
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: fix typos
wangyuntao [Tue, 17 Aug 2021 03:24:15 +0000 (03:24 +0000)]
cmd/compile: fix typos

Change-Id: I88a3e69e232bf94296fe97621c5d395fc1296bbb
GitHub-Last-Rev: f1cc29dc287eb02881fead0b815e1b45e23adfa4
GitHub-Pull-Request: golang/go#47482
Reviewed-on: https://go-review.googlesource.com/c/go/+/338751
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

3 years agogo/types: check if the interface is already complete in Complete
Robert Findley [Tue, 17 Aug 2021 00:13:25 +0000 (20:13 -0400)]
go/types: check if the interface is already complete in Complete

Once Interfaces have been completed they must never be written again,
as they may be used concurrently.

Avoid writing Interface.complete unnecessarily in Complete. Also, update
documentation to reflect that Complete must be called before the
Interface may be considered safe for concurrent use.

For #47726

Change-Id: Ic9fd1395ab0dd6d3499f7a698dadf315abcddab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/342749
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoRevert "go/types: make Interface.Complete a no-op"
Robert Findley [Mon, 16 Aug 2021 23:50:47 +0000 (23:50 +0000)]
Revert "go/types: make Interface.Complete a no-op"

This reverts commit fda8ee8b077dd8a5819cac7c52c3af1499a0674e.

Reason for revert: Interface.Complete is still necessary for safe concurrency.

For #47726

Change-Id: I8b924ca5f4af8c7d7e2b5a27bb03a5a5ed9b1d22
Reviewed-on: https://go-review.googlesource.com/c/go/+/342710
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agosrc: simplify race.bash checking condition
Cuong Manh Le [Sat, 15 May 2021 17:08:42 +0000 (00:08 +0700)]
src: simplify race.bash checking condition

By using "uname -s -m" to get the OS name and hardware name,
then using it to match supported platform in case command.

Change-Id: I5161a29c6f3fe34dcda9e7bd477fa3b772b9e041
Reviewed-on: https://go-review.googlesource.com/c/go/+/320250
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile: lowered MulUintptr on riscv64
Meng Zhuo [Sat, 31 Jul 2021 10:20:10 +0000 (10:20 +0000)]
cmd/compile: lowered MulUintptr on riscv64

According to RISCV instruction set manual v2.2 Sec 6.1
MULHU followed by MUL will be fused into one multiply by microarchitecture

name              old time/op  new time/op  delta
MulUintptr/small  11.2ns ±24%   9.2ns ± 0%  -17.54%  (p=0.000 n=10+9)
MulUintptr/large  15.9ns ± 0%  10.9ns ± 0%  -31.55%  (p=0.000 n=8+8)

Change-Id: I3d152218f83948cbc5c576bda29dc86e9b4206ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/338753
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
3 years agonet: reduce allocations for UDP send/recv on Windows
Josh Bleecher Snyder [Mon, 28 Jun 2021 22:41:20 +0000 (15:41 -0700)]
net: reduce allocations for UDP send/recv on Windows

This brings the optimizations added in CLs 331489 and 331490 to Windows.

Updates #43451

Change-Id: I75cf520050325d9eb5c2785d6d8677cc864fcac8
Reviewed-on: https://go-review.googlesource.com/c/go/+/331511
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agonet: reduce allocation size in ReadFromUDP
Josh Bleecher Snyder [Fri, 12 Feb 2021 03:34:22 +0000 (19:34 -0800)]
net: reduce allocation size in ReadFromUDP

Switch to concrete types. Bring your own object to fill in.

Allocate just enough for the IP byte slice.
The allocation is now just 4 bytes for IPv4,
which puts it in the tiny allocator, which is much faster.

name                  old time/op    new time/op    delta
WriteToReadFromUDP-8    13.7µs ± 1%    13.4µs ± 2%   -2.49%  (p=0.000 n=10+10)

name                  old alloc/op   new alloc/op   delta
WriteToReadFromUDP-8     32.0B ± 0%      4.0B ± 0%  -87.50%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
WriteToReadFromUDP-8      1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Windows is temporarily stubbed out.

Updates #43451

Change-Id: Ief506f891b401d28715d22dce6ebda037941924e
Reviewed-on: https://go-review.googlesource.com/c/go/+/331490
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agonet: remove allocation from UDPConn.WriteTo
Josh Bleecher Snyder [Wed, 26 May 2021 19:55:16 +0000 (12:55 -0700)]
net: remove allocation from UDPConn.WriteTo

Duplicate some code to avoid an interface.

name                  old time/op    new time/op    delta
WriteToReadFromUDP-8    6.38µs ±20%    5.59µs ±10%  -12.38%  (p=0.001 n=10+9)

name                  old alloc/op   new alloc/op   delta
WriteToReadFromUDP-8     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
WriteToReadFromUDP-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)

Windows is temporarily stubbed out.

Updates #43451

Change-Id: Ied15ff92268c652cf445836e0446025eaeb60cc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/331489
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agoruntime: accept restartable sequence pcdata values in isAsyncSafePoint
Cherry Mui [Wed, 4 Aug 2021 23:41:19 +0000 (19:41 -0400)]
runtime: accept restartable sequence pcdata values in isAsyncSafePoint

If the pcdata value indicates a restartable sequence, it is okay
to asynchronously preempt (and resume at the restart PC). Accept
it in isAsyncSafePoint.

Fixes #47530.

Change-Id: I419225717c8eee5812f3235338262da5895aad0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/340011
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Austin Clements <austin@google.com>
3 years agocmd/cgo: fix unused parameter warnings in generated _cgo_main.c
Hans [Fri, 30 Jul 2021 02:36:02 +0000 (02:36 +0000)]
cmd/cgo: fix unused parameter warnings in generated _cgo_main.c

Applying -Werror compiler option to request warnings is an usual
way to discover potential errors. Go user may put a cgo directive
in preamble: `// #cgo CFLAGS: -Werror=unused-parameter`.

However, the directive also takes effect on the cgo generated files.
I cleaned _cgo_main.c to help Go user only concentrate on warnings
of their own file.

Fixes #43639

Change-Id: I9112f02ae5226f2fc87a8650d19faee59cddd588
GitHub-Last-Rev: f09d172f979acfba855be8108e7d79ec2778c406
GitHub-Pull-Request: golang/go#46358
Reviewed-on: https://go-review.googlesource.com/c/go/+/322232
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>

3 years agotesting/fstest: allow specifying file for "." in MapFS
Josh Bleecher Snyder [Tue, 15 Jun 2021 23:01:25 +0000 (16:01 -0700)]
testing/fstest: allow specifying file for "." in MapFS

Prior to this commit, specifying a file for "." in MapFS
created an invalid fs.FS and caused infinite recursion in fs.WalkDir.

Fixes #46776

Change-Id: Ia9e4ae1125355a74dba9ee6b36451b7fda75a862
Reviewed-on: https://go-review.googlesource.com/c/go/+/328409
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agonet: avoid memory copy calling absDomainName
Andy Pan [Thu, 24 Jun 2021 04:50:14 +0000 (12:50 +0800)]
net: avoid memory copy calling absDomainName

Change-Id: I8ea9bec8bc33e29b8c265fbca40871bc23667144
Reviewed-on: https://go-review.googlesource.com/c/go/+/330470
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: skip sysmon workaround on NetBSD >= 9.2
Tobias Klauser [Thu, 3 Jun 2021 14:57:54 +0000 (16:57 +0200)]
runtime: skip sysmon workaround on NetBSD >= 9.2

Detect the NetBSD version in osinit and only enable the workaround for
the kernel bug identified in #42515 for NetBSD versions older than 9.2.

For #42515
For #46495

Change-Id: I808846c7f8e47e5f7cc0a2f869246f4bd90d8e22
Reviewed-on: https://go-review.googlesource.com/c/go/+/324472
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go: address code review comments in test cgo_path_space_quote
Jay Conrod [Tue, 3 Aug 2021 21:51:46 +0000 (14:51 -0700)]
cmd/go: address code review comments in test cgo_path_space_quote

For CL 334732.

Change-Id: I5cb88cd7d5e4edf6006bbaeb17723dac2cdf0fd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/339590
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341938

3 years agocmd: update x/tools and remove copy of txtar
Jay Conrod [Mon, 26 Jul 2021 17:39:38 +0000 (10:39 -0700)]
cmd: update x/tools and remove copy of txtar

golang.org/x/tools/txtar is the main location for this package. We
don't need our own copy.

For golang/go#47193

Change-Id: I480eb591f57a0d05b433a657653e2021e39354eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/337352
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341937

3 years agocmd: support space and quotes in CC and CXX
Jay Conrod [Wed, 14 Jul 2021 23:57:24 +0000 (16:57 -0700)]
cmd: support space and quotes in CC and CXX

The CC and CXX environment variables now support spaces and quotes
(both double and single). This fixes two issues: first, if CC is a
single path that contains spaces (like 'c:\Program
Files\gcc\bin\gcc.exe'), that should now work if the space is quoted
or escaped (#41400). Second, if CC or CXX has multiple arguments (like
'gcc -O2'), they are now split correctly, and the arguments are passed
before other arguments when invoking the C compiler. Previously,
strings.Fields was used to split arguments, and the arguments were
placed later in the command line. (#43078).

Fixes golang/go#41400
Fixes golang/go#43078

NOTE: This change also includes a fix (CL 341929) for a test that was
broken by the original CL. Commit message for the fix is below.

[dev.cmdgo] cmd/link: fix TestBuildForTvOS

This test was broken in CL 334732 on darwin.

The test invokes 'go build' with a CC containing the arguments
-framework CoreFoundation. Previously, the go command split CC on
whitespace, and inserted the arguments after the command line when
running CC directly. Those arguments weren't passed to cgo though,
so cgo ran CC without -framework CoreFoundation (or any of the other
flags).

In CL 334732, we pass CC through to cgo, and cgo splits arguments
using str.SplitQuotedFields. So -framework CoreFoundation actually
gets passed to the C compiler. It appears that -framework flags are
only meant to be used in linking operations, so when cgo invokes clang
with -E (run preprocessor only), clang emits an error that -framework
is unused.

This change fixes the test by moving -framework CoreFoundation out of
CC and into CGO_LDFLAGS.

Change-Id: I2d5d89ddb19c94adef65982a8137b01f037d5c11
Reviewed-on: https://go-review.googlesource.com/c/go/+/334732
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341936
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/internal/str: add utilities for quoting and splitting args
Jay Conrod [Wed, 14 Jul 2021 22:37:06 +0000 (15:37 -0700)]
cmd/internal/str: add utilities for quoting and splitting args

JoinAndQuoteFields does the inverse of SplitQuotedFields: it joins a
list of arguments with spaces into one string, quoting arguments that
contain spaces or quotes.

QuotedStringListFlag uses SplitQuotedFields and JoinAndQuoteFields
together to define new flags that accept lists of arguments.

For golang/go#41400

Change-Id: I4986b753cb5e6fabb5b489bf26aedab889f853f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/334731
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341935

3 years agocmd/go: add document -json in testflag
180909 [Mon, 16 Aug 2021 06:07:39 +0000 (06:07 +0000)]
cmd/go: add document -json in testflag

Fixes #47628

Change-Id: I2776fbc22d8a73ca7adc2cf7ad85669d57cc7eae
GitHub-Last-Rev: 826907b0797cdc25f921117e2ee44fc0dc2d21c3
GitHub-Pull-Request: golang/go#47683
Reviewed-on: https://go-review.googlesource.com/c/go/+/341991
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
3 years agocmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse
Jay Conrod [Wed, 28 Jul 2021 21:16:47 +0000 (14:16 -0700)]
cmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse

Previously, callers of loadRefs were expected to always
call via gitRepo.refsOnce.Do and check r.refsErr. This hasn't always
been the case.

This change makes loadRefs cache its own result with r.refsOnce and
return refs and refsErr. Callers can use it more like a normal
function.

CL 297950 is related. Previously, a commit like 0123456789ab could be
resolved to a v0.0.0 pseudo-version when tags couldn't be fetched, but
a shorter commit like 0123456 or a branch name like "master" couldn't
be resolved the same way. With this change, tags must be fetched
successfully ('git ls-remote' must succeed).

For #42751

Change-Id: I49c9346e6c72609ee4f8b10cfe1f69781e78457e
Reviewed-on: https://go-review.googlesource.com/c/go/+/338191
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agonet/http: drop headers with invalid keys in Header.Write
Damien Neil [Mon, 16 Aug 2021 17:46:06 +0000 (10:46 -0700)]
net/http: drop headers with invalid keys in Header.Write

Don't let handlers inject unexpected headers by setting keys like:
w.Header().Set("Evil: x\r\nSmuggle", y)

Fixes #47711.

Change-Id: I459ce1c79bc273a84230a0f5b665f81c46dbc672
Reviewed-on: https://go-review.googlesource.com/c/go/+/342530
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: use the orig object for Named.Obj
Robert Findley [Mon, 16 Aug 2021 18:00:14 +0000 (14:00 -0400)]
go/types: use the orig object for Named.Obj

This is a port of CL 341858 to go/types.

Change-Id: I9fba8941069aaacd641a19e3068de3a769e14e50
Reviewed-on: https://go-review.googlesource.com/c/go/+/342482
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: rename TypeParams to TParamList
Robert Findley [Mon, 16 Aug 2021 17:37:45 +0000 (13:37 -0400)]
go/types: rename TypeParams to TParamList

This is a straightforward port of CL 341861 to go/types.

Change-Id: I4f21170eb2ea1e5395a6eba5132f34aa1d53bb20
Reviewed-on: https://go-review.googlesource.com/c/go/+/342481
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove targs from substMap
Robert Findley [Mon, 16 Aug 2021 17:36:27 +0000 (13:36 -0400)]
go/types: remove targs from substMap

This is a straightforward port of CL 341859 to go/types.

Change-Id: I5d2508f516b5cf4d8775c3a77cc8bed5d4bec338
Reviewed-on: https://go-review.googlesource.com/c/go/+/342480
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: simplify Named.under
Robert Findley [Mon, 16 Aug 2021 17:20:29 +0000 (13:20 -0400)]
go/types: simplify Named.under

This is a straighforward port of CL 341857 to go/types.

Change-Id: I3407676232b595662c1470627771a13263703061
Reviewed-on: https://go-review.googlesource.com/c/go/+/342479
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: define Identical for instances
Robert Findley [Mon, 16 Aug 2021 17:15:47 +0000 (13:15 -0400)]
go/types: define Identical for instances

This is a port of CL 341856 to go/types. It is adjusted to use the
NumTArgs/TArg API of go/types, which has not yet been ported to types2.

Change-Id: I6faeec027f4ae08634267001f473263703e80c5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342478
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: merge Instantiate and InstantiateLazy
Robert Findley [Mon, 16 Aug 2021 16:42:27 +0000 (12:42 -0400)]
go/types: merge Instantiate and InstantiateLazy

This is a straightforward port of CL 341855 to go/types.

Change-Id: I42a74df7a54f5d03aab31ad75dfeb3d1ba775354
Reviewed-on: https://go-review.googlesource.com/c/go/+/342477
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: remove Named.SetTArgs
Robert Findley [Mon, 16 Aug 2021 16:09:56 +0000 (12:09 -0400)]
go/types: remove Named.SetTArgs

This is a port of CL 341290 to go/types; SetTArgs is a potentially
error-prone API.

Change-Id: I484e62d71a0e09be1e19f8e63994912a88364eca
Reviewed-on: https://go-review.googlesource.com/c/go/+/342476
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: parameterized functions must have a body
Robert Findley [Mon, 16 Aug 2021 16:07:27 +0000 (12:07 -0400)]
go/types: parameterized functions must have a body

This is a port of CL 340911 to go/types. The new check differs slightly,
due to go/ast storing type parameters on the function type, rather than
declaration. The error was positioned on the function name for
consistency with types2 (and because that's a better position).

Change-Id: Icdfc76cd65fab215139180b710293a0d79709297
Reviewed-on: https://go-review.googlesource.com/c/go/+/342475
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: expand is only required for *Named types
Robert Findley [Mon, 16 Aug 2021 14:49:10 +0000 (10:49 -0400)]
go/types: expand is only required for *Named types

This is a port of CL 340749 to go/types.

Change-Id: I2af602d357486ee2f45b91c11c4b02ec6b58ed38
Reviewed-on: https://go-review.googlesource.com/c/go/+/342474
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types,types2: superficial changes to align types and types2
Robert Findley [Mon, 16 Aug 2021 13:36:49 +0000 (09:36 -0400)]
go/types,types2: superficial changes to align types and types2

This CL contains an assortment of superficial fixes noticed while
self-reviewing the most recent stack of ports. It also makes a couple
adjustments to termlist_test.go, in both go/types and
cmd/compile/internal/types2.

Change-Id: I64c8cda5e1704e86ac11c6ffc86d55248f44ef79
Reviewed-on: https://go-review.googlesource.com/c/go/+/342490
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: make Interface.Complete a no-op
Robert Findley [Mon, 16 Aug 2021 01:50:42 +0000 (21:50 -0400)]
go/types: make Interface.Complete a no-op

This is a partial port of CL 340255 to go/types. Of course we can't
delete Interface.Complete, but make it a no-op.

Completing interfaces is no longer necessary.

Change-Id: Ida3c84cc94713f14a646c7682f5d4ae5339a0faa
Reviewed-on: https://go-review.googlesource.com/c/go/+/342489
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile: fix panic with dead hidden closures
Cuong Manh Le [Sun, 15 Aug 2021 19:15:28 +0000 (02:15 +0700)]
cmd/compile: fix panic with dead hidden closures

Currently, for hidden closures, we always push them to compile queue
during typechecking. If the hidden closure is discarded from the outer
function body during deadcode, any desugaring phase after deadcode won't
be applied to the closure. Thus, some un-expected OPs are passed to
downstream passes, which they can't handle, the compiler goes boom!

To fix this, we keep track of discarded hidden closures during deadcode
pass, and won't compile them then.

Fixes #47712

Change-Id: I078717d5d1f4f2fa39cbaf610cfffbb042e70ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/342350
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agosyscall: hoist Getsockname out of NetlinkRIB loops
Matt Layher [Wed, 21 Jul 2021 20:03:34 +0000 (16:03 -0400)]
syscall: hoist Getsockname out of NetlinkRIB loops

Calling Getsockname once to fetch the Pid field from the *SockaddrNetlink
is necessary, but this data will remain static for the rest of the netlink
socket's lifetime. Moving this call and type assertion outside of the inner
loops will remove a number of unnecessary system calls.

Change-Id: I7e7e81866af1a31fccdaaf7531efd6cc4cbb8926
Reviewed-on: https://go-review.googlesource.com/c/go/+/336369
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agotime: update current time comment
astraw99 [Mon, 16 Aug 2021 09:54:40 +0000 (09:54 +0000)]
time: update current time comment

In the time package, the ticker and timer both send
current time to channel C, so this PR update the comment
to understand them better.

Change-Id: I99846a40bf8ef780bf0062dd84cf721b3b892a1b
GitHub-Last-Rev: 535da54b8ebd25be22289699212364df0aa49c7f
GitHub-Pull-Request: golang/go#47597
Reviewed-on: https://go-review.googlesource.com/c/go/+/340649
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agointernal/syscall/unix: change Ioctl arg type to unsafe.Pointer on AIX
Matt Layher [Mon, 9 Aug 2021 21:12:37 +0000 (17:12 -0400)]
internal/syscall/unix: change Ioctl arg type to unsafe.Pointer on AIX

Without this change, this code is technically in violation of the
unsafe.Pointer rules since the conversion from unsafe.Pointer to uintptr has
to happen when calling into the syscall6 assembly implementation.

Change-Id: I4821f5bf9788c8fa2efeb041f811ed092e07ae74
Reviewed-on: https://go-review.googlesource.com/c/go/+/340949
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: fix dictionaries for nested closures
Keith Randall [Fri, 13 Aug 2021 16:30:19 +0000 (09:30 -0700)]
cmd/compile: fix dictionaries for nested closures

Capturing dictionary closure variables is ok.

Fixes #47684

Change-Id: I049c87117915e0c5a172b9665bfac2f91064b2d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/342050
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/link: start at address 0 when external linking
Cherry Mui [Wed, 12 May 2021 16:30:34 +0000 (12:30 -0400)]
cmd/link: start at address 0 when external linking

When external linking, we are creating an object file, instead of
a executable. The absolute address is irrelevant. The external
linker will set it up. Start at address 0.

Change-Id: I3a2e0b8087b328d5c3144f29ca8ba6311aa39cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/319830
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agodoc: start draft of go1.18 release notes, move go1.17 to x/website
Carlos Amedee [Fri, 13 Aug 2021 18:42:49 +0000 (14:42 -0400)]
doc: start draft of go1.18 release notes, move go1.17 to x/website

This template is based on CL 295209 and previous ones like it.
Continue to eagerly include often-used sections, and clarify that
the TODO is about completing the section, or removing if it turns
out not to be needed.

Move the Go 1.17 release notes to x/website, since that's the new
home for past Go release notes as of CL 291711. They're added to
x/website in CL 342089.

For #47694
Updates #44513

Change-Id: I24962eed800d1509bdf71b7d7f819a683eb96f8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/342070
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile/internal/ssa: delete unused code
cuiweixie [Mon, 16 Aug 2021 14:49:45 +0000 (14:49 +0000)]
cmd/compile/internal/ssa: delete unused code

Fixes #46186

Change-Id: Idb0674079f9484593e07cca172dfbb19be0e594d
GitHub-Last-Rev: 615fc5365510ff7a39af7569f05a0013b724d0c9
GitHub-Pull-Request: golang/go#46185
Reviewed-on: https://go-review.googlesource.com/c/go/+/320111
Reviewed-by: Ben Shi <powerman1st@163.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: David Chase <drchase@google.com>

3 years agogo/types: limit termlist lengths
Robert Findley [Mon, 16 Aug 2021 01:43:12 +0000 (21:43 -0400)]
go/types: limit termlist lengths

This is a port of CL 340254 to go/types, with minor adjustments for
errors and positions.

Change-Id: I49ea1d1de8d6e27484f167b813267615d142d31c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342438
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: change types2.Union API to accept a list of Terms
Robert Findley [Mon, 16 Aug 2021 01:36:25 +0000 (21:36 -0400)]
go/types: change types2.Union API to accept a list of Terms

This is a straightforward port of CL 340250 to go/types.

Change-Id: I8fc1c78833b5393fb39344fd248529df57870a72
Reviewed-on: https://go-review.googlesource.com/c/go/+/342437
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: add defined type to term/termlist tests
Robert Findley [Mon, 16 Aug 2021 01:28:30 +0000 (21:28 -0400)]
go/types: add defined type to term/termlist tests

This is a port of CL 339905 to go/types.

Change-Id: I9afac9e84bde6f34bb65c7e3d726986d2c648a91
Reviewed-on: https://go-review.googlesource.com/c/go/+/342436
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: minor cleanup of writeTParamList
Robert Findley [Mon, 16 Aug 2021 01:22:38 +0000 (21:22 -0400)]
go/types: minor cleanup of writeTParamList

This is a port of CL 339903 to go/types.

Change-Id: Iaf5fe7321d907df4421128c66cf8c58129eaae8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342435
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: fix make with type parameter argument
Robert Findley [Mon, 16 Aug 2021 01:20:10 +0000 (21:20 -0400)]
go/types: fix make with type parameter argument

This is a port of CL 339899 to go/types. A test assertion is adjusted
to place the 'not enough arguments' error on the ')'.

Change-Id: Ia13eccc66586f9b84a8b99d462bb406d363a3288
Reviewed-on: https://go-review.googlesource.com/c/go/+/342434
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile: intrinsify Mul64 on riscv64
Meng Zhuo [Tue, 22 Jun 2021 11:20:03 +0000 (11:20 +0000)]
cmd/compile: intrinsify Mul64 on riscv64

According to RISCV instruction set manual v2.2 Sec 6.1
MULHU followed by MUL will be fused into one multiply by microarchitecture

Benchstat on Hifive unmatched:
name          old time/op    new time/op    delta
Hash8Bytes       245ns ± 3%     186ns ± 4%  -23.99%  (p=0.000 n=10+10)
Hash320Bytes    1.94µs ± 1%    1.31µs ± 1%  -32.38%  (p=0.000 n=9+10)
Hash1K          5.84µs ± 0%    3.84µs ± 0%  -34.20%  (p=0.000 n=10+9)
Hash8K          45.3µs ± 0%    29.4µs ± 0%  -35.04%  (p=0.000 n=10+10)

name          old speed      new speed      delta
Hash8Bytes    32.7MB/s ± 3%  43.0MB/s ± 4%  +31.61%  (p=0.000 n=10+10)
Hash320Bytes   165MB/s ± 1%   244MB/s ± 1%  +47.88%  (p=0.000 n=9+10)
Hash1K         175MB/s ± 0%   266MB/s ± 0%  +51.98%  (p=0.000 n=10+9)
Hash8K         181MB/s ± 0%   279MB/s ± 0%  +53.94%  (p=0.000 n=10+10)

Change-Id: I3561495d02a4a0ad8578e9b9819bf0a4eaca5d12
Reviewed-on: https://go-review.googlesource.com/c/go/+/329970
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>

3 years agogo/types: fix range over exprs of type parameter type
Robert Findley [Mon, 16 Aug 2021 01:11:18 +0000 (21:11 -0400)]
go/types: fix range over exprs of type parameter type

This is a port of CL 339897 to go/types. In addition, an error message
that was adjusted in CL 274974 is ported to go/types (CL 274974 was
only considered necessary for compiler compatibility).

Change-Id: Idfe44d759c925f9fed353a2d1898d3d4d8d85452
Reviewed-on: https://go-review.googlesource.com/c/go/+/342433
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: better names for things (cleanup)
Robert Findley [Mon, 16 Aug 2021 01:04:39 +0000 (21:04 -0400)]
go/types: better names for things (cleanup)

This is a port of CL 339891 to go/types.

Change-Id: If4d9bbb3ace45bec0f40082dd42ed2dd249100ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/342432
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: cleanup panic calls
Robert Findley [Mon, 16 Aug 2021 00:44:49 +0000 (20:44 -0400)]
go/types: cleanup panic calls

This is a port of CL 339969 to go/types. It differs slightly in
errors.go, due to the differing API.

Change-Id: Ie2bf84ebf312ea3872ee6706615dfc6169a32405
Reviewed-on: https://go-review.googlesource.com/c/go/+/342431
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove TestIncompleteInterfaces (cleanup)
Robert Findley [Mon, 16 Aug 2021 00:38:37 +0000 (20:38 -0400)]
go/types: remove TestIncompleteInterfaces (cleanup)

This is a straightforward port of CL 339832 to go/types.

Change-Id: Ibcb1b130ea474bbbfe9cb5138170e27b466313cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/342430
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove unused gcCompatibilityMode flag (cleanup)
Robert Findley [Mon, 16 Aug 2021 00:32:29 +0000 (20:32 -0400)]
go/types: remove unused gcCompatibilityMode flag (cleanup)

This is a port of CL 339831 to go/types.

gcCompatibilityMode is unused, and x/tools/go/types no longer exists, so
delete it.

Change-Id: I886d8c24b7aa6511934ac78549f07a88a18e950b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342429
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile/internal/types2: use the underlying TypeParam in
Robert Findley [Sun, 15 Aug 2021 23:47:08 +0000 (19:47 -0400)]
cmd/compile/internal/types2: use the underlying TypeParam in
assignableTo

In CL 338310, assignableTo was altered to walk the constituent types of
TypeParams rather than Unions, but was not also adjusted to use under
rather than optype. This manifested in the port to go/types.

Change-Id: Ie057b96ce93cef204af88b536ea49344c9bc8f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/342409
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: implement type sets with term lists
Robert Findley [Sun, 15 Aug 2021 19:28:22 +0000 (15:28 -0400)]
go/types: implement type sets with term lists

This is a port of CL 338310 to go/types. It is superficially adjusted
for different error reporting and AST APIs. It also fixes a bug in CL
338310 that only manifests in go/types (TestFixedbugs/issue39755.go2)
due to go/types preserving untyped nil. In that CL, operand.go is
checking if optype is a TypeParam, which can never be the case. A fix
for types2 will be mailed in a separate CL.

Change-Id: Icf3394e74baec536842267d99f7511d25ab32a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/342331
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: implement term lists
Robert Findley [Sun, 15 Aug 2021 16:23:47 +0000 (12:23 -0400)]
go/types: implement term lists

This is a straightforward port of CL 339596 to go/types, differing only
in the package declaration.

Change-Id: If5bf8fd5667bee91b04fdb797702e6045d5fba7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342330
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agosyscall: use correct type for TIOCSPGRP/TIOCGPGRP
Joel Sing [Sat, 29 May 2021 15:46:19 +0000 (01:46 +1000)]
syscall: use correct type for TIOCSPGRP/TIOCGPGRP

These ioctls take a pid_t (generally a C integer aka int32) and not an int64 - we
currently get away with this on little endian 64 bit platforms, since the bytes
fall into the correct place, however this breaks on big endian 64 bit platforms
(like openbsd/mips64).

This is the same fix as CL 267605, however for libc based exec.

Updates #36435

Change-Id: I01ae4905cba5e1f8725fa6cb8c35403c511534b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/334881
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: make asmcgocall g0/gsignal checks consistent
Joel Sing [Tue, 20 Jul 2021 07:29:15 +0000 (17:29 +1000)]
runtime: make asmcgocall g0/gsignal checks consistent

In asmcgocall() we need to switch to the g0 stack if we're not already on
the g0 stack or the gsignal stack. The prefered way of doing this is to
check gsignal first, then g0, since if we are going to switch to g0 we will
need g0 handy (thus avoiding a second load).

Rewrite/reorder 386 and amd64 to check gsignal first - this shaves a few
assembly instructions off and makes the order consistent with arm, arm64,
mips64 and ppc64. Add missing gsignal checks to mips, riscv64 and s390x.

Change-Id: I1b027bf393c25e0c33e1d8eb80de67e4a0a3f561
Reviewed-on: https://go-review.googlesource.com/c/go/+/335869
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: correct mips64 asmcgocall signal stack behaviour
Joel Sing [Fri, 28 May 2021 18:06:56 +0000 (04:06 +1000)]
runtime: correct mips64 asmcgocall signal stack behaviour

Do not switch to the g0 stack if we're already running on the signal
stack, otherwise all kind of fun ensues.

Updates #36435

Change-Id: I57f35d75b9ee4f92b997713b4cdd38ce881705e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/334880
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: include pthread.h in defs_openbsd.go
Joel Sing [Tue, 18 May 2021 06:01:43 +0000 (16:01 +1000)]
runtime: include pthread.h in defs_openbsd.go

This is required now that defs_openbsd.go has pthread related references.

Updates #36435

Change-Id: I73cdf23eef6aceea6f9b37b7702bdb3b560aa120
Reviewed-on: https://go-review.googlesource.com/c/go/+/334877
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: remove unused getrlimit on linux/riscv64
Tobias Klauser [Tue, 13 Jul 2021 21:12:18 +0000 (23:12 +0200)]
runtime: remove unused getrlimit on linux/riscv64

Follow CL 94775 and CL 93655 which removed the (commented-out) usage
of this function on other platforms.

Change-Id: I28e0569d8531d0c09f3caefa7c4eb54fb5bd8a33
Reviewed-on: https://go-review.googlesource.com/c/go/+/334429
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocrypto/sha{256,512}: unname result parameters for consistency
Brad Fitzpatrick [Mon, 24 May 2021 17:06:36 +0000 (10:06 -0700)]
crypto/sha{256,512}: unname result parameters for consistency

Sum224 and Sum256 didn't look the same at:

    https://golang.org/pkg/crypto/sha256/

Now they match. Likewise with sha512's funcs.

Per:
https://github.com/golang/go/wiki/CodeReviewComments#named-result-parameters

Change-Id: I6b88c8ef15141c78a6cddeb0960b3ad52db34244
Reviewed-on: https://go-review.googlesource.com/c/go/+/322329
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/types2: better error message for index syntax error (follow-up)
Robert Griesemer [Sun, 15 Aug 2021 19:34:59 +0000 (12:34 -0700)]
cmd/compile/internal/types2: better error message for index syntax error (follow-up)

For #47704.

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

3 years agocmd/compile/internal/syntax: better error message for index syntax error
Robert Griesemer [Sun, 15 Aug 2021 18:46:33 +0000 (11:46 -0700)]
cmd/compile/internal/syntax: better error message for index syntax error

Fixes #47704.

Change-Id: I1de9fd00baaa4b534c23f011ade54120f5153a9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/342369
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agolib/time: fix RFC 6557 url
180909 [Sun, 15 Aug 2021 01:57:33 +0000 (01:57 +0000)]
lib/time: fix RFC 6557 url

Change-Id: I59406ee7dbab7b2a0404b62061af552b6b4ecf5f
GitHub-Last-Rev: 7cad5ae9bac19fdffb072413095fe5b223c95eca
GitHub-Pull-Request: golang/go#47696
Reviewed-on: https://go-review.googlesource.com/c/go/+/342209
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agotime/tzdata: update links in comment
Ian Lance Taylor [Fri, 13 Aug 2021 20:58:23 +0000 (13:58 -0700)]
time/tzdata: update links in comment

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