1
0
mirror of https://github.com/golang/go synced 2024-11-08 13:46:18 -07:00
Commit Graph

55517 Commits

Author SHA1 Message Date
Russ Cox
8a27154bcd cmd/dist: make toolchain build reproducible
- Build cmd with CGO_ENABLED=0. Doing so removes the C compiler
  toolchain from the reproducibility perimeter and also results in
  cmd/go and cmd/pprof binaries that are statically linked,
  so that they will run on a wider variety of systems.
  In particular the Linux versions will run on Alpine and NixOS
  without needing a simulation of libc.so.6.

  The potential downside of disabling cgo is that cmd/go and cmd/pprof
  use the pure Go network resolver instead of the host resolver on
  Unix systems. This means they will not be able to use non-DNS
  resolver mechanisms that may be specified in /etc/resolv.conf,
  such as mDNS. Neither program seems likely to need non-DNS names
  like those, however.

  macOS and Windows systems still use the host resolver, which they
  access without cgo.

- Build cmd with -trimpath when building a release.
  Doing so removes $GOPATH from the file name prefixes stored in the
  binary, so that the build directory does not leak into the final artifacts.

- When CC and CXX are empty, do not pick values to hard-code into
  the source tree and binaries. Instead, emit code that makes the
  right decision at runtime. In addition to reproducibility, this
  makes cross-compiled toolchains work better. A macOS toolchain
  cross-compiled on Linux will now correctly look for clang,
  instead of looking for gcc because it was built on Linux.

- Convert \ to / in file names stored in .a files.
  These are converted to / in the final binaries, but the hashes of
  the .a files affect the final build ID of the binaries. Without this
  change, builds of a Windows toolchain on Windows and non-Windows
  machines produce identical binaries except for the input hash part
  of the build ID.

- Due to the conversion of \ to / in .a files, convert back when
  reading inline bodies on Windows to preserve output file names
  in error messages.

Combined, these four changes (along with Go 1.20's removal of
installed pkg/**.a files and conversion of macOS net away from cgo)
make the output of make.bash fully reproducible, even when
cross-compiling: a released macOS toolchain built on Linux or Windows
will contain exactly the same bits as a released macOS toolchain
built on macOS.

The word "released" in the previous sentence is important.
For the build IDs in the binaries to work out the same on
both systems, a VERSION file must exist to provide a consistent
compiler build ID (instead of using a content hash of the binary).

For #24904.
Fixes #57007.

Change-Id: I665e1ef4ff207d6ff469452347dca5bfc81050e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/454836
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 23:10:31 +00:00
Russ Cox
dbe327a640 make.bash, make.rc: fix GOROOT detection when GOEXPERIMENT is set
We need to clear GOEXPERIMENT any time we are invoking a bootstrap
toolchain. One line missed the clearing of GOEXPERIMENT.

There were three different lines using different syntaxes and subtly
different sets of variables being cleared, so hoist them into a function
so it's all in one place.

Also quote $GOROOT_BOOTSTRAP consistently.



Change-Id: I6c5a5d70c694c24705bbc61298b28ae906c0cf6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456635
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2023-01-17 22:30:56 +00:00
Russ Cox
627765a861 time/tzdata: generate zip constant during cmd/dist
We have a make.bash-time generation capability,
so use it to generate the embedded zip file for time/tzdata.
This is one less file to try to review in CLs like CL 455356.

For #22487.
Fixes #43350.

Change-Id: I2fcd0665fa0b1c830baec5fb4cd714483fea25a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/455357
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2023-01-17 22:30:53 +00:00
Russ Cox
6bb003d032 cmd/go: do not confuse files for standard library packages
I often create dummy files holding various data named things like 'z'.
If a file (not directory) GOROOT/src/z exists, it confuses cmd/go into
thinking z is a standard library package, which breaks the test
Script/mod_vendor.

This CL fixes internal/goroot to only report that something is a standard
library package when a directory with that name exists, not just a file.

Change-Id: I986c9a425e78d23c7e033aeadb8e9f71aab2b878
Reviewed-on: https://go-review.googlesource.com/c/go/+/461955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2023-01-17 22:30:23 +00:00
Matthew Dempsky
f773bef9ab cmd/compile: fix static init inlining for hidden node fields
Unified IR added several new IR fields for holding *runtime._type
expressions. To avoid throwing off any frontend semantics
(particularly inlining cost heuristics), they were marked as
`mknode:"-"` so that code wouldn't visit them.

Unfortunately, this has a bad interaction with the static init
inlining optimization, because the latter relies on ir.EditChildren to
substitute all parameters. This potentially includes dictionary
parameters, which can appear within the new RType fields.

This CL adds a new ir.EditChildrenWithHidden function that also edits
these fields, and switches staticinit to use it. Longer term, we
should unhide the RType fields so that ir.EditChildren visits them
normally, but that's scarier so late in the release cycle.

Fixes #57778.

Change-Id: I98c1e8cf366156dc0c81a0cb79029cc5e59c476f
Reviewed-on: https://go-review.googlesource.com/c/go/+/461686
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-17 22:13:42 +00:00
Robert Griesemer
d45df06663 go/types, types2: more uses of factored functions; generate object_test.go
Change-Id: I7a8366f7dcbd68770b723247ce3e7e81716a8e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/461680
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 19:56:40 +00:00
Robert Griesemer
7da4675dad go/types, types2: use factored parse/typecheck functions, generate hilbert_test.go
Change-Id: I4a325736d18a98bbcd02bfa3d32b1d1dd2048dc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/461609
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:56:39 +00:00
Robert Griesemer
354c8fb436 cmd/compile: remove support for old comparable semantics
Change-Id: I730da5082ea6de1510482aabaa2915e83d3819a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/461607
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:56:37 +00:00
Robert Griesemer
9bd4e9bb1a go/types: consistently use _ prefix for unexported names that are exported in types2
Change-Id: Ic9b24b4b3a6336782023c7db40cc937f2dc743df
Reviewed-on: https://go-review.googlesource.com/c/go/+/461606
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-01-17 19:56:36 +00:00
Robert Griesemer
71971be034 go/types: generate util_test.go, cosmetic changes to generator.go
Change-Id: I80e4bbda302b9170d2367af2442ee282bdf51b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/461679
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-17 19:56:16 +00:00
Robert Griesemer
2f5718a80b go/types: generate unify.go
Change-Id: If94a4c18e954ff403892d0a70e424ab58e997451
Reviewed-on: https://go-review.googlesource.com/c/go/+/461603
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-01-17 19:56:12 +00:00
Robert Griesemer
4cc8d0eea9 go/types: allow filename arguments to generator for easier manual use
Change-Id: I96b25fae1dcbfae55f57c07de9529c6663ad28d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/461602
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:56:10 +00:00
Robert Griesemer
5ce9d9fee8 go/types: use the same interface method sorting as types2
See also CL 321231 which introduces object.less to match
expected compiler behavior.

Change-Id: I56fbf332a04596dc96393b71d40acf4df5d950fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/461677
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-17 19:55:47 +00:00
Robert Griesemer
248950f192 go/types, types2: factor out position comparison, share more code
This CL introduces the new files util.go and util_test.go for both
type checkers; these files factor out functionality that is different
between the type checkers so that more code (that is otherwise mostly
the same) can be generated.

With cmpPos/CmpPos factored out, go/types/scope.go can now be generated.

Change-Id: I35f67e53d83b3c5086a559b1e826db83d38ee217
Reviewed-on: https://go-review.googlesource.com/c/go/+/461596
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-01-17 19:55:42 +00:00
Robert Griesemer
9251822631 go/types, types2: factor out under.go, generate it for go/types
Change-Id: I581be544de313618ccd1e3ef4dc38f1ebf201b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/461495
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-17 19:55:41 +00:00
Robert Griesemer
8ed5a161ce go/types: generate more files from types2 sources
Change-Id: I5e00b4367d7288867b03702d0c76b8210c125668
Reviewed-on: https://go-review.googlesource.com/c/go/+/461083
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:55:39 +00:00
Robert Griesemer
97f843b51f go/types: use nopos instead of token.NoPos to match types2
This will simplify the generation of go/types files from types2 files.

Change-Id: Ie9c8061346cff098cb884908c7eb569267886594
Reviewed-on: https://go-review.googlesource.com/c/go/+/461082
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:55:37 +00:00
Robert Griesemer
f9cba430b2 go/types: generate various source files from types2 files
Starting point for more code sharing.

Change-Id: Ia6bc3ba54476a5202bfd5f89cef09bacb3f4f3b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/460761
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-17 19:55:35 +00:00
Robert Griesemer
4210ebcd08 go/types: make tracing configurable (matching types2)
This CL replaces the internal trace flag with Config.trace.
While unexported, it can still be set for testing via reflection.
The typical use is for manual tests, where -v (verbose) turns on
tracing output. Typical use:

        go test -run Manual -v

This change makes go/types match types2 behavior.

Change-Id: I22842f4bba8fd632efe5929c950f4b1cab0a8569
Reviewed-on: https://go-review.googlesource.com/c/go/+/461081
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-01-17 19:55:08 +00:00
Robert Griesemer
839c842550 go/types, cmd/compile/internal/types2: minor adjustments (cleanups)
go/types:
- gofmt a couple of files

types2:
- add loong64 to sizes list (present in go/types)
- fix a type in validtype.go
- co-locate an accessor with others in typeparam.go

This changes further reduce discrepancy between types2 and go/types.

Change-Id: I2e6a09f1c4b8dbc947c48af13031ff58a2bc6f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/460996
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-17 19:55:06 +00:00
Robert Griesemer
3c357409d1 cmd/compile/internal/syntax: remove Crawl, not needed anymore (cleanup)
This also brings some of the types2 testing code better in sync with
go/types.

Also: fix a minor bug in resolver_test.go (continue traversing
      SelectorExpr if the first part is not an identifier).

Change-Id: Ib6c5f6228812b49c185b52a4f02ca5b393418e01
Reviewed-on: https://go-review.googlesource.com/c/go/+/460760
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 19:55:04 +00:00
Robert Griesemer
d4639ecdfc go/types, types2: test that error format strings have matching parentheses/brackets
Also, for go/types, switch to using syntax.Inspect instead of
(deprecated) syntax.Crawl.

Change-Id: I8333079040e9676e0a61c23d09d41ca790526eeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/460759
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-17 19:55:02 +00:00
Robert Griesemer
cf5dbd4459 go/types, types2: do not abort constraint type inference eagerly
During constraint type inference, unification may fail because it
operates with limited information (core types) even if the actual
type argument satisfies the type constraint in question.

On the other hand, it is safe to ignore failing unification during
constraint type inference because if the failure is true, an error
will be reported when checking instantiation.

Fixes #53650.

Change-Id: Ia76b21ff779bfb1282c1c55f4174847b29cc6f3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/454655
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 19:54:58 +00:00
Robert Griesemer
5cd805c6df go/types, types2: distinguish between substring and regexp error patterns
Use ERROR for substrings, and ERRORx for regexp error patterns.
Correctly unquote patterns for ERROR and ERRORx.
Adjust all tests in internal/types/testdata and locally as needed.

The changes to internal/types/testdata were made through
repeated applications of regexpr find/replace commands
and manual cleanups.

Fixes #51006.

Change-Id: Ib9ec5001243b688bf5aee56b7d4105fb55999ab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/455755
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:54:27 +00:00
Robert Griesemer
b003ee499a internal/types: consistently use double quotes around ERROR patterns
Before matching the pattern, the double quotes are simply stripped
(no Go string unquoting) for now. This is a first step towards use
of proper Go strings as ERROR patterns.

The changes were obtained through a couple of global regexp
find/replace commands:

/\* ERROR ([^"]+) \*/   =>   /* ERROR "$1" */
// ERROR ([^"]+)$       =>   // ERROR "$1"

followed up by manual fixes where multiple "/* ERROR"-style
errors appeared on the same line (in that case, the first
regexp matches the first and last ERROR).

For #51006.

Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/455718
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 19:54:25 +00:00
Robert Griesemer
3af3810a3e go/types, types2: avoid sorting all errors when matching errors
Sorting is only needed if there are multiple matching errors on
the same line. Instead, in that rare case, select the error that
is closest.

Follow-up on CL 456137.

Change-Id: Ia2056b21c629f3a42495e32de89607fbefb82fa7
Reviewed-on: https://go-review.googlesource.com/c/go/+/456335
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-17 19:53:54 +00:00
Robert Griesemer
390eee7ab1 go/types: use commentMap to collect error comments
Adjust the testFiles function to use the new commentMap
function. This makes it possible for testFiles to match
the types2.TestFiles logic more closely.

For #51006.

Change-Id: I6c5ecbeb86d095404ec04ba4452fb90d404b8280
Reviewed-on: https://go-review.googlesource.com/c/go/+/456137
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-17 19:53:51 +00:00
Robert Griesemer
526b8956c2 go/types: add commentMap and test
This adds the (adjusted) syntax.CommentMap function and corresponding
test to the types_test package so that we can use it for collecting
ERROR comments in the next CL.

For #51006.

Change-Id: I63ce96e7394c28c02d5a292250586cc49c1f6e19
Reviewed-on: https://go-review.googlesource.com/c/go/+/456125
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17 19:53:49 +00:00
Robert Griesemer
1e00516583 cmd/compile/internal/syntax: rename ErrorMap to CommentMap, make more flexible
Change the ErrorMap function to collect all comments with a comment
text that matches a given regexp pattern. Also rename it to CommentMap.

Adjust uses and corresponding test.

Adjust various type-checker tests with incorrect ERROR patterns.

For #51006.

Change-Id: I749e8f31b532edbf8568f27ba1546dc849efd143
Reviewed-on: https://go-review.googlesource.com/c/go/+/456155
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cherry Mui <cherryyz@google.com>
2023-01-17 19:53:18 +00:00
Cherry Mui
83f8688915 internal/goversion: update Version to 1.21
This is the start of the Go 1.21 development cycle, so update the
Version value accordingly. It represents the Go 1.x version that
will soon open up for development (and eventually become released).

For #40705.
For #57736.

Change-Id: I31b739f632bdc8d14f46560e0e5bf333fb8e7740
Reviewed-on: https://go-review.googlesource.com/c/go/+/462456
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-01-17 19:47:10 +00:00
Keith Randall
9088c691da cmd/compile: ensure temp register mask isn't empty
We need to avoid nospill registers at this point in regalloc.
Make sure that we don't restrict our register set to avoid registers
desired by other instructions, if the resulting set includes only
nospill registers.

Fixes #57846

Change-Id: I05478e4513c484755dc2e8621d73dac868e45a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/461685
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 18:21:06 +00:00
Alan Donovan
c0799f7015 os: document that Rename is not atomic on non-Unix platforms
Windows provides no reliable way to rename files atomically.

The Plan 9 implementation of os.Rename performs a deletion
if the target exists.

Change-Id: Ife5f9c97b21f48c11e300cd76d8c7f715db09fd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/462395
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-17 18:12:07 +00:00
Filippo Valsorda
d74c31f0ba doc/go1.20: update cryptography release notes
Change-Id: I5d6d2bd5cbb246ea514e5adbe936fb31b92904af
Reviewed-on: https://go-review.googlesource.com/c/go/+/459978
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2023-01-17 18:01:38 +00:00
fangguizhen
8e19929436 strings: remove redundant symbols
Change-Id: Ie3fe0274288d6cb6303acdcec1340c480e5c0b20
GitHub-Last-Rev: ce9d44619e
GitHub-Pull-Request: golang/go#57848
Reviewed-on: https://go-review.googlesource.com/c/go/+/462277
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-17 17:24:17 +00:00
Than McIntosh
6cb8c43b84 cmd/go: include coverage build flags for "go list"
This patch ensures that the go command's "list" subcommand accepts
coverage-related build options, which were incorrectly left out when
"go build -cover" was rolled out. This is needed in order to do things
like check the staleness of an installed cover-instrumented target.

Fixes #57785.

Change-Id: I140732ff1e6b83cd9c453701bb8199b333fc0f2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/462116
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 16:41:24 +00:00
Filippo Valsorda
02ed0e5e67 crypto/ed25519: improve Ed25519ctx docs and add example
Change-Id: Ic215a90d1e1daa5805dbab1dc56480281e53b341
Reviewed-on: https://go-review.googlesource.com/c/go/+/459975
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 16:25:39 +00:00
Filippo Valsorda
f375b305c8 crypto/x509: clarify that CheckSignatureFrom and CheckSignature are low-level APIs
In particular, CheckSignatureFrom just can't check the path length
limit, because it might be enforced above the parent.

We don't need to document the supported signature algorithms for
CheckSignatureFrom, since we document at the constants in what contexts
they are allowed and not. That does leave CheckSignature ambiguous,
though, because that function doesn't have an explicit context.

Change-Id: I4c107440a93f60bc0de07df2b7efeb1a4a766da0
Reviewed-on: https://go-review.googlesource.com/c/go/+/460537
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 16:22:02 +00:00
Russ Cox
8409251e10 cmd/go: document GODEBUG=installgoroot=all
At the moment the only documentation is the release notes,
but everything mentioned in the release notes should have
proper documentation separate from them.

Change-Id: I9885962f6c6d947039b0be59b608385781479271
Reviewed-on: https://go-review.googlesource.com/c/go/+/462196
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-17 16:11:26 +00:00
Russ Cox
66689c7d46 doc/go1.20: remove mention of arena goexperiment
The arena goexperiment contains code used inside Google in very
limited use cases that we will maintain, but the discussion on #51317
identified serious problems with the very idea of adding arenas to the
standard library. In particular the concept tends to infect many other
APIs in the name of efficiency, a bit like sync.Pool except more
publicly visible.

It is unclear when, if ever, we will pick up the idea and try to push
it forward into a public API, but it's not going to happen any time
soon, and we don't want users to start depending on it: it's a true
experiment and may be changed or deleted without warning.

The arena text in the release notes makes them seem more official
and supported than they really are, and we've already seen a couple
blog posts based on that erroneous belief. Delete the text to try to
set expectations better.

Change-Id: I4f6e328ac470a9cd410f5f722d0769ef62d5e5ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/462355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
2023-01-17 15:26:07 +00:00
Russ Cox
145dd38471 archive/tar, archive/zip: document ErrInsecurePath and GODEBUG setting
These are mentioned in the release notes but not the actual doc comments.
Nothing should exist only in release notes.

Change-Id: I8d10f25a2c9b2677231929ba3f393af9034b777b
Reviewed-on: https://go-review.googlesource.com/c/go/+/462195
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17 14:18:16 +00:00
Archana R
1c65b69bd1 runtime: fix performance regression in morestack_noctxt on ppc64
In the fix for 54332 the MOVD R1, R1 instruction was added to
morestack_noctxt function to set the SPWRITE bit. However, the
instruction MOVD R1, R1 results in or r1,r1,r1 which is a special
instruction on ppc64 architecture as it changes the thread priority
and can negatively impact performance in some cases.
More details on such similar nops can be found in Power ISA v3.1
Book II on Power ISA Virtual Environment architecture in the chapter
on Program Priority Registers and Or instructions.
Replacing this by OR R0, R1 has the same affect on setting SPWRITE as
needed by the first fix but does not affect thread priority and
hence does not cause the degradation in performance

Hash65536-64           2.81GB/s ±10%  16.69GB/s ± 0%  +494.44%
Fixes #57741

Change-Id: Ib912e3716c6afd277994d6c1c5b2891f82225d50
Reviewed-on: https://go-review.googlesource.com/c/go/+/461597
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Auto-Submit: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
2023-01-16 08:37:36 +00:00
Bryan Mills
ebb572d82f Revert "internal/fsys: follow root symlink in fsys.Walk"
This reverts CL 448360 and adds a regression test for #57754.

Reason for revert: broke 'go list' in Debian's distribution of the Go toolchain

Fixes #57754.
Updates #50807.

Change-Id: I3e8b9126294c55f21572774b549fb28f29eded0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/461959
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-13 21:45:47 +00:00
Austin Clements
16cec4e7a0 doc/go1.20: mention build speed improvements
For #49569.
For #54202.

Change-Id: Iac45338bc4e45617e8ac7425076cf4cd0af157a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/461957
TryBot-Bypass: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-13 16:42:47 +00:00
Than McIntosh
643f463186 cmd/cover: remove go.mod from testdata subdir
Remove a superfluous go.mod file in one of the testdata subdirs; test
runs ok without it, no need for it to be there (can confuse tooling).

Change-Id: I3c43dd8ca557fdd32ce2f84cdb2427326a2dd35e
Reviewed-on: https://go-review.googlesource.com/c/go/+/461945
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-13 16:01:25 +00:00
Robert Findley
245e95dfab go/types, types2: don't look up fields or methods when expecting a type
As we have seen many times, the type checker must be careful to avoid
accessing named type information before the type is fully set up. We
need a more systematic solution to this problem, but for now avoid one
case that causes a crash: checking a selector expression on an
incomplete type when a type expression is expected.

For golang/go#57522

Change-Id: I7ed31b859cca263276e3a0647d1f1b49670023a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/461577
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-11 22:29:34 +00:00
zhengchaopu
18625d9bec runtime: fix incorrect comment
Fix incorrect comment for the runtime package.

Change-Id: Iab889eff0e9c622afbed959d32b8b5f0ed0bfebf
GitHub-Last-Rev: e9587868db
GitHub-Pull-Request: golang/go#57731
Reviewed-on: https://go-review.googlesource.com/c/go/+/461498
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-11 22:26:01 +00:00
Robert Griesemer
6ad27161f8 cmd/compile: better error message for when a type is in a constraint but not the type set
While at it, also remove the word "constraint" in the detail explanation
of an unsatisfied constraint.

Fixes #57500.

Change-Id: I55dae1694de2cfdb434aeba9d4a3530af7aca8f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/460455
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-11 17:10:19 +00:00
Russ Cox
76d39ae349 cmd/link, runtime: Apple libc atfork workaround take 3
CL 451735 worked around bugs in Apple's atfork handlers by calling
notify_is_valid_token and xpc_atfork_child at startup, so that init
code that wouldn't be safe in the child process would be warmed up in
the parent process instead, but xpc_atfork_child broke use of the xpc
library in Go programs, and xpc is internally used by various macOS
frameworks (#57263).

CL 459175 reverted that change, and then CL 459176 tried a new
approach: use __fork, which doesn't call any of the atfork handlers at all.
That worked, but an Apple engineer reviewing the change in private
email suggests that since __fork is not public API, it should be avoided.
The same engineer (with access to the source code for the xpc library)
suggests that the breakage in #57263 is caused by xpc_atfork_child
marking the library as unusable, expecting an imminent call to exec,
and that calling xpc_date_create_from_current instead would do the
necessary initialization without marking xpc as unusable.

CL 460475 reverted that change, to prepare for this one.

This CL goes back to the original “call functions to warm things up”
approach, replacing xpc_atfork_child with xpc_date_create_from_current.

The CL also updates cmd/link to use OS and SDK version 10.13.0 for
x86 macOS binaries, up from 10.9.0, also suggested by the Apple engineer.
Combined with the two warmup calls, this makes the fork hangs go away.
The minimum macOS version has been 10.13 High Sierra since Go 1.17,
so there should be no problem with writing that in the binaries too.

Fixes #33565.
Fixes #56784.
Fixes #57263.
Fixes #57577.

Change-Id: I20769d9daa1fe9ea930f8009481335f8a14dc21b
Reviewed-on: https://go-review.googlesource.com/c/go/+/460476
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-10 20:34:22 +00:00
Russ Cox
0a0de0fc42 runtime: revert use of __fork to work around Apple atfork bugs
An Apple engineer suggests that since __fork is not public API,
it would be better to use a different fix. With the benefit of source code,
they suggest using xpc_date_create_from_current instead of
xpc_atfork_child. The latter sets some flags that disable certain
functionality for the remainder of the process lifetime (expecting exec),
while the former should do the necessary setup.

Reverting the __fork fix in order to prepare a clean fix based
on CL 451735 using xpc_date_create_from_current.

This reverts commit c61d322d5f.

Change-Id: I2da293ff537237ffd2d40ad756d827c95c84635b
Reviewed-on: https://go-review.googlesource.com/c/go/+/460475
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-10 20:34:19 +00:00
Bryan C. Mills
82f09b75ca os/exec: avoid leaking an exec.Cmd in TestWaitInterrupt
In CL 436655 I added a GODEBUG setting to this test process to verify
that Wait is eventually called for every exec.Cmd before it becomes
unreachable. However, the cmdHang test helpers in
TestWaitInterrupt/Exit-hang and TestWaitInterrupt/SIGKILL-hang
intentially leak a subprocess in order to simulate a leaky third-party
program, as Go users might encounter in practical use.

To avoid tripping over the leak check, we call Wait on the leaked
subprocess in a background goroutine. Since we expect the process
running cmdHang to exit before its subprocess does, the call to Wait
should have no effect beyond suppressing the leak check.

Fixes #57596.
Updates #52580.
Updates #50436.

Change-Id: Ia4b88ea47fc6b605c27ca6d9d7669c874867a900
Reviewed-on: https://go-review.googlesource.com/c/go/+/460998
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-10 17:59:34 +00:00