]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agocmd/go: quote fragments in CGO_ env variables reported by 'go env'
Bryan C. Mills [Fri, 1 Apr 2022 18:54:39 +0000 (14:54 -0400)]
cmd/go: quote fragments in CGO_ env variables reported by 'go env'

These fields have been parsed as quoted fields since CL 334732,
but we missed the unparsing side in 'go env'.

Certain scripts (notably make.ba{sh,t}) expect to be able to set the
environment to exactly what 'go env' reports, so for round-trip
purposes it is important to match the marshaling and unmarshaling
functions.

(Noticed while debugging #52009.)
Updates #41400

Change-Id: I0ff39b7a6e1328111c285c97cd23f79b723f3c73
Reviewed-on: https://go-review.googlesource.com/c/go/+/398058
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocrypto/elliptic: delete outdated fuzz test
Filippo Valsorda [Sun, 27 Mar 2022 01:07:30 +0000 (03:07 +0200)]
crypto/elliptic: delete outdated fuzz test

It had not been doing anything since CL 233939, because the Params
method was getting upgraded to the assembly one. We could make it use
genericParamsForCurve, but really we need lower-level, targeted Go 1.18
fuzz targets in nistec now.

Change-Id: I5b198a309aa90ecef9c04aaa6c107d5c0a41a44b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396254
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agocrypto/elliptic: fix BenchmarkMarshalUnmarshal/Compressed
Filippo Valsorda [Tue, 29 Mar 2022 22:18:48 +0000 (00:18 +0200)]
crypto/elliptic: fix BenchmarkMarshalUnmarshal/Compressed

Change-Id: Ifbf4a95e5f315a88633ec0170625cadb087167c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/396934
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agoapi: add x509.CertPool.Equal to next/46057.txt
Dmitri Shuralyov [Tue, 5 Apr 2022 02:49:34 +0000 (22:49 -0400)]
api: add x509.CertPool.Equal to next/46057.txt

CL 388915 added an exported API but was authored (and tested)
before the API check became stricter.

Updates #46057.

Change-Id: Iee6e4969ade77fb0539fa97fcef0047389fb2cf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/398237
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agocrypto/subtle: note that input length mismatch makes ConstantTimeCompare return immed...
Dan Kortschak [Mon, 3 May 2021 03:47:04 +0000 (13:17 +0930)]
crypto/subtle: note that input length mismatch makes ConstantTimeCompare return immediately

Change-Id: Id1ae6c8fbb8c2f31b251ba141dc2bbedae189006
Reviewed-on: https://go-review.googlesource.com/c/go/+/316169
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

3 years agocrypto/rand: make Prime not deterministic for a fixed input stream
Filippo Valsorda [Thu, 10 Mar 2022 16:43:43 +0000 (11:43 -0500)]
crypto/rand: make Prime not deterministic for a fixed input stream

rand.Prime does not guarantee the precise prime selection algorithm as
part of its contract. For example, it changed slightly in CL 387554. We
want to ensure that no tests come to rely on it staying the same, so
just like other cryptographic functions that use randomness in an
unspecified way (ECDSA signing, RSA PKCS #1 v1.5 encryption, RSA key
generation), make it randomly read an extra byte or not.

Change-Id: Ib9079c03360812d412b7c21d5a06caadabb4a8bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/391554
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agocrypto/x509: add CertPool.Equal
Roland Shoemaker [Wed, 2 Mar 2022 19:01:18 +0000 (11:01 -0800)]
crypto/x509: add CertPool.Equal

Fixes #46057

Change-Id: Id3af101c54108d6fd5b65946c4358872358eefcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/388915
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agodebug: define ELF relocation for loong64
Xiaodong Liu [Wed, 30 Mar 2022 08:52:59 +0000 (16:52 +0800)]
debug: define ELF relocation for loong64

Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

For #46229

Change-Id: I0c58305754c20d2a59328adbd82caa527de254ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/396735
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agodoc/go_spec.html: update type identity example
Jared Horvat [Mon, 4 Apr 2022 18:07:01 +0000 (18:07 +0000)]
doc/go_spec.html: update type identity example

In the Type identity section, the example provides various types as givens.

The example refers to the type *T5, but it is not provided in the givens.

I am assuming this was a typo, and was meant to refer to *A1 or *B1.
*B1 seems to be in alignment with the rest of the provided examples.

Change-Id: I554319ee8bca185c3643559321417e8b2a544ba0
GitHub-Last-Rev: e80560d32abcb36c51554606beb09a53d45f0062
GitHub-Pull-Request: golang/go#52143
Reviewed-on: https://go-review.googlesource.com/c/go/+/398075
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agointernal/goexperiment: add GOEXPERIMENT=boringcrypto
Russ Cox [Fri, 25 Mar 2022 17:22:57 +0000 (13:22 -0400)]
internal/goexperiment: add GOEXPERIMENT=boringcrypto

Not hooked up to everything else yet.

Copy of CL 395880, for setting up GOEXPERIMENT=boringcrypto
builder ahead of merge.

For #51940.

Change-Id: If842761f77d07329d88748990b95f4b39c2f153a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397895
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agomake.bash: disable GOEXPERIMENT when using bootstrap toolchain
Russ Cox [Fri, 25 Mar 2022 17:22:55 +0000 (13:22 -0400)]
make.bash: disable GOEXPERIMENT when using bootstrap toolchain

When using Go 1.4 this doesn't matter, but when using Go 1.17,
the bootstrap toolchain will complain about unknown GOEXPERIMENT settings.
Clearly GOEXPERIMENT is for the toolchain being built, not the bootstrap.

Already submitted as CL 395879 on the dev.boringcrypto branch,
but needed on master to set up GOEXPERIMENT=boringcrypto
builder ahead of merge.

For #51940.

Change-Id: Ib6a4099cca799b4d5df1974cdb5471adb0fd557d
Reviewed-on: https://go-review.googlesource.com/c/go/+/397894
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agounsafe: document that Sizeof includes field alignment
Ian Lance Taylor [Fri, 1 Apr 2022 03:41:12 +0000 (20:41 -0700)]
unsafe: document that Sizeof includes field alignment

Fixes #52018

Change-Id: I6d06d5b5279b9bdc899b0ad43488577d3c0b94be
Reviewed-on: https://go-review.googlesource.com/c/go/+/397516
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
3 years agocmd/compile: use shlx&shrx instruction for GOAMD64>=v3
Wayne Zuo [Wed, 2 Mar 2022 08:32:16 +0000 (16:32 +0800)]
cmd/compile: use shlx&shrx instruction for GOAMD64>=v3

The SHRX/SHLX instruction can take any general register as the shift count operand, and can read source from memory. This CL introduces some operators to combine load and shift to one instruction.

For #47120

Change-Id: I13b48f53c7d30067a72eb2c8382242045dead36a
Reviewed-on: https://go-review.googlesource.com/c/go/+/385174
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agoruntime/race: update PPC64LE syso file to new TSAN runtime (v3)
Cherry Mui [Fri, 1 Apr 2022 23:23:52 +0000 (19:23 -0400)]
runtime/race: update PPC64LE syso file to new TSAN runtime (v3)

In CL 397494 Linux/PPC64LE syso was not updated due to  test
failure. It should be fixed by the previous CL and should work
now.

Change-Id: Ieb0993ded5541397094d3aecae28c5255c822eac
Reviewed-on: https://go-review.googlesource.com/c/go/+/397676
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: switch to final unified IR export format
Matthew Dempsky [Tue, 15 Feb 2022 19:39:41 +0000 (11:39 -0800)]
cmd/compile: switch to final unified IR export format

Now that there's a native go/types importer for unified IR, the
compiler no longer needs to stay backwards compatible with old iexport
importers.

This CL also updates the go/types and go/internal/gcimporter tests to
expect that the unified IR importer sets the receiver parameter type
to the underlying Interface type, rather than the Named type. This is
a temporary workaround until we make a decision on #49906.

Notably, this makes `GOEXPERIMENT=unified go test` work on generics
code without requiring `-vet=off` (because previously cmd/vet was
relying on unified IR's backwards-compatible iexport data, which
omitted generic types).

Change-Id: Iac7a2346bb7a91e6690fb2978fb702fadae5559d
Reviewed-on: https://go-review.googlesource.com/c/go/+/386004
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/internal/gcimporter: add support for unified IR
Matthew Dempsky [Tue, 15 Feb 2022 03:51:37 +0000 (19:51 -0800)]
go/internal/gcimporter: add support for unified IR

This CL ports unified IR's types2 importer back to the go/types
API. Notably, it drops support for lazy importing, because those APIs
aren't exposed yet via go/types.

Also, it supports unified IR's "final" data format, which wholey
replaces the iexport data format rather than the current
backwards-compatible hack that cmd/compile uses. The next CL will
switch the compiler to using this same format.

Change-Id: I44e1744bbdc384c9c354119975e68befdc117cff
Reviewed-on: https://go-review.googlesource.com/c/go/+/386002
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agomake.bash: document CC_FOR_${GOOS}_${GOARCH}
uji [Wed, 2 Mar 2022 23:29:43 +0000 (23:29 +0000)]
make.bash: document CC_FOR_${GOOS}_${GOARCH}

Fixes #51306

Change-Id: I5989d86fe5ac4d02793b2ecb00c549d9586763da
GitHub-Last-Rev: 6b0f6bee434219a2c502e8b5630fbe74ca25024a
GitHub-Pull-Request: golang/go#51379
Reviewed-on: https://go-review.googlesource.com/c/go/+/388176
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocopyright: add Loongson into AUTHORS
Xiaodong Liu [Sun, 15 Aug 2021 06:57:00 +0000 (14:57 +0800)]
copyright: add Loongson into AUTHORS

Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I23fb430f1f6e8a587f13e2f020721cbd3a45d4ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/342303
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agotext/template: permit eq and ne funcs to check against nil
Rob Pike [Mon, 14 Mar 2022 02:21:06 +0000 (13:21 +1100)]
text/template: permit eq and ne funcs to check against nil

The existing code errors out immediately if the argument is not
"comparable", making it impossible to test a slice, map, and so
on from being compared to nil.

Fix by delaying the "comparable" error check until we encounter
an actual check between two non-comparable, non-nil values.

Note for the future: reflect makes it unnecessarily clumsy
to deal with nil values in cases like this. For instance, it
should be possible to check if a value is nil without stepping
around a panic. See the new functions isNil and canCompare
for my (too expensive) workaround.

Fixes #51642

Change-Id: Ic4072698c4910130ea7e3d76e7a148d8a8b88162
Reviewed-on: https://go-review.googlesource.com/c/go/+/392274
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agoreflect: fix Value.NumMethod docs
zlasd [Sun, 27 Mar 2022 13:17:53 +0000 (21:17 +0800)]
reflect: fix Value.NumMethod docs

NumMethod counts unexported methods for interface types. This
behavior is documented in Type.NumMethod

Fixes #42123

Change-Id: Ia5aba353a8cc64190c701d1521972d57e8903564
Reviewed-on: https://go-review.googlesource.com/c/go/+/396075
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocrypto/x509: only disable SHA-1 verification for certificates
Roland Shoemaker [Mon, 21 Mar 2022 18:58:08 +0000 (11:58 -0700)]
crypto/x509: only disable SHA-1 verification for certificates

Disable SHA-1 signature verification in Certificate.CheckSignatureFrom,
but not in Certificate.CheckSignature. This allows verification of OCSP
responses and CRLs, which still use SHA-1 signatures, but not on
certificates.

Updates #41682

Change-Id: Ia705eb5052e6fc2724fed59248b1c4ef8af6c3fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/394294
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Jordan Liggitt <liggitt@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: support reading union type for compiler backend in unified IR
Cuong Manh Le [Mon, 4 Apr 2022 07:07:36 +0000 (14:07 +0700)]
cmd/compile: support reading union type for compiler backend in unified IR

Fixes #52124

Change-Id: I5749822d41d8e51f476bceb277b1d2cf7350dcc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/397874
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoruntime: use proper C ABI for race call on PPC64LE
Cherry Mui [Fri, 1 Apr 2022 23:15:32 +0000 (19:15 -0400)]
runtime: use proper C ABI for race call on PPC64LE

On PPC64LE, the C ABI requires SP to be 16-byte aligned. Also, in
the C ABI the callee may save LR, CR, R2 etc. to the 4 reserved
words of the caller's frame. This CL aligns the SP and reserves
the space on stack.

Change-Id: I738880028815b7d3402647e4ebbdae37f45acc77
Reviewed-on: https://go-review.googlesource.com/c/go/+/397675
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/types, types2: fix overlap test for union termlist
Robert Griesemer [Sat, 2 Apr 2022 00:02:28 +0000 (17:02 -0700)]
go/types, types2: fix overlap test for union termlist

Per the spec, "the type sets of all non-interface terms must be
pairwise disjoint (the pairwise intersection of the type sets must
be empty)" in a union.

For the overlap test, the existing implementation casually mixed
syntactic union terms (which may have interface type) with type set
terms (which are normalized/expanded and must not have interface
type). As a consequence, in some cases the overlap test failed.

This change skips terms with interface types in the overlap test.

Fixes #51607.

Change-Id: I8ae9953db31f0a0428389c6a45a6696aa2450219
Reviewed-on: https://go-review.googlesource.com/c/go/+/397695
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agoRevert "os: add handling of os.Interrupt for windows"
Bryan Mills [Mon, 4 Apr 2022 14:45:45 +0000 (14:45 +0000)]
Revert "os: add handling of os.Interrupt for windows"

This reverts CL 367495.

Reason for revert: broke `x/tools` tests on Windows.

Change-Id: Iab6b33259181c9520cf8db1e5b6edfeba763f974
Reviewed-on: https://go-review.googlesource.com/c/go/+/397997
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoregexp/syntax: add and use ErrInvalidDepth
Russ Cox [Wed, 2 Feb 2022 21:44:35 +0000 (16:44 -0500)]
regexp/syntax: add and use ErrInvalidDepth

The fix for #51112 introduced a depth check but used
ErrInternalError to avoid introduce new API in a CL that
would be backported to earlier releases.

New API accepted in proposal #51684.

This CL adds a distinct error for this case.

For #51112.
Fixes #51684.

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

3 years agocmd/go: prevent panic in go work use
Filippo Rossi [Mon, 4 Apr 2022 06:25:32 +0000 (06:25 +0000)]
cmd/go: prevent panic in go work use

Check if paths passed as arguments are existing directories.

Fixes #51841
Fixes #51749

Change-Id: Icfd148627e6f2c4651d6f923a37d413e68c67f6c
GitHub-Last-Rev: 77fffa7635052f11dc93488ee23fd1c895284b4d
GitHub-Pull-Request: golang/go#51845
Reviewed-on: https://go-review.googlesource.com/c/go/+/394154
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoreflect: fix the collision of variable name and package name
hopehook [Sat, 12 Feb 2022 09:03:19 +0000 (17:03 +0800)]
reflect: fix the collision of variable name and package name

The return value "abi" of func "funcLayout" is the same as package
"internal/abi", which currently works fine, but it is more reliable to
avoid conflicts.

Change-Id: I83715dd79beff7cb3fc25747fef186dc0e2dfa8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385414
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agocmd/compile: use LZCNT instruction for GOAMD64>=3
Wayne Zuo [Wed, 30 Mar 2022 13:44:44 +0000 (21:44 +0800)]
cmd/compile: use LZCNT instruction for GOAMD64>=3

LZCNT is similar to BSR, but BSR(x) is undefined when x == 0, so using
LZCNT can avoid a special case for zero input. Except that case,
LZCNTQ(x) == 63-BSRQ(x) and LZCNTL(x) == 31-BSRL(x).

And according to https://www.agner.org/optimize/instruction_tables.pdf,
LZCNT instructions are much faster than BSR on AMD CPU.

name              old time/op  new time/op  delta
LeadingZeros-8    0.91ns ± 1%  0.80ns ± 7%  -11.68%  (p=0.000 n=9+9)
LeadingZeros8-8   0.98ns ±15%  0.91ns ± 1%   -7.34%  (p=0.000 n=9+9)
LeadingZeros16-8  0.94ns ± 3%  0.92ns ± 2%   -2.36%  (p=0.001 n=10+10)
LeadingZeros32-8  0.89ns ± 1%  0.78ns ± 2%  -12.49%  (p=0.000 n=10+10)
LeadingZeros64-8  0.92ns ± 1%  0.78ns ± 1%  -14.48%  (p=0.000 n=10+10)

Change-Id: I125147fe3d6994a4cfe558432780408e9a27557a
Reviewed-on: https://go-review.googlesource.com/c/go/+/396794
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: add MOVBEWstore support for GOAMD64>=3
Wayne Zuo [Wed, 30 Mar 2022 11:27:21 +0000 (19:27 +0800)]
cmd/compile: add MOVBEWstore support for GOAMD64>=3

This CL add MOVBE support for 16-bit version, but MOVBEWload is
excluded because it does not satisfy zero extented.

For #51724

Change-Id: I3fadf20bcbb9b423f6355e6a1e340107e8e621ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/396617
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

3 years agoos: add handling of os.Interrupt for windows
Constantin Konstantinidis [Sun, 28 Nov 2021 14:19:15 +0000 (15:19 +0100)]
os: add handling of os.Interrupt for windows

Add GenerateConsoleCtrlEvent call to internal syscall package.
Define ErrProcessDone while reviewing handling of os.Signal().
Update test to run for windows using the added call.

Fixes #42311
Fixes #46354

Change-Id: I460955efc76c4febe04b612ac9a0670e62ba5ff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/367495
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agonet: support error.Is of network errors and context errors
Ian Lance Taylor [Thu, 31 Mar 2022 00:26:21 +0000 (17:26 -0700)]
net: support error.Is of network errors and context errors

Change timeouts to be Is(context.DeadlineExceeded) and cancelation to
be Is(context.Canceled).

Fixes #51428

Change-Id: Ic580bd9da0f338e993fb79138875a78d99cc1a1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396877
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agocmd/cgo: retain original file paths in godefs generated comment
Tobias Klauser [Fri, 1 Apr 2022 07:41:57 +0000 (09:41 +0200)]
cmd/cgo: retain original file paths in godefs generated comment

Don't rewrite relative file paths to absolute file paths in the
godefs generated code comment.

Fixes #52063

Change-Id: Ie9c5bd021b8f3954e827838930861622c7aa90b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/396936
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoos: run TestStatSymlinkLoop on all platforms
Tobias Klauser [Fri, 1 Apr 2022 10:41:35 +0000 (12:41 +0200)]
os: run TestStatSymlinkLoop on all platforms

The test doesn't seem to be specific to Windows, so run in on all
platforms supporting symlinks.

Change-Id: I0bbae10040d86e313c285bee2c465df2135fd777
Reviewed-on: https://go-review.googlesource.com/c/go/+/397574
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodoc: add illegal octal over 255 example
Zach Collier [Fri, 1 Apr 2022 23:42:12 +0000 (23:42 +0000)]
doc: add illegal octal over 255 example

Octal values over 255, like \400 or \777, are illegal.  It wasn't clear if the expected behavior was a compile error, encoding the value as two characters, or if the value would be capped at 255.

This example explicitly shows that octal values over 255 are illegal.

Change-Id: I45d94680107029c5f083e5d434e6270cc5b258c1
GitHub-Last-Rev: f6bef0379f547ca6204c837279d67ad87c2b69c7
GitHub-Pull-Request: golang/go#52111
Reviewed-on: https://go-review.googlesource.com/c/go/+/397555
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

3 years agogo/types: don't report errors for untyped int shifts on Go < 1.13
Robert Findley [Wed, 30 Mar 2022 13:56:13 +0000 (09:56 -0400)]
go/types: don't report errors for untyped int shifts on Go < 1.13

CL 337529 introduced upfront type-checking of constant shift operands,
to avoid converting their type to uint (per the spec). However, it
had an oversight in that the checks intended for non-constant operands
still ran after the explicit checking of constant operands. As a
result, there are at least two bugs:
 - When GoVersion is < 1.13, we report spurious errors for untyped
   constant shift operands.
 - When the operand is an untyped float constant, we still convert to
   uint (this was a known bug reported in #47410).

Looking at this now, it seems clear that we can avoid both of these bugs
by simply not running the additional checks in the case of a constant
operand. However, this should be considered with some care, as shifts
are notoriously tricky.

Updates #47410
Fixes #52031

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

3 years agostrings: document the use of simple case-folding in EqualFold
hopehook [Wed, 30 Mar 2022 07:47:57 +0000 (15:47 +0800)]
strings: document the use of simple case-folding in EqualFold

Fixes #52022

Change-Id: I077fc062dfd02f79eb83713490efbe0bdc783d8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agonet/netip: improve documentation terminology for IPv4-mapped IPv6 addresses
hopehook [Mon, 21 Mar 2022 08:18:00 +0000 (16:18 +0800)]
net/netip: improve documentation terminology for IPv4-mapped IPv6 addresses

Updates #51834

Change-Id: I07a43457e2e328b51fea8131f7d6d5a4f1de4dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/394078
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agonet: in TestNotTemporaryRead, reject io.EOF on platforms other than plan9
Bryan C. Mills [Mon, 14 Feb 2022 21:07:05 +0000 (16:07 -0500)]
net: in TestNotTemporaryRead, reject io.EOF on platforms other than plan9

Updates #29685

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

3 years agoall: remove trailing blank doc comment lines
Russ Cox [Mon, 31 Jan 2022 01:11:47 +0000 (20:11 -0500)]
all: remove trailing blank doc comment lines

A future change to gofmt will rewrite

// Doc comment.
//
func f()

to

// Doc comment.
func f()

Apply that change preemptively to all doc comments.

For #51082.

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

3 years agoall: fix TODO comment hanging indents
Russ Cox [Mon, 31 Jan 2022 00:22:46 +0000 (19:22 -0500)]
all: fix TODO comment hanging indents

For whatever reason (perhaps some tool does this), a handful of comments,
including some doc comments, have TODOs formatted like:

// TODO(name): Text here and
//             more text aligned
//             under first text.

In doc comments the second line turns into a <pre> block,
which is undesirable in this context.

Rewrite those to unindent, like this instead:

// TODO(name): Text here and
// more text aligned
// at left column.

For #51082.

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

3 years agoall: fix various doc comment formatting nits
Russ Cox [Sun, 30 Jan 2022 00:07:27 +0000 (19:07 -0500)]
all: fix various doc comment formatting nits

A run of lines that are indented with any number of spaces or tabs
format as a <pre> block. This commit fixes various doc comments
that format badly according to that (standard) rule.

For example, consider:

// - List item.
//   Second line.
// - Another item.

Because the - lines are unindented, this is actually two paragraphs
separated by a one-line <pre> block. This CL rewrites it to:

//  - List item.
//    Second line.
//  - Another item.

Today, that will format as a single <pre> block.
In a future release, we hope to format it as a bulleted list.

Various other minor fixes as well, all in preparation for reformatting.

For #51082.

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

3 years agocrypto/x509: skip WSATRY_AGAIN errors when dialing badssl.com subdomains
Bryan C. Mills [Fri, 1 Apr 2022 15:09:30 +0000 (11:09 -0400)]
crypto/x509: skip WSATRY_AGAIN errors when dialing badssl.com subdomains

(Temporarily, until the root cause of the test failure can be
diagnosed and fixed properly.)

For #52094

Change-Id: Iec69e162159f3f0a93135f742aac97cf82c1d96c
Reviewed-on: https://go-review.googlesource.com/c/go/+/397478
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/race: update syso files to new TSAN runtime (v3)
Cherry Mui [Thu, 31 Mar 2022 23:01:17 +0000 (19:01 -0400)]
runtime/race: update syso files to new TSAN runtime (v3)

Following CL 333529, update syso files for other architectures.

Windows/AMD64 is not updated, waiting for Than for C toolchain
updates.

OpenBSD/AMD64 is not updated as upstream LLVM TSAN removed OpenBSD
support (#52090).

Linux/PPC64LE is not updated due to a test failure. Will look into
it.

Change-Id: I46441fd3bb0f2c9e372d3e7fd43744ffafaf87a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/397494
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agodebug/dwarf: better error handling in SeekPC
Than McIntosh [Thu, 31 Mar 2022 11:47:19 +0000 (07:47 -0400)]
debug/dwarf: better error handling in SeekPC

The dwarf.Reader "SeekPC" method was not properly handling the case
of a truncated/empty unit (something that has header information
but an empty abbrev table and no DIEs). Add some guards to handle
this case.

Fixes #52045.

Change-Id: I978163eca3b610f7528058693b840931e90d3f63
Reviewed-on: https://go-review.googlesource.com/c/go/+/397054
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/pprof: point to -h in package documentation
Eli Bendersky [Thu, 31 Mar 2022 03:19:52 +0000 (20:19 -0700)]
cmd/pprof: point to -h in package documentation

Change-Id: I820c72e31fbb6471481f4483e7f13bb8b3d5d00c
Reviewed-on: https://go-review.googlesource.com/c/go/+/396881
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Eli Bendersky‎ <eliben@golang.org>
Run-TryBot: Eli Bendersky‎ <eliben@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/asm: add DC instruction on arm64
erifan01 [Wed, 12 Aug 2020 09:41:54 +0000 (17:41 +0800)]
cmd/asm: add DC instruction on arm64

There was only a placeholder for DC instruction in the previous code.
gVisor needs this instruction. This CL completes its support.

This patch is a copy of CL 250858, contributed by Junchen Li(junchen.li@arm.com).
Co-authored-by: Junchen Li(junchen.li@arm.com)
CustomizedGitHooks: yes
Change-Id: I76098048a227fbd08aa42c4173b028f0ab4f66e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302851
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/asm: add TLBI instruction on arm64
erifan01 [Wed, 12 Aug 2020 09:41:54 +0000 (17:41 +0800)]
cmd/asm: add TLBI instruction on arm64

There was only a placeholder for TLBI instruction in the previous code.
gVisor needs this instruction. This CL completes its support.

This patch is a copy of CL 250758, contributed by Junchen Li(junchen.li@arm.com).
Co-authored-by: Junchen Li(junchen.li@arm.com)
Change-Id: I69e893d2c1f75e227475de9e677548e14870f3cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/302850
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoflag: recover panic when calling String on zero value in PrintDefaults
Andrew Gerrand [Tue, 29 Mar 2022 23:37:07 +0000 (10:37 +1100)]
flag: recover panic when calling String on zero value in PrintDefaults

When printing the usage message, recover panics when calling String
methods on reflect-constructed flag.Value zero values. Collect the panic
messages and include them at the end of the PrintDefaults output so that
the programmer knows to fix the panic.

Fixes #28667

Change-Id: Ic4378a5813a2e26f063d5580d678add65ece8f97
Reviewed-on: https://go-review.googlesource.com/c/go/+/396574
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Trust: Andrew Gerrand <adg@golang.org>

3 years agoruntime: use correct parameter name in comment
Ian Lance Taylor [Tue, 29 Mar 2022 22:55:27 +0000 (15:55 -0700)]
runtime: use correct parameter name in comment

Change-Id: If8713aca9d6b1f1c218e85f09c9ee016833b3faa
Reviewed-on: https://go-review.googlesource.com/c/go/+/396515
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agocmd/asm: refactor some operands that are not special registers on arm64
erifan01 [Wed, 12 Aug 2020 09:41:54 +0000 (17:41 +0800)]
cmd/asm: refactor some operands that are not special registers on arm64

The previous code treats some operands such as EQ, LT, etc. as special
registers. However, they are not. This CL adds a new AddrType TYPE_SPOPD
and a new class C_SPOPD to support this kind of special operands, and
refactors the relevant code.

This patch is a copy of CL 260861, contributed by Junchen Li(junchen.li@arm.com).

Co-authored-by: Junchen Li(junchen.li@arm.com)
Change-Id: I57b28da458ee3332f610602632e7eda03af435f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/302849
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoreflect, runtime: add reflect support for regabi on riscv64
Meng Zhuo [Wed, 3 Nov 2021 10:01:09 +0000 (18:01 +0800)]
reflect, runtime: add reflect support for regabi on riscv64

This CL adds regabi support needed for reflect and reimplement
of CL 360994, which is reverted.

Change-Id: I140673f09109dd9f72eff70aad64c0aa00d6857a
Reviewed-on: https://go-review.googlesource.com/c/go/+/396077
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: mzh <mzh@golangcn.org>

3 years agocmd/internal/obj/arm64: fix encoding error for SYS instruction
eric fang [Thu, 31 Mar 2022 07:34:01 +0000 (07:34 +0000)]
cmd/internal/obj/arm64: fix encoding error for SYS instruction

Currently using the SYS instruction will report the "illegal combination"
error. This is because the assembler parser treats the register operand
as p.To, while optab defines it as p.Reg. This CL fixes this bug.

Change-Id: I57799a7c19934b0c62278948f4efaa41001593a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/396796
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Eric Fang <eric.fang@arm.com>

3 years agocmd/dist: enable msan/asan
Meng Zhuo [Thu, 30 Dec 2021 08:46:21 +0000 (16:46 +0800)]
cmd/dist: enable msan/asan

Supporting memory sanitizer and address sanitizer in toolchains

Change-Id: Ie292657b78954d65bd72e64e063b1c4f18d4f0d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/374974
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agomime/multipart: allow nested boundary with outer boundary+dash prefix
Olivier Szika [Fri, 30 Jul 2021 10:02:51 +0000 (12:02 +0200)]
mime/multipart: allow nested boundary with outer boundary+dash prefix

Fixes #46042

Change-Id: Icd243eb12c6e260aeead04710f12340048a0e859
Reviewed-on: https://go-review.googlesource.com/c/go/+/338549
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/internal/obj/riscv: fix illegal form of MOV instructions
Ben Shi [Thu, 31 Mar 2022 14:34:32 +0000 (14:34 +0000)]
cmd/internal/obj/riscv: fix illegal form of MOV instructions

The MOV like instructions should only have two operands.

Change-Id: Icbfb49e47a91ac305194c2f140d3d81c912f6d6d
GitHub-Last-Rev: 2b25aaa0ed126e8a019db09247953b27123d493f
GitHub-Pull-Request: golang/go#52073
Reviewed-on: https://go-review.googlesource.com/c/go/+/397175
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/elf: ajdust SectionOverlap test for proper fields
Meng Zhuo [Sat, 26 Mar 2022 07:15:45 +0000 (15:15 +0800)]
debug/elf: ajdust SectionOverlap test for proper fields

The current SectionOverlap tests Size (addr) with Offset (file)

This CL set this test for overlap of Size + Addr and
Offset + FileSize

Fixes #51939

Change-Id: Ied4c0b87f61c4d5e52139a8295c371f55abc776f
Reviewed-on: https://go-review.googlesource.com/c/go/+/395920
Trust: mzh <mzh@golangcn.org>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: use opregreg for x86.AXOR* ops
nimelehin [Mon, 6 Dec 2021 08:46:57 +0000 (11:46 +0300)]
cmd/compile: use opregreg for x86.AXOR* ops

Change-Id: Id087d86261744559685c687aa7bad6c55466f1b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/369020
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Alex Rakoczy <alex@golang.org>

3 years agoruntime: check GOAMD64 v4 compatibility on Darwin
vpachkov [Fri, 19 Nov 2021 11:38:23 +0000 (14:38 +0300)]
runtime: check GOAMD64 v4 compatibility on Darwin

Darwin requires a different approach to check AVX512 support.

Update #45453

Change-Id: Ia3dfecc04b47aab16f472000e92e46d4fc6d596d
Reviewed-on: https://go-review.googlesource.com/c/go/+/365395
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years agonet/http: handle 3xx responses with no Location
Damien Neil [Tue, 4 Jan 2022 18:34:50 +0000 (10:34 -0800)]
net/http: handle 3xx responses with no Location

RFC 7231 does not require that a 3xx response contain a Location header.
When receiving such a response, just return it to the caller rather than
treating it as an error.

Fixes #49281.

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

3 years agomime/multipart: unified Part and Reader receiver name
Wayne Zuo [Sun, 20 Mar 2022 14:04:43 +0000 (22:04 +0800)]
mime/multipart: unified Part and Reader receiver name

Change-Id: Ic36dd232f3ea049403715fadec00a74efbf7dc9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394075
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>

3 years agocrypto/x509: properly handle issuerUniqueID and subjectUniqueID
Roland Shoemaker [Tue, 22 Mar 2022 00:26:26 +0000 (17:26 -0700)]
crypto/x509: properly handle issuerUniqueID and subjectUniqueID

Fixes #51754

Change-Id: I3bfa15db3497de9fb82d6391d87fca1ae9ba6543
Reviewed-on: https://go-review.googlesource.com/c/go/+/394297
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agonet: skip tests that use netsh on the windows-arm64-10 builder
Bryan C. Mills [Thu, 31 Mar 2022 18:58:20 +0000 (14:58 -0400)]
net: skip tests that use netsh on the windows-arm64-10 builder

These tests sometimes hang on Windows 10 on ARM64, due to what appears
to be a platform bug. Since we have not yet observed any such hangs on
the windows-arm64-11 builder, I am leaving the tests otherwise enabled
on the theory that the platform bug may have been fixed in Windows 11.

Fixes #52082 (at least for now).

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

3 years agosyscall: relax output check in TestGroupCleanupUserNamespace
Bryan C. Mills [Thu, 31 Mar 2022 20:51:32 +0000 (16:51 -0400)]
syscall: relax output check in TestGroupCleanupUserNamespace

“If you have a procedure with ten parameters, you probably missed some.”
― attr. Alan J. Perlis

I argue that the same is true for hard-coded special cases.

In TestGroupCleanupUserNamespace, instead of a curated list of strings
observed in the wild we now check for a prefix, as was done for
TestGroupCleanup in CL 24670.

Updates #16224.
Updates #16303.
Updates #19938.
Updates #34547.
Updates #46752.
Fixes #52088.

Change-Id: I59c5b0c048113e306996c0f8247e09c714d2423a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397316
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/go: prevent go work use panic when given a file
John Anthony [Thu, 17 Mar 2022 15:36:52 +0000 (15:36 +0000)]
cmd/go: prevent go work use panic when given a file

The current implementation fails to identify that an argument to go work
use is a file when expecting a directory, and panics when attempting to
access it as a directory. This change checks arguments are directories
and generates an error otherwise.

Fixes #51749

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

3 years agostrconv: quote rune 007F as \x7f, not \u007f
Ian Lance Taylor [Thu, 31 Mar 2022 19:30:14 +0000 (12:30 -0700)]
strconv: quote rune 007F as \x7f, not \u007f

\u007f is not wrong but it's weird to use \u when we could use the
shorter \x.

Fixes #52062

Change-Id: Ica4bdc2463128051876f44e15297ed1e9edf1de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/397255
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agocmd/go: allow either test to complete first in TestScript/test_chatty_parallel_succes...
Bryan C. Mills [Thu, 31 Mar 2022 15:03:00 +0000 (11:03 -0400)]
cmd/go: allow either test to complete first in TestScript/test_chatty_parallel_success_run

This fixes a failure mode observed in
https://build.golang.org/log/7b28a914b1914dabe94f7c4e36ad6466ebd4de5d,
in which the expected CONT lines are present but the test completions
are reported in a different (but valid) order.

CONT lines are only printed between interleaved output lines, so if
the ordering of the tests swaps after all output is already generated
the PASS lines can be in arbitrary order.

Fixes #51221 (again).

Change-Id: I051f8ec4331e2e3ab1bb00a7c188c322ad4e0a03
Reviewed-on: https://go-review.googlesource.com/c/go/+/397194
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: better propagation of desired registers
Keith Randall [Sat, 26 Mar 2022 17:05:04 +0000 (10:05 -0700)]
cmd/compile: better propagation of desired registers

This fixes two independent problems:

We normally propagate desired registers backwards through opcodes that
are marked resultInArg0. Unfortunately for the desired register
computation, ADDQconst is not marked as resultInArg0. This is because
the amd64 backend can write it out as LEAQ instead if the input and
output registers don't match. For desired register purposes, we want
to treat ADDQconst as resultInArg0, so that we get an ADDQ instead of
a LEAQ if we can.

Desired registers don't currently work for tuple-generating opcodes.
Declare that the desired register applies to the first element of the
tuple, and propagate the desired register back through Select0.

Noticed when fixing #51964

Change-Id: I83346b988882cd58c2d7e7e5b419a2b9a244ab66
Reviewed-on: https://go-review.googlesource.com/c/go/+/396035
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime: rewrite stale comment about pacer
Michael Anthony Knyszek [Wed, 2 Mar 2022 17:41:49 +0000 (17:41 +0000)]
runtime: rewrite stale comment about pacer

Change-Id: Ieb8015164526da59b042031234146def06f70a1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/393399
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime: add wrappers for sys* functions and consolidate docs
Michael Anthony Knyszek [Tue, 15 Mar 2022 00:23:26 +0000 (00:23 +0000)]
runtime: add wrappers for sys* functions and consolidate docs

This change lifts all non-platform-specific code out of sys* functions
for each platform up into wrappers, and moves documentation about the OS
virtual memory abstraction layer from malloc.go to mem.go, which
contains those wrappers.

Change-Id: Ie803e4447403eaafc508b34b53a1a47d6cee9388
Reviewed-on: https://go-review.googlesource.com/c/go/+/393398
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: remove intermediate fields in memstats for ReadMemStats
Michael Anthony Knyszek [Mon, 14 Mar 2022 23:39:03 +0000 (23:39 +0000)]
runtime: remove intermediate fields in memstats for ReadMemStats

Currently, the ReadMemStats (really this is all happening in
readmemstats_m, but that's just a direct call from ReadMemStats) call
chain first populates some fields in memstats, then copies those into
the final MemStats location. This used to make a lot of sense when
memstats' structure aligned with MemStats, and the values were just
copied from one to other. Sometime in the last few releases, we switched
to populating the MemStats manually because a lot of fields had diverged
from their internal representation. Now, we're left with a lot of fields
in memstats that pollute the structure: they only exist to be updated
for the sake of ReadMemStats. Since we're going to be adding more fields
to memstats in further CLs, this is a good opportunity to clean up.

As a result of this change, updatememstats, which used to just update
the aforementioned intermediate fields in memstats, is no longer
necessary, so it is removed.

Change-Id: Ifabfb3ac3002641105af62e9509a6351165dcd87
Reviewed-on: https://go-review.googlesource.com/c/go/+/393397
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime: remove old pacer and the PacerRedesign goexperiment
Michael Anthony Knyszek [Mon, 14 Feb 2022 22:36:25 +0000 (22:36 +0000)]
runtime: remove old pacer and the PacerRedesign goexperiment

Now that Go 1.18 has been released, remove the old pacer.

Change-Id: Ie7a7596d67f3fc25d3f375a08fc75eafac2eb834
Reviewed-on: https://go-review.googlesource.com/c/go/+/393396
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime/internal/atomic: add Bool
Michael Anthony Knyszek [Mon, 14 Feb 2022 19:28:20 +0000 (19:28 +0000)]
runtime/internal/atomic: add Bool

This change adds the Bool type, a convenient wrapper around Uint8 for
atomic bool values.

Change-Id: I86127d6f213b730d6999db5718ca1a5af0c5b538
Reviewed-on: https://go-review.googlesource.com/c/go/+/393395
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: remove AVX2less code in memclrNoHeapPointers for GOAMD64 >= 3
vpachkov [Mon, 29 Nov 2021 12:20:37 +0000 (15:20 +0300)]
runtime: remove AVX2less code in memclrNoHeapPointers for GOAMD64 >= 3

Optimize memclr by removing simple case loop along with the
runtime check since AVX2 is guaranteed to be available when
compiling with GOAMD64 >= 3

name             old speed      new speed      delta
Memclr/5-12      2.70GB/s ± 1%  2.73GB/s ± 1%     ~     (p=0.056 n=5+5)
Memclr/16-12     7.00GB/s ± 2%  7.03GB/s ± 1%     ~     (p=1.000 n=5+5)
Memclr/64-12     25.5GB/s ± 1%  25.5GB/s ± 1%     ~     (p=0.548 n=5+5)
Memclr/256-12    53.4GB/s ± 1%  52.7GB/s ± 2%     ~     (p=0.222 n=5+5)
Memclr/4096-12    109GB/s ± 1%   129GB/s ± 0%  +18.57%  (p=0.008 n=5+5)
Memclr/65536-12  75.2GB/s ± 2%  78.3GB/s ± 3%   +4.14%  (p=0.008 n=5+5)
Memclr/1M-12     53.5GB/s ± 2%  54.1GB/s ± 2%     ~     (p=0.310 n=5+5)
Memclr/4M-12     53.1GB/s ± 3%  52.9GB/s ± 2%     ~     (p=1.000 n=5+5)
Memclr/8M-12     44.6GB/s ± 3%  45.1GB/s ± 3%     ~     (p=0.310 n=5+5)
Memclr/16M-12    24.8GB/s ± 2%  24.2GB/s ± 2%     ~     (p=0.056 n=5+5)
Memclr/64M-12    38.3GB/s ± 1%  37.8GB/s ± 1%     ~     (p=0.056 n=5+5)
[Geo mean]       31.0GB/s       31.5GB/s        +1.78%

Change-Id: I6f3014f6338cb3b5a1b94503faa205f043fe2de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/367494
Trust: Cherry Mui <cherryyz@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/link/internal/ld: revise recipe for ASLR enable on windows
Than McIntosh [Tue, 8 Feb 2022 17:41:26 +0000 (12:41 -0500)]
cmd/link/internal/ld: revise recipe for ASLR enable on windows

When doing external linking on windows, the existing Go linker code
assumed that the external linker defaulted to "--no-dynamicbase" (if
no explicit option was given). This assumption doesn't hold for LLD,
which turns on "--dynamicbase" by default for 64-bit apps. Change the
linker to detect whether a more modern toolchain is in use and to
explicitly pass "--dynamicbase" either way , so as to take the
external linker default out of the equation. This also applies to the
"--high-entropy-va" option as well.

Updates #35006.

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

3 years agocmd/go: update TestCgoHandlesWlORIGIN to avoid -rpath on windows
Than McIntosh [Tue, 8 Feb 2022 16:56:10 +0000 (11:56 -0500)]
cmd/go: update TestCgoHandlesWlORIGIN to avoid -rpath on windows

Tweak the cgo recipe for the TestCgoHandlesWlORIGIN testpoint to avoid
using "-rpath" on Windows, where it doesn't make sense to use it. This
change needed to avoid an "unknown flag -rpath" from clang/ldd on
windows.

Updates #35006.

Change-Id: I4fcd649df4687aa3aff5690e11a15fc0e0f42332
Reviewed-on: https://go-review.googlesource.com/c/go/+/384155
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: remove a false dependency for TZCNT
nimelehin [Mon, 6 Dec 2021 15:46:25 +0000 (18:46 +0300)]
cmd/compile: remove a false dependency for TZCNT

LZCNT/TZCNT on some Intel CPUs suffer from a false dependency on
the destination register.

The problem was mentioned in the GCC Ticket: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62011#c7
and fixed with https://gcc.gnu.org/viewcvs?rev=214112&root=gcc&view=rev

Change-Id: I8109e84f03ac85f221b06d3b913612b58320d151
Reviewed-on: https://go-review.googlesource.com/c/go/+/369019
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alex Rakoczy <alex@golang.org>
Run-TryBot: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/build: set allTags even when short-circuiting x_GOOS_GOARCH.go
Ian Lance Taylor [Wed, 30 Mar 2022 23:36:14 +0000 (16:36 -0700)]
go/build: set allTags even when short-circuiting x_GOOS_GOARCH.go

Fixes #52053

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

3 years agocmd/compile: clean up arm64 32bit pointer in Reverse
Wayne Zuo [Sun, 27 Mar 2022 07:12:39 +0000 (15:12 +0800)]
cmd/compile: clean up arm64 32bit pointer in Reverse

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

3 years agocmd/compile: fix clobberFlags for BSWAP
Jakub Ciolek [Thu, 10 Mar 2022 14:35:17 +0000 (15:35 +0100)]
cmd/compile: fix clobberFlags for BSWAP

BSWAP does not affect EFLAGS on neither 386 nor x64. Set the clobberFlags value accordingly.

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

3 years agodebug/pe: skip TestReadCOFFSymbolAuxInfo on big-endian systems
Than McIntosh [Thu, 31 Mar 2022 17:15:51 +0000 (13:15 -0400)]
debug/pe: skip TestReadCOFFSymbolAuxInfo on big-endian systems

Disable the new TestReadCOFFSymbolAuxInfo testpoint on big endian
systems, pending resolution of issue 52079. The newly added interfaces
for reading symbol definition aux info is not working properly when
reading PE objects obj big-endian systems.

Updates #52079.

Change-Id: I8d55c7e4c03fc6444ef06a6a8154cb50596ca58a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397294
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: simplify func value symbol generation
Cherry Mui [Tue, 29 Mar 2022 16:59:12 +0000 (12:59 -0400)]
cmd/compile: simplify func value symbol generation

Currently, in most cases the compiler generates a func value
symbol when it is referenced, except when building a shared object
it generates the func value symbol when the function is declared.

The comment says this was necessary because we cannot deduplicate
DUPOK symbols across DSO boundaries. But the dynamic linker is
just fine to resolve symbols with the same name across DSO
boundaries.

Another problem may be that the address of the PLT stub may be
used. When such a func value is deferred, when the runtime needs
to scan its arguments, it cannot look up the PC to find the
function and therefore cannot find its stack map. This is not a
problem now as deferred functions always have no arguments.

Remove the special case for shared linkage.

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

3 years agotest: update comments in run.go (cleanup)
Robert Griesemer [Thu, 31 Mar 2022 16:34:50 +0000 (09:34 -0700)]
test: update comments in run.go (cleanup)

The -G compiler option doesn't exist anymore. Update some variable
names and comments to reflect the new reality.

Change-Id: I227e9c59a01615c3a40c3869102e8045cb012980
Reviewed-on: https://go-review.googlesource.com/c/go/+/397254
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocrypto/elliptic: tolerate zero-padded scalars in generic P-256
Filippo Valsorda [Thu, 31 Mar 2022 16:31:58 +0000 (12:31 -0400)]
crypto/elliptic: tolerate zero-padded scalars in generic P-256

Fixes #52075

Change-Id: I595a7514c9a0aa1b9c76aedfc2307e1124271f27
Reviewed-on: https://go-review.googlesource.com/c/go/+/397135
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agoruntime: remove use of -mnop-fun-dllimport from cgotest win.go
Than McIntosh [Mon, 7 Feb 2022 21:32:01 +0000 (16:32 -0500)]
runtime: remove use of -mnop-fun-dllimport from cgotest win.go

This flag is not supported by clang, so remove it from the cgo cflags
when building for windows. It is clear that it was needed at some
point in the past, but it doesn't appear to be needed at the moment,
since all.bash passes on windows without it now.

Updates #35006.

Change-Id: Ib06c891f516654138e3363e06645cd187e46ce4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/383838
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/link/internal/loadpe: add rudimentary COMDAT support
Than McIntosh [Mon, 7 Feb 2022 20:00:46 +0000 (15:00 -0500)]
cmd/link/internal/loadpe: add rudimentary COMDAT support

Add some rudimentary support to the PE file loader for handling
sections in COMDAT when reading host object files. This is needed
in order to link programs with support libraries that are of a more
modern vintage than GCC 5.X.

If a given section XYZ is in COMDAT, the symbol for that section will
be flagged, e.g. section 'Characteristics' field will have the
IMAGE_SCN_LNK_COMDAT bit set, and the symbol will be followed by an
"aux" symbol that includes the COMDAT handling strategy that the
linker needs to use.

This patch supports two COMDAT strategies (IMAGE_COMDAT_SELECT_ANY and
IMAGE_COMDAT_SELECT_SAME_SIZE); more work will have to be done in the
future to support other flavors if it turns out that they are needed.

Updates #35006.

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

3 years agodebug/pe: add APIs for reading section def aux info
Than McIntosh [Tue, 22 Mar 2022 12:49:52 +0000 (08:49 -0400)]
debug/pe: add APIs for reading section def aux info

Add hooks to support reading of section definition symbol aux data
(including COMDAT information) from the aux symbols associated with
section definition symbols. The COFF symbol array made available by
"pe.File" includes entries for aux symbols, but doesn't expose their
structure (since it varies depending on the type of aux symbol). This
patch adds a function for returning a specific class of aux symbol
("type 5") that immediately follows a COFF symbol corresponding to a
section definition.

Updates #35006.
Updates #51868.

Change-Id: I21fcc057150f7a3c64f01a5961aabca0fa43399e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394534
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/link: resolve __CTOR_LIST__/__DTOR_LIST__ refs for PE
Than McIntosh [Mon, 7 Feb 2022 20:30:34 +0000 (15:30 -0500)]
cmd/link: resolve __CTOR_LIST__/__DTOR_LIST__ refs for PE

When doing an internal link on Windows, it's possible to see
unresolved references to the symbols "__CTOR_LIST__" and/or
"__DTOR_LIST__" (which are needed in some circumstances). If these are
still unresolved at the point where we're done reading host objects,
then synthesize dummy versions of them.

Updates #35006.

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

3 years agogo/types, types2: better error message for invalid type parameter term
Robert Griesemer [Wed, 30 Mar 2022 19:19:24 +0000 (12:19 -0700)]
go/types, types2: better error message for invalid type parameter term

The spec says "In a union, a term cannot be a type parameter,...",
but it's really the type in a term that cannot be a type parameter.
(Also, for the spec's purposes, a single term is still a union.)

This CL changes the current error message from:

        "cannot use type parameter in typeset"

to one of two messages:

        "term cannot be a type parameter"           (for term of form P)
        "type in term ~P cannot be a type parameter (for term of form ~P)

which are more specific and match the spec more closely.

Fixes #50420.

Change-Id: Id48503efc8416cabc03d5c40d8e64d5b3a7f078e
Reviewed-on: https://go-review.googlesource.com/c/go/+/396874
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodebug/elf: check for negative shoff and phoff fields
Ian Lance Taylor [Thu, 31 Mar 2022 01:47:11 +0000 (18:47 -0700)]
debug/elf: check for negative shoff and phoff fields

No test because we could add an infinite number of tests of bogus data.

For #47653
Fixes #52035

Change-Id: Iec7e2fe23f2dd1cf14bad2475422f243f51028f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/396880
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: read crt2.o for windows internal-linking CGO
Than McIntosh [Thu, 3 Feb 2022 13:23:10 +0000 (08:23 -0500)]
cmd/link: read crt2.o for windows internal-linking CGO

For Windows internal linking with CGO, when using more modern
LLVM-based compilers, we may need to read in the object file "crt2.o"
so as to have a definition of "atexit" (for example when linking the
runtime/cgo test), and we also need to allow for the possibility that
a given host archive might have to be looked at more than once. The goal
here is to get all.bash working on Windows when using an up to date
mingw C compiler (including those based on clang + LLD).

This patch also adds a new "hostObject" helper routine, similar to
"hostArchive" but specific to individual object files. There is also a
change to hostArchive to modify the pseudo-package name assigned when
reading archive elements: up until this point, a package name of
"libgcc" was used (even when reading a host archive like
"libmingex.a"), which led to very confusing errors messages if symbols
were missing or there were duplicate definitions.

Updates #35006.

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

3 years agocmd/link/internal/loadpe: generalize handling of "__imp_*" syms
Than McIntosh [Thu, 3 Feb 2022 13:11:53 +0000 (08:11 -0500)]
cmd/link/internal/loadpe: generalize handling of "__imp_*" syms

The existing PE file loader has a special case for the symbol
"__acrt_iob_func", whose hosting object file contains both an actual
definition and also a DLL import symbol "__imp___acrt_iob_func". The
normal way of handling __imp_XXX symbols is for the host object loader
to rename them to their intended target (e.g. "XXX") however if the
target is also defined locally, you get a duplicate definition.

This patch generalizes the def/import symbol detection to apply to all
symbols in the object file being loaded (not just a hard-coded set),
since it will be needed when reading things like crt2.o.

Updates #35006.

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

3 years agocmd/link/internal/loadpe: refactor readpesym()
Than McIntosh [Wed, 2 Feb 2022 18:26:16 +0000 (13:26 -0500)]
cmd/link/internal/loadpe: refactor readpesym()

Rewrite the helper "readpesym()" and the code that calls it to pass in
most of the values it needs via a state object (the signature was
getting a bit too busy/lengthy). No change in functionality, this is
just a refactor.

Updates #35006.

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

3 years agonet: clean up redundant if branch in dial
Shang Ding [Thu, 24 Feb 2022 01:35:21 +0000 (19:35 -0600)]
net: clean up redundant if branch in dial

Dialer.DialContext no longer performs a redundant check on the length
of the fallback slice, because dialParallel already handles the
situation where the fallback slice is empty or nil.

Change-Id: Ibb16f4813fc55dec2939c54c10e665ff35bfe163
Reviewed-on: https://go-review.googlesource.com/c/go/+/387795
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agotext/template: remove newline special casing in documentation
Sean Liao [Tue, 22 Mar 2022 20:53:10 +0000 (20:53 +0000)]
text/template: remove newline special casing in documentation

Updates #29770
Fixes #51872

Change-Id: Icee660c8cc6c69a79ad11e818dd8ab40a344e800
Reviewed-on: https://go-review.googlesource.com/c/go/+/394676
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agomath/big: call norm when returning success from Rat SetString
Shulhan [Tue, 16 Nov 2021 18:36:15 +0000 (01:36 +0700)]
math/big: call norm when returning success from Rat SetString

After CL 24430, reflect.DeepEqual no longer returns true when comparing
a *Rat built with (*Rat).SetString("0") with one built with
(*Rat).SetInt64(0).
These should be equivalent, but because (*Rat).SetString does not call
norm() when returning the zero value, the result of reflect.DeepEqual
will be false.

One could suggest that developers should use (*Rat).Cmp instead
of relying on reflect.DeepEqual, but if a (*Rat) is part of a
larger struct that is being compared, this can be cumbersome.

This is fixed by calling z.norm() when returning zero in SetString.

Fixes #50944

Change-Id: Ib84ae975bf82fe02d1203aa9668a01960c0fd59d
Reviewed-on: https://go-review.googlesource.com/c/go/+/364434
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agostrings: limits allocation size for SplitN
Philippe Antoine [Sun, 20 Mar 2022 21:34:42 +0000 (21:34 +0000)]
strings: limits allocation size for SplitN

So that `strings.SplitN("", "T", int(144115188075855872))` does not panic.

Change-Id: Iea00417e61780bcaf0fee02fa2b18026d89bc545
GitHub-Last-Rev: d1f45b44a8011ddb27c71e1bc9983b62b5d3d771
GitHub-Pull-Request: golang/go#51755
Reviewed-on: https://go-review.googlesource.com/c/go/+/393654
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

3 years agocmd/cgo: use size_t instead of __SIZE_TYPE__
qmuntal [Wed, 19 Jan 2022 16:01:25 +0000 (17:01 +0100)]
cmd/cgo: use size_t instead of __SIZE_TYPE__

__SIZE_TYPE__ is a GCC type which has been superseded
by size_t -define in stddef.h- since ISO C99.

cmd/cgo already uses size_t in many places, but still generates several
files using __SIZE_TYPES__, most notably the _cgo_export.h.

This change replaces all __SIZE_TYPES__ occurrences with size_t.

Updates #36233

Change-Id: Id8a99b5d7763caab9333eab9b585e78249a37415
Reviewed-on: https://go-review.googlesource.com/c/go/+/379474
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agocmd/go: add comments to C.* special functions
qmuntal [Thu, 17 Feb 2022 09:44:13 +0000 (10:44 +0100)]
cmd/go: add comments to C.* special functions

Adding comments to these functions help IDE tooling to display
meaningful documentation, p.e. on hover.

Tested with gopls and vscode.

Updates #51134

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

3 years agospec: clarify type term restriction for type parameters
Robert Griesemer [Wed, 30 Mar 2022 21:13:39 +0000 (14:13 -0700)]
spec: clarify type term restriction for type parameters

Be clear that the type of a term (not the term itself, which may
be of the form ~P) cannot be a type parameter.

For #50420.

Change-Id: I388d57be0618393d7ebe2c74ec04c1ebe3f33f7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396915
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>