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

48313 Commits

Author SHA1 Message Date
Dan Scales
b1a398cf0f [dev.typeparams] cmd/compile: add import/export of calls to builtin functions
For generic functions, we have to leave the builtins in OCALL form,
rather than transform to specific ops, since we don't know the exact
types involved. Allow export/import of builtins in OCALL form.

Added new export/import test mapimp.go.

Change-Id: I571f8eeaa13b4f69389dbdb9afb6cc61924b9bf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/321750
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-05-21 17:14:19 +00:00
Dan Scales
ccbfbb1c33 [dev.typeparams] cmd/compile: export OFUNCINST and OSELRECV2 nodes (for generic functions)
Added new test typeparam/factimp.go and changed a bunch of other tests
to test exporting more generic functions and types.

Change-Id: I573d75431cc92482f8f908695cfbc8e84dbb36d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/321749
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-05-21 17:03:30 +00:00
Tim Heckman
3148694f60 cmd/go: remove warning from module deprecation notice printing
Fixes #46294

Change-Id: I50023006dab83dee455f98a702ca1c72e61764ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/321649
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: Jay Conrod <jayconrod@google.com>
2021-05-21 16:51:34 +00:00
Robert Griesemer
243076da64 [dev.typeparams] cmd/compile/internal/types2: move signature checking into separate file
This only moves functionality from one file into another.
Except for import adjustments there are no changes to the
code.

Change-Id: Id0d20a7537f20abe3a257ad3f550b0cb4499598c
Reviewed-on: https://go-review.googlesource.com/c/go/+/321590
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>
2021-05-21 15:26:27 +00:00
Robert Griesemer
cfe0250497 [dev.typeparams] cmd/compile/internal/types2: move struct checking into separate file
This only moves functionality from one file into another.
Except for import adjustments there are no changes to the
code.

Change-Id: I8dff41fe82693c96b09a152975c3fd1e3b439e8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/321589
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>
2021-05-21 15:26:25 +00:00
Robert Griesemer
211244e172 [dev.typeparams] cmd/compile/internal/types2: move interface checking into separate file
This only moves functionality from one file into another.
Except for import adjustments there are no changes to the
code.

Change-Id: Ia7d611d3a01c1ed3331dcc7cfe94a96f87b338e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/321549
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>
2021-05-21 15:26:23 +00:00
Jason A. Donenfeld
7e63c8b765 runtime: wait for Go runtime to initialize in Windows signal test
The test harness waits for "ready" as a sign that the Go runtime has
installed its signal handler and is ready to be tested. But actually,
while LoadLibrary starts the loading of the Go runtime, it does so
asynchronously, so the "ready" sign is potentially premature and
certainly racy. However, all exported cgo entry points make a call to
_cgo_wait_runtime_init_done which waits for that asynchronous
initialization to complete. Therefore, this commit fixes the test to
call into the exported "Dummy" cgo function before emitting the "ready"
sign, so that we're sure the Go runtime is actually loaded.

Updates #45638.

Change-Id: I9b12b172d45bdcc09d54dd301de3a3e499544834
Reviewed-on: https://go-review.googlesource.com/c/go/+/321769
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-21 13:21:00 +00:00
Dan Scales
7b3ee6102d [dev.typeparams] cmd/compile: move to new export version, keep reading previous version
I added constants for the previous export versions, and for the final
generics export version. I also added a const for the current export
version. We can increment the current export version for unstable
changes in dev.typeparams, and eventally set it back to the generics
version (2) before release. Added the same constants in
typecheck/iexport.go, importer/iimport.go, and gcimporter/iimport.go,
must be kept in sync.

Put in the needed conditionals to be able to read old versions.

Added new export/import test listimp.dir.

Change-Id: I166d17d943e07951aa752562e952b067704aeeca
Reviewed-on: https://go-review.googlesource.com/c/go/+/319931
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-05-21 04:03:26 +00:00
Dan Scales
15ad61aff5 [dev.typeparams] cmd/compile: get export/import of generic types & functions working
The general idea is that we now export/import typeparams, typeparam
lists for generic types and functions, and instantiated types
(instantiations of generic types with either new typeparams or concrete
types).

This changes the export format -- the next CL in the stack adds the
export versions and checks for it in the appropriate places.

We always export/import generic function bodies, using the same code
that we use for exporting/importing the bodies of inlineable functions.

To avoid complicated scoping, we consider all type params as unique and
give them unique names for types1. We therefore include the types2 ids
(subscripts) in the export format and re-create on import. We always
access the same unique types1 typeParam type for the same typeparam
name.

We create fully-instantiated generic types and functions in the original
source package. We do an extra NeedRuntimeType() call to make sure that
the correct DWARF information is written out. We call SetDupOK(true) for
the functions/methods to have the linker automatically drop duplicate
instantiations.

Other miscellaneous details:
 - Export/import of typeparam bounds works for methods (but not
   typelists) for now, but will change with the typeset changes.

 - Added a new types.Instantiate function roughly analogous to the
   types2.Instantiate function recently added.

 - Always access methods info from the original/base generic type, since
   the methods of an instantiated type are not filled in (in types2 or
   types1).

 - New field OrigSym in types.Type to keep track of base generic type
   that instantiated type was based on. We use the generic type's symbol
   (OrigSym) as the link, rather than a Type pointer, since we haven't
   always created the base type yet when we want to set the link (during
   types2 to types1 conversion).

 - Added types2.AsTypeParam(), (*types2.TypeParam).SetId()

 - New test minimp.dir, which tests use of generic function Min across
   packages. Another test stringimp.dir, which also exports a generic
   function Stringify across packages, where the type param has a bound
   (Stringer) as well. New test pairimp.dir, which tests use of generic
   type Pair (with no methods) across packages.

 - New test valimp.dir, which tests use of generic type (with methods
   and related functions) across packages.

 - Modified several other tests (adder.go, settable.go, smallest.go,
   stringable.go, struct.go, sum.go) to export their generic
   functions/types to show that generic functions/types can be exported
   successfully (but this doesn't test import).

Change-Id: Ie61ce9d54a46d368ddc7a76c41399378963bb57f
Reviewed-on: https://go-review.googlesource.com/c/go/+/319930
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-21 03:41:18 +00:00
Adam Mitha
831573cd21 io/fs: added an example for io/fs.WalkDir
The documentation currently does not show how to get an `FS` instance for the operating system's filesystem. This example demonstrates how to accomplish this using the `os` package.

Fixes #46083

Change-Id: I053111c12ab09ef13f0d04fcdff8a6ea0dccf379
Reviewed-on: https://go-review.googlesource.com/c/go/+/319989
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-21 03:21:56 +00:00
Dan Scales
468efd5e2f [dev.typeparams] cmd/compile: change method instantiations back to being functions
Change all instantiated methods to being functions again. We found that
this is easier for adding the dictionary argument consistently. A method
wrapper will usually be added around the instantiation call, so that
eliminate the inconsistency in the type of the top-level method and the
the associated function node type.

Change-Id: I9034a0c5cc901e7a89e60756bff574c1346adbc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/321609
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-05-20 23:01:37 +00:00
Tim King
baa934d26d cmd: go get golang.org/x/tools/analysis@49064d23 && go mod vendor
This brings in CLs 312829, 317431, 319211.

Fixes #40356.
Fixes #46129.

Change-Id: I2ee1f858b2a41ffa60d88b0c17511ccad57f1816
Reviewed-on: https://go-review.googlesource.com/c/go/+/321389
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-20 20:37:02 +00:00
Cherry Mui
382c5dd5f7 [dev.typeparams] internal/buildcfg: turn on register ABI on all AMD64 platforms
Register ABI is already enabled by default on AMD64 on Linux
(including Android), macOS, and Windows. This CL enables it on the
rest, specifically, on FreeBSD, OpenBSD, NetBSD, DragonflyBSD,
Solaris (including Illumos), iOS (simulator), and Plan 9.

Change-Id: I80fa20c8bbc8d67b16a19f71b65422e890210ab5
Reviewed-on: https://go-review.googlesource.com/c/go/+/321332
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-20 19:29:30 +00:00
Cherry Mui
240d6d00ca [dev.typeparams] cmd/link: mangle symbol ABI name on Plan 9
It is probably not strictly necessary (as we don't support
external linking on Plan 9). Do it for consistency (and less
confusion).

Change-Id: I0b48562061273ccbd4be83db4a981b8e465b1c95
Reviewed-on: https://go-review.googlesource.com/c/go/+/321331
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>
2021-05-20 19:04:33 +00:00
Cherry Mui
ed2001232a [dev.typeparams] runtime: use internal/abi.FuncPCABI0 for sigtramp PC on Plan 9
Same as CL 313230, for Plan 9.

Change-Id: I0e99c095856c4b21b89abdffa4c0699b24ea9428
Reviewed-on: https://go-review.googlesource.com/c/go/+/321330
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-20 19:04:21 +00:00
Cherry Mui
02117775d1 [dev.typeparams] cmd/compile, runtime: do not zero X15 on Plan 9
On Plan 9, we cannot use SSE registers in note handlers, so we
don't use X15 for zeroing (MOVOstorezero and DUFFZERO). Do not
zero X15 on Plan 9.

Change-Id: I2b083b01b27965611cb83d19afd66b383dc77846
Reviewed-on: https://go-review.googlesource.com/c/go/+/321329
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>
2021-05-20 19:03:48 +00:00
Vishal Dalwadi
7c692cc7ea doc/go1.17: document changes to os package
Documents the changes to File.WriteString method.

For #44513.
Fixes #46018.

Change-Id: I3a8ef9df9f84662614d54802710bd705d626b995
Reviewed-on: https://go-review.googlesource.com/c/go/+/317910
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-05-20 17:40:58 +00:00
Lapo Luchini
ce9a3b79d5 crypto/x509: add new FreeBSD 12.2+ trusted certificate folder
Up to FreeBSD 12.1 the package ca_root_nss was needed in order to have
certificates under /usr/local/share/certs as the base system didn't have
a system trusted certificate store.

This has been fixed in FreeBSD 12.2 using /etc/ssl/certs:
https://svnweb.freebsd.org/base?view=revision&revision=357082

Fixes #46284

Change-Id: I912b1bacc30cdf20d19e3ef9d09b69bb8055ff49
GitHub-Last-Rev: 0fa5542ea3
GitHub-Pull-Request: golang/go#46276
Reviewed-on: https://go-review.googlesource.com/c/go/+/321190
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-05-20 17:06:05 +00:00
Joel Sing
f8be906d74 test: re-enable test on riscv64 now that it supports external linking
Update #36739

Change-Id: I14ab2cd0e29966b9a2f992e8c3bcb415203e63e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/321449
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-20 16:41:09 +00:00
Cherry Mui
def5360541 doc/go1.17: add release notes for OpenBSD ports
Updates #44513.

Change-Id: I8758768f6231fd7fcbaa7109eb49ee56cd60d93d
Reviewed-on: https://go-review.googlesource.com/c/go/+/321310
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-20 16:09:44 +00:00
Cherry Mui
ef1f52cc38 doc/go1.17: add release note for windows/arm64 port
Updates #44513, #42604.

Change-Id: I8200e8087c219a0042ab2a6770a7275c3b17942a
Reviewed-on: https://go-review.googlesource.com/c/go/+/321309
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-20 16:09:29 +00:00
Vishal Dalwadi
bb7495a46d doc/go1.17: document new math constants
Documents the newly introduced:
* MaxInt
* MinInt
* MaxUint

Updates #28538.
For #44513.
Fixes #46012.

Change-Id: Iab6bbcf8f76ebe105b973d5fd39b86b8cd078348
Reviewed-on: https://go-review.googlesource.com/c/go/+/317911
Trust: Heschi Kreinick <heschi@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-20 16:08:35 +00:00
Cherry Mui
a5cd89b8c3 [dev.typeparams] runtime: use internal/abi.FuncPCABI0 and cgo_unsafe_args for Solaris syscall wrappers
Similar to CL 313230, for Solaris (and Illumos). Also mark
functions that take address of one arg and pass to asmcgocall
cgo_unsafe_args, as it effectively takes address of all args.

Change-Id: I4281dd774719fb21ecba82e5ed94a609378a3df5
Reviewed-on: https://go-review.googlesource.com/c/go/+/321314
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-20 16:07:12 +00:00
Michael Anthony Knyszek
f07e4dae3c syscall: document NewCallback and NewCallbackCDecl limitations
Currently NewCallback and NewCallbackCDecl may only be called a limited
number of times in a single Go process, but this property of the API is
not documented. This change fixes that, but does not document the
precise limit to avoid making that limit part of the API, leaving us
open to increasing or decreasing the limit in the future as needed.

Although the API avoids documenting a limit, it does guarantee a minimum
callback count so users can rely on at least some amount of callbacks
working.

Updates #46184.

Change-Id: I5129bf5fe301efff73ac112ba1f207ab32058833
Reviewed-on: https://go-review.googlesource.com/c/go/+/321133
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-20 13:19:43 +00:00
Dmitri Shuralyov
a8d85918b6 misc/cgo/testplugin: skip TestIssue25756pie on darwin/arm64 builder
This test is known to be broken on the darwin/arm64 builder.
Skip it while it's being investigated so it doesn't mask other failures.

For #46239.
Updates #43228.

Change-Id: I8fe57a0636bba84c3100337146dcb96cc264e524
Reviewed-on: https://go-review.googlesource.com/c/go/+/321349
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-20 01:22:28 +00:00
Robert Griesemer
6bdfff112f [dev.typeparams] cmd/compile/internal/types2: use correct type parameter list in missingMethod
For #46275

Change-Id: Iaed9d8ba034ad793e5c57f2be174f01a535fee95
Reviewed-on: https://go-review.googlesource.com/c/go/+/321232
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-05-19 23:43:30 +00:00
Matthew Dempsky
eff66248ea [dev.typeparams] cmd/compile/internal/types2: implement package height
This CL extends types2 with package height information, styled after
the way it works already in cmd/compile:

- A new NewPackageHeight entry point for constructing packages with
  explicit height information, and a corresponding Height accessor
  method.

- The types2 importer is updated to provide package height for
  imported packages.

- The types2 type checker sets height based on imported packages.

- Adds an assertion to irgen to verify that types1 and types2
  calculated the same height for the source package.

- Func.less's ordering incorporates package height to match
  types.Sym.less and is generalized to object.less.

- sortTypes (used for sorting embedded types) now sorts defined types
  using object.less as well.

Change-Id: Id4dbbb627aef405cc7438d611cbdd5a5bd97fc96
Reviewed-on: https://go-review.googlesource.com/c/go/+/321231
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-19 21:53:04 +00:00
Cherry Mui
3f6f12972b [dev.typeparams] runtime: use internal/abi.FuncPCABI0 for sigtramp PC on DragonflyBSD
Same as CL 313230, for DragonflyBSD. sigtramp is the only one we need.

Change-Id: Ic11d0aedc7422512b43b2e4505e8f95056f915bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/321312
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-19 21:39:18 +00:00
Keith Randall
b69347d24a [dev.typeparams] cmd/compile: simplify tparam's type
We just need the type of the param, no need for a full Field.

Change-Id: I851ff2628e1323d971e58d0cabbdfd93c63e1d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/321229
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>
2021-05-19 17:34:24 +00:00
Keith Randall
701bd60646 [dev.typeparams] cmd/compile: simplify targ's type
Make the base type of targ a *types.Type instead of an ir.Node
containing a type.

Also move makeInstName to typecheck, so it can later be used by
reflectdata for making wrappers.

Change-Id: If148beaa972e5112ead2771d6e32d73f16ca30c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/321209
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>
2021-05-19 17:33:56 +00:00
Dmitri Shuralyov
6c1c055d1e cmd/internal/moddeps: use filepath.SkipDir only on directories
If a filepath.WalkFunc returns filepath.SkipDir when invoked on a
non-directory file, it skips the remaining files in the containing
directory.¹

CL 276272 accidentally added a code path that triggers this behavior
whenever filepath.Walk reaches a non-directory file that begins with
a dot, such as .gitattributes or .DS_Store, causing findGorootModules
to return early without finding any modules in GOROOT. Tests that use
it ceased to provide test coverage that the tree is tidy.

Add an explicit check for info.IsDir in the 5 places that intend to
use filepath.SkipDir to skip traversing that directory. Even paths
like GOROOT/bin and GOROOT/pkg which are unlikely to be anything but
a directory are worth checking, since the goal of moddeps is to take
a possibly problematic GOROOT tree as input and detect problems.

While the goal of findGorootModules is to find all modules in GOROOT
programmatically (in case new modules are added or modified), there
are 4 modules now that are quite likely to exist, so check for their
presence to avoid similar regressions. (It's not hard to update this
test if a well-known GOROOT module is removed or otherwise modified;
but if it becomes hard we can simplify it to check for a reasonable
number of modules instead.)

Also fix the minor skew that has crept in since the test got disabled.

¹ This wasn't necessarily an intentional design decision, but it was
  found only when Go 1.4 was already out. See CL 11690 for details.

Fixes #46254.

Change-Id: Id55ed926f8c0094b1af923070de72bacca05996f
Reviewed-on: https://go-review.googlesource.com/c/go/+/320991
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-05-19 15:20:08 +00:00
Michael Pratt
658b5e66ec net: return nil UDPAddr from ReadFromUDP
In cases where the socket operation has no underlying address,
golang.org/cl/291509 unintentionally changed ReadFromUDP from return a
nil *UDPAddr to a non-nil (but zero value) *UDPAddr.

This may break callers that assume "no address" is always addr == nil,
so change it back to remain nil.

Fixes #46238

Change-Id: I8531e8fa16b853ed7560088eabda0b9e3e53f5be
Reviewed-on: https://go-review.googlesource.com/c/go/+/320909
Trust: Michael Pratt <mpratt@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-19 13:04:45 +00:00
Matthew Dempsky
c2966ae272 [dev.typeparams] cmd/compile/internal/ir: more position details in dump
When dumping node positions, include column position and the full
inlining tree. These details are helpful for diagnosing "toolstash
-cmp" failures due to subtly changing positions.

Change-Id: I953292d6c01899fd98e2f315bafaa123c4d98ffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/321089
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-05-19 06:33:22 +00:00
Matthew Dempsky
fb79f6955e [dev.typeparams] cmd/compile/internal/importer: implement position reading
This CL finishes importReader.pos's stub implementation to actually
return syntax.Pos. New PosBase handling is analogous to
typecheck/iimport.go, except for using syntax.PosBase instead of
src.PosBase.

Change-Id: I7629f9f5e69a38ffc2eec772504d6fb2169e1f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/320614
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-19 06:29:50 +00:00
Matthew Dempsky
c92ae885d9 [dev.typeparams] cmd/compile/internal/types2: better recv Var for method expressions
When synthesizing the Signature to represent a method expression, keep
as much of the original parameter as possible, substituting only the
receiver type.

Fixes #46209.

Change-Id: Ic4531820ae7d203bb0ba25a985f72d219b4aa25f
Reviewed-on: https://go-review.googlesource.com/c/go/+/320489
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>
2021-05-19 06:29:40 +00:00
Matthew Dempsky
90b6e72605 [dev.typeparams] cmd/compile/internal/types2: tweak anonymous parameter position
When declaring anonymous parameters, use the syntax.Field's Pos
directly rather than its Type field's Pos. When the type expression is
a qualified identifier (i.e., SelectorExpr), its Pos returns the
position of the dot, whereas we typically declare the anonymous
parameter at the starting position of the type. (We could equivalently
use syntax.StartPos(field.Type), but we already have this as
field.Pos().)

Change-Id: If6ac9635b6e9c2b75a1989d5893a78e0b21cba88
Reviewed-on: https://go-review.googlesource.com/c/go/+/320611
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>
2021-05-19 06:26:57 +00:00
Matthew Dempsky
fc9e64cc98 [dev.typeparams] cmd/compile/internal/types2: fix types2 panic
When reporting a "cannot import package as init" error, we can't rely
on s.LocalPkgName being non-nil, as the original package's name may
already be nil.

Change-Id: Idec006780f12ee4398501d05a5b2ed13157f88ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/320490
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>
2021-05-19 06:26:44 +00:00
Matthew Dempsky
c81562d99f [dev.typeparams] test: update regress tests for types2
Followup to previous commit that extended test/run.go to run more
tests with -G=3. This CL updates a handful of easy test cases for
types2 compatibility.

Change-Id: I58a6f9ce6f9172d61dc25411536ee489ccb03ae0
Reviewed-on: https://go-review.googlesource.com/c/go/+/320610
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-19 06:26:35 +00:00
Robert Griesemer
81b22480cf [dev.typeparams] cmd/compile/internal/syntax: accept embedded type literals
The parser accepted embedded elements but the first term
of an element had to be a ~-term or a type name. This CL
fixes that.

Change-Id: I013b6cdc5963fb228867ca6597f9139db2be7ec5
Reviewed-on: https://go-review.googlesource.com/c/go/+/321109
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>
2021-05-19 04:19:24 +00:00
Cherry Mui
15a374d5c1 test: check portable error message on issue46234.go
issue46234.go expects an error output "segmentation violation",
which is UNIX-specific. Check for "nil pointer dereference"
instead, which is emitted by the Go runtime and should work on all
platforms.

Should fix Windows builders.

Change-Id: I3f5a66a687d43cae5eaf6a9e942b877e5a248900
Reviewed-on: https://go-review.googlesource.com/c/go/+/321072
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>
2021-05-19 01:09:20 +00:00
Russ Cox
eeadce2d87 go/build/constraint: fix parsing of "// +build" (with no args)
"// +build" by itself was like "// +build !" - unsatisfiable.
Make it so again (right now it panics).

Fixes #44487.

Change-Id: Iacbc1398af6f988ef011f9f438e792eb62f8f434
Reviewed-on: https://go-review.googlesource.com/c/go/+/320829
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-05-18 22:36:55 +00:00
Matthew Dempsky
f3fc8b5779 [dev.typeparams] cmd/compile: simplify type alias handling for export
Currently the exporter uses types.IsDotAlias(n.Sym()) to recognize
that n is a type alias, but IsDotAlias is actually meant for
recognizing aliases introduced by dot imports. Translated to go/types,
the current logic amounts recognizing type aliases as if by:

	var n *types.TypeName
	typ, ok := n.Pkg().Scope().Lookup(n.Name()).Type().(*types.Named)
	isAlias := !ok || typ.Obj().Pkg() != n.Pkg() || typ.Obj().Name() != n.Name()

But we can instead just check n.Alias() (eqv. n.IsAlias() in
go/types). In addition to being much simpler, this is also actually
correct for recognizing function-scoped type declarations (though we
don't currently support those anyway, nor would they go through this
exact code path).

To avoid possible future misuse of IsDotAlias, this CL also inlines
its trivial definition into its only call site.

Passes toolstash -cmp, also w/ -gcflags=all=-G=3.

Change-Id: I7c6283f4b58d5311aa683f8229bbf62f8bab2ff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/320613
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-05-18 21:18:56 +00:00
Cherry Mui
140cd7c1d3 [dev.typeparams] runtime: use internal/abi.FuncPCABI0 for syscall wrappers on OpenBSD
Same as CL 313230, for OpenBSD.

Change-Id: I56f4a8a368e1a17615a01db4e2b6c53e4ed263bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/320889
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>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-18 20:56:26 +00:00
Matthew Dempsky
bbc0059b03 [dev.typeparams] test: run more tests with -G=3
This CL expands the current logic for re-running "errorcheck" tests
with -G=3 to run (almost) all regress tests that way. This exposes a
handful of additional failures, so the excluded-files list is expanded
accordingly. (The next CL addresses several of the easy test cases.)

Change-Id: Ia5ce399f225d83e817a046a3bd1a41b9681be3af
Reviewed-on: https://go-review.googlesource.com/c/go/+/320609
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-05-18 20:50:47 +00:00
Matthew Dempsky
f208f1ac99 [dev.typeparams] cmd/compile/internal/ir: more useful Fatalfs
This CL just adds some additional details to existing Fatalf messages
that make them more useful for identifying what went wrong.

Change-Id: Icba0d943ccfb1b810a1ede0977cc8cf22b2afde5
Reviewed-on: https://go-review.googlesource.com/c/go/+/320612
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-05-18 20:23:13 +00:00
Than McIntosh
6d2ef2ef2a cmd/compile: don't emit inltree for closure within body of inlined func
When inlining functions with closures, ensure that we don't mark the
body of the closure with a src.Pos marker that reflects the inline,
since this will result in the generation of an inltree table for the
closure itself (as opposed to the routine that the func-with-closure
was inlined into).

Fixes #46234.

Change-Id: I348296de6504fc4745d99adab436640f50be299a
Reviewed-on: https://go-review.googlesource.com/c/go/+/320913
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
2021-05-18 20:04:57 +00:00
Roland Shoemaker
048cb4ceee crypto/x509: remove duplicate import
Change-Id: I86742ae7aa4ff49a38f8e3bc1d64fb223feae73e
Reviewed-on: https://go-review.googlesource.com/c/go/+/318409
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-05-18 20:00:18 +00:00
Cherry Mui
c7dd3e305d [dev.typeparams] all: merge master (690a8c3) into dev.typeparams
Merge List:

+ 2021-05-18 690a8c3fb1 make.bash: fix misuse of continue
+ 2021-05-18 8b0901fd32 doc/go1.17: fix typo "avoding" -> "avoiding"
+ 2021-05-18 5e191f8f48 time: rewrite the documentation for layout strings
+ 2021-05-17 bfe3573d58 go/token: correct the interval notation used in some panic messages
+ 2021-05-17 a2c07a9a1a all: update golang.org/x/net to latest
+ 2021-05-17 b9b2bed893 syscall: some containers may fail syscall.TestSetuidEtc
+ 2021-05-17 b1aff42900 cmd/go: don't print 'go get' deprecation notices in the main module
+ 2021-05-17 bade680867 runtime/cgo: fix crosscall2 on ppc64x
+ 2021-05-15 ce92a2023c cmd/go: error out of 'go mod tidy' if the go version is newer than supported
+ 2021-05-14 02699f810a runtime: mark osyield nosplit on OpenBSD
+ 2021-05-14 3d324f127d net/http: prevent infinite wait during TestMissingStatusNoPanic
+ 2021-05-14 0eb38f2b16 cmd/go/internal/load: override Package.Root in module mode
+ 2021-05-14 a938e52986 cmd/go: fix a portability issue in the cd script command
+ 2021-05-14 d137b74539 cmd/go: fix spacing in help text of -overlay flag
+ 2021-05-14 c925e1546e cmd/internal/obj/arm64: disable AL and NV for some condition operation instructions
+ 2021-05-14 12d383c7c7 debug/macho: fix a typo in macho.go
+ 2021-05-14 3a0453514a all: fix spelling
+ 2021-05-13 b4833f7c06 cmd/link: always mark runtime.unreachableMethod symbol
+ 2021-05-13 92c189f211 cmd/link: resolve ABI alias for runtime.unreachableMethod
+ 2021-05-13 7a7624a3fa cmd/go: permit .tbd files as a linker flag
+ 2021-05-13 cde2d857fe cmd/go: be less strict about go version syntax in dependency go.mod files
+ 2021-05-13 2a61b3c590 regexp: fix repeat of preferred empty match
+ 2021-05-13 fd4631e24f cmd/compile/internal/dwarfgen: fix DWARF param DIE ordering
+ 2021-05-13 a63cded5e4 debug/dwarf: delay array type fixup to handle type cycles
+ 2021-05-13 0fa2302ee5 cmd/vendor: update golang.org/x/sys to latest
+ 2021-05-13 2c76a6f7f8 all: add //go:build lines to assembly files
+ 2021-05-12 6db7480f59 cmd/go/internal/modload: in updateLazyRoots, do not require the main module explicitly
+ 2021-05-12 f93b951f33 cmd/compile/abi-internal.md: fix table format
+ 2021-05-12 3b321a9d12 cmd/compile: add arch-specific inlining for runtime.memmove
+ 2021-05-12 07ff596404 runtime/internal/atomic: add LSE atomics instructions to arm64
+ 2021-05-12 03886707f9 runtime: fix handling of SPWRITE functions in traceback
+ 2021-05-12 e03383a2e2 cmd/link: check mmap error
+ 2021-05-12 af0f8c149e cmd/link: don't cast end address to int32
+ 2021-05-12 485474d204 cmd/go/testdata/script: fix test failing on nocgo builders
+ 2021-05-12 1a0ea1a08b runtime: fix typo in proc.go
+ 2021-05-11 9995c6b50a cmd/go: ignore implicit imports when the -find flag is set

Change-Id: I843fe029b8ac09424a83e8a4e8bdcc86edd40603
2021-05-18 14:49:21 -04:00
Cherry Mui
077f03f4d8 [dev.typeparams] runtime: use internal/abi.FuncPCABI0 for sigtramp PC on FreeBSD
Same as CL 313230, for FreeBSD. sigtramp is the only one we need.

Change-Id: Iefc00c1cb7e70b08a07c3bc3604b2114fd86563d
Reviewed-on: https://go-review.googlesource.com/c/go/+/320912
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>
2021-05-18 17:15:01 +00:00
Cherry Mui
690a8c3fb1 make.bash: fix misuse of continue
Apparently, in bash, the "continue" keyword can only be used
inside of a loop, not in an if block. If readelf exists but $CC
does not, make.bash emits a warning:

./make.bash: line 135: continue: only meaningful in a `for', `while', or `until' loop

Change it to a conditional.

Change-Id: I00a0940ed99bc0c565094e506705961b6b3d362e
Reviewed-on: https://go-review.googlesource.com/c/go/+/320170
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>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-05-18 15:00:55 +00:00