1
0
mirror of https://github.com/golang/go synced 2024-11-06 09:16:16 -07:00
Commit Graph

54961 Commits

Author SHA1 Message Date
Bryan C. Mills
b820fb8df1 go/build: in TestImportDirTarget, only expect an install target when cgo is enabled
As of CL 448803, packages in GOROOT only have install targets when
they have cgo source files. When cgo is not enabled, that condition
is necessarily false, and no install target will exist.

For #47257.

Change-Id: I653a9c5f89d18a5841810f3de8d490bd7cb7e922
Reviewed-on: https://go-review.googlesource.com/c/go/+/449375
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-11-10 17:06:47 +00:00
David Chase
d33043d37d cmd/compile: add ability to hash-debug on file:line, including inlining
Modified the fmahash gc debug flag to use this, and modified the
test to check for a hash match that includes inlining.  Also
made the test non-short to ensure portability.

Note fma.go has been enhanced into an FMA test that requires
two separate FMAs in order to "fail"; if either one is 2-rounding,
then it "passes".  (It neither passes nor fails here; its role
is to demonstrate that the FMAs are correctly reported; the
enhanced failure mode was discovered while testing the search
tool.)

Change-Id: I4e328e3654f442d498eac982135420abb59c5434
Reviewed-on: https://go-review.googlesource.com/c/go/+/448358
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
2022-11-10 17:02:09 +00:00
Robert Findley
271f139f17 internal/types: fix the iota value in error code declarations
The new "InvalidSyntaxTree" node in the error code declaration
inadvertently incremented the value of iota by 1. Fix this by moving it
to its own declaration.

Change-Id: I34b33a8caddbbb9e41f431321ec0e5863dc15055
Reviewed-on: https://go-review.googlesource.com/c/go/+/449475
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-10 16:34:05 +00:00
Robert Griesemer
d3726f3469 cmd/compile/internal/importer: turn off debugging output
Also, remove `debug` constant. Was not used.
Follow-up on CL 442303.

Fixes #56681.

Change-Id: Ia1499511ba553670617bcb9b7c699412e8df0669
Reviewed-on: https://go-review.googlesource.com/c/go/+/449238
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-10 14:32:22 +00:00
Keith Randall
a11cd6f69a go/doc: recognize methods on generic types as Funcs
When writing markdown for godoc, we can reference a method M of
a type T as [T.M]. This doesn't currently work for methods on generic
types because the declaration of the type parameter gets in the way.
(You'd have to write [T[P].M] and that doesn't parse, and even if it
did you'd have to spell "P" correctly.)

Get rid of the type parameter when building the list of Funcs so
[T.M] works in godoc if T is generic.

Change-Id: I8ef5264124a944967df3ce20ddd40a2447ff4187
Reviewed-on: https://go-review.googlesource.com/c/go/+/449236
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-10 06:33:18 +00:00
Ian Lance Taylor
c3d444d098 os/user: allocate buffers in Go memory, not C memory
Since the first implementation of os/user, it's called C malloc
to allocate memory for buffers. However, the buffers are just
used for temporary storage, and we can just a []byte instead.

To make this work without causing cgo pointer errors, we move
the pwd and grp structs into C stack memory, and just return them.
It's OK to store a Go pointer on the C stack temporarily.

Change-Id: I9f8ffb6e51df1e585276c259fe99359d7835df87
Reviewed-on: https://go-review.googlesource.com/c/go/+/449335
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-10 05:54:51 +00:00
cui fliter
d2aa787f2a expvar: convert f to atomic type
For #53821

Change-Id: I2e7c5376e6ca3e3dbb2f92ad771aed62fca8b793
GitHub-Last-Rev: b67ddf81ec
GitHub-Pull-Request: golang/go#54864
Reviewed-on: https://go-review.googlesource.com/c/go/+/428195
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-11-10 05:17:55 +00:00
Russ Cox
db259cdd80 cmd/go: cache compiler flag info
When you run 'go env' or any command that needs to consider
what the default gcc flags are (such as 'go list net' or
'go list <any package with net as a dependency>'),
the go command runs gcc (or clang) a few times to see what
flags are available.

These runs can be quite expensive on some systems, particularly
Macs that seem to need to occasionally cache something before
gcc/clang can execute quickly.

To fix this, cache the derived information about gcc under a cache
key derived from the size and modification time of the compiler binary.
This is not foolproof, but it should be good enough.

% go install cmd/go
% time go env >/dev/null
        0.22 real         0.01 user         0.01 sys
% time go env >/dev/null
        0.03 real         0.01 user         0.01 sys
%

Fixes #50982.

Change-Id: Iba7955dd10f610f2793e1accbd2d06922f928faa
Reviewed-on: https://go-review.googlesource.com/c/go/+/392454
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-11-10 04:09:44 +00:00
Russ Cox
cb6e4f08c2 cmd/api: point to API docs in all.bash failure
When people add new API and get an all.bash failure,
they often don't know about the API checker at all.
Point to the README in the failure message, to try to
help them find what they need to know.

Change-Id: I6b148ec414d212033b371357a5e8c6ab79bb50a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/449015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-11-10 04:08:52 +00:00
Aleks Rudzitis
e48fc2665e crypto: allow hash.Hash for OAEP and MGF1 to be specified independently
crypto/rsa assumes RSA OAEP uses the same hash to be used for both the label
and the mask generation function. However, implementations in other languages,
such as Java and Python, allow these parameters to be specified independently.

This change allows the MGF hash to be specified independently for decrypt
operations in order to allow decrypting ciphertexts generated in other
environments.

Fixes: #19974
Change-Id: If453d628f0da354ceb3b52863f30087471670f7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/418874
Auto-Submit: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
2022-11-09 23:51:34 +00:00
Constantin Konstantinidis
89332e037a encoding/xml: error when more than one colon in qualified names
Add test.

Fixes #20396

Change-Id: I89e9013eb338f831e1908e390b284794df78fb6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/103875
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-11-09 22:56:44 +00:00
Constantin Konstantinidis
bef5eca118 encoding/xml: disallow empty namespace when prefix is set
Non-regression tests are added.

Fixes #8068

Change-Id: Icb36c910bbf4955743b7aa8382002b2d9246fadc
Reviewed-on: https://go-review.googlesource.com/c/go/+/105636
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-11-09 22:45:43 +00:00
Bryan C. Mills
e70f74b0aa api/next/54299: add missing newline
Updates #54299.

Change-Id: I20a9191fa3c78810987ace69527d34091c4a42fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/449215
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-09 22:23:18 +00:00
Matthew Dempsky
42768b4c26 unsafe: add docs for SliceData, String, and StringData
Updates #53003.

Change-Id: I076d1eb4bd0580002ad8008f3ca213c5edc951ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/427095
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-09 22:11:13 +00:00
Damien Neil
739618945e Revert "path/filepath: change IsAbs("NUL") to return true"
This reverts commit d154ef60a0.

This change made IsAbs return true for certain reserved filenames,
but does not consistently detect reserved names. For example,
"./COM1", "//./COM1", and (on some Windows versions) "COM1.txt"
all refer to the COM1 device, but IsAbs detects none of them.

Since NUL is not an absolute path, do not attempt to detect it
or other device paths in IsAbs. See #56217 for more discussion
of IsAbs and device paths.

For #56217.

Change-Id: If4bf81c7e1a2e8842206c7c5268555102140dae8
Reviewed-on: https://go-review.googlesource.com/c/go/+/448898
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2022-11-09 22:06:26 +00:00
Damien Neil
61c57575cd os: remove special casing of NUL in Windows file operations
Some file operations, notably Stat and Mkdir, special cased their
behavior when operating on a file named "NUL" (case-insensitive).
This check failed to account for the many other names of the NUL
device, as well as other non-NUL device files: "./nul", "//./nul",
"nul.txt" (on some Windows versions), "con", etc.

Remove the special case.

os.Mkdir("NUL") now returns no error. This is consonant with the
operating system's behavior: CreateDirectory("NUL") succeeds, as
does "MKDIR NUL" on the command line.

os.Stat("NUL") now follows the existing path for FILE_TYPE_CHAR devices,
returning a FileInfo which correctly reports the file as being a
character device.

os.Stat and os.File.Stat have common elements of their logic unified.

For #24482.
For #24556.
For #56217.

Change-Id: I7e70f45901127c9961166dd6dbfe0c4a10b4ab64
Reviewed-on: https://go-review.googlesource.com/c/go/+/448897
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2022-11-09 22:06:14 +00:00
Damien Neil
be9d78c9c5 path/filepath: detect all forms of \\ volume paths on Windows
Previously, the volumeNameLen function checked for UNC paths starting
with two slashes, a non-'.' character, and another slash. This misses
volume names such as "\\.\C:\".

The previous check for volume names rejects paths beginning
with "\\.". This is incorrect, because while these names are not
UNC paths, "\\.\C:\" is a DOS device path prefix indicating the
C: device. It also misses UNC path prefixes in the form
"\\.\UNC\server\share\".

The previous check for UNC paths also rejects any path with an
empty or missing host or share component. This leads to a number
of possibly-incorrect behaviors, such as Clean(`\\a`) returning `\a`.
Converting the semantically-significant `\\` prefix to a single `\`
seems wrong.

Consistently treat paths beginning with two separators as having
a volume prefix.

Update VolumeName to detect DOS device paths (`\\.\` or `\\?\`),
DOS device paths linking to UNC paths (`\\.\UNC\Server\Share`
or `\\?\UNC\Server\Share`), and UNC paths (`\\Server\Share\`).

	Clean(`\\a`) = `\\a`
	Join(`\\`, `a`, `b`) = `\\a\b`

In addition, normalize path separators in VolumeName for consistency
with other functions which Clean their result.

Fixes #56336

Change-Id: Id01c33029585bfffc313dcf0ad42ff6ac7ce42fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/444280
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-11-09 22:06:00 +00:00
Damien Neil
575964d42c cmd/go: improve handling of os.DevNull on Windows
The "go test" and "go build" commands have special-case behavior when
passed "-o /dev/null". These checks are case-sensitive and assume that
os.DevNull is an absolute path. Windows filesystems are case-insensitive
and os.DevNull is NUL, which is not an absolute path.

CL 145220 changed filepath.IsAbs to report "NUL" as absolute to work
around this issue; that change is being rolled back and a better fix here
is to compare the value of -o against os.DevNull before attempting to
merge it with a base path. Make that fix.

On Windows, accept any capitilization of "NUL" as the null device.

This change doesn't cover every possible name for the null device, such
as "-o //./NUL", but this test is for efficiency rather than correctness.
Accepting just the most common name is fine.

For #56217.

Change-Id: I60b59b671789fc456074d3c8bc755a74ea8d5765
Reviewed-on: https://go-review.googlesource.com/c/go/+/449117
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-09 22:05:51 +00:00
Bryan C. Mills
0521a12401 doc/go1.20: add a release note for os/exec API changes
Updates #50436.

Change-Id: Ib6771221bda1c81d5593b29d7287ebcf169882ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/449076
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-11-09 22:04:07 +00:00
rleungx
d02fceb95e cmd/go: mod vendor: emit error if any replacement in vendor directory
Fixes #29169

Change-Id: I3a0fd506c45ad999a2fc6f75f9b3e8a5118ad91b
Reviewed-on: https://go-review.googlesource.com/c/go/+/156400
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-11-09 19:40:02 +00:00
Michael Matloob
f5d21ffc81 cmd/go: decide whether to install .a based on number of CgoFiles
Instead of hardcoding the set of five packages that depend on cgo to
decide whether a package should have an install target, make the
decision based on whether the package has any CgoFiles. This means that
in nocgo configurations, there will be no installed packages, and that
if an GOOS/GOARCH combination doesn't have cgo files we don't
unnecessarily install a .a.

Because the determination of whether a file is a CgoFile is made later
in the Import functions, the choice of whether to add a PkgObj for teh
case there are CgoFiles is moved later. One concern here is that in some
cases, PkgObj may be set differently in the case of the FindOnly mode,
since the determination is moved across the boundary. We might want
to always set PkgObj after the FindOnly boundary for consistency? cmd/go
doesn't seem to use it when calling Import with FindOnly.

Also remove internal/buildinternal/needs_install.go because we will be
checking whether to install based on the number of cgo files and it
might be overkill to make the NeedsInstalledDotA function be the
equivalent of len(input) > 0.

For #47257

Change-Id: I5f7f2137dc99aaeb2e2695c14e0222093a6b2407
Reviewed-on: https://go-review.googlesource.com/c/go/+/448803
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2022-11-09 19:37:08 +00:00
Damien Neil
342751a695 cmd/go/testdata: don't set GOPATH=NUL in test
An upcoming change to the filepath package to make IsAbs("NUL")==false
on Windows will cause this test to fail, since it sets GOPATH=NUL and
GOPATH must be an absolute path.

Set GOPATH to the name of a text file instead. (The intent is that GOPATH
be set to a path that is not writable.)

For #56217.

Change-Id: I18e645fe11547d02d1a2e0e580085e6348c4009a
Reviewed-on: https://go-review.googlesource.com/c/go/+/448896
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-09 18:21:12 +00:00
Michael Matloob
4f13067f8a internal/fsys: follow root symlink in fsys.Walk
If fsys.Walk is called with a root directory that is a symlink, follow
the symlink when doing the walk. This allows for users setting their
current directory to a symlink to a module.

Fixes #50807

Change-Id: Ie65a7cb804b87dea632ea6c758c20adcfa62fcd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/448360
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-09 18:07:37 +00:00
cuiweixie
2f4d5c3b79 net/http: add Transport.OnProxyConnectResponse
Fixes #54299

Change-Id: I3a29527bde7ac71f3824e771982db4257234e9ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/447216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-11-09 17:41:34 +00:00
Damien Neil
cd8d1bca2c cmd/go: more informative test failures when GOROOT is stale
If GOROOT is stale, test fail when commands unexpectedly write to GOROOT.
Include an message in the test failure indicating that this is a possible
and expected reason for the failure, and how to fix it.

For #48698.

Change-Id: I057c20260bab09aebf684e8f20794ab8fc0ede1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/448895
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2022-11-09 17:39:55 +00:00
Russ Cox
7a92c4fc63 cmd/go: print test2json start events
Add a new "Action":"start" test2json event to mark the
start of the test binary execution. This adds useful information
to the JSON traces, and it also lets programs watching test
execution see the order in which the tests are being run,
because we arrange for the starts to happen sequentially.

Change-Id: I9fc865a486a55a7e9315f8686f59a2aa06455884
Reviewed-on: https://go-review.googlesource.com/c/go/+/448357
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-09 17:33:07 +00:00
Russ Cox
9ff2a6677f crypto/x509: allow BoringCrypto to use 4096-bit keys
FIPS-140 has been updated to allow 4096-bit RSA keys.
Allow them in certificate processing.

Fixes #41147.

Change-Id: I4c6bcb1b137a200dfe70cebc605ae57f49871184
Reviewed-on: https://go-review.googlesource.com/c/go/+/447655
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-11-09 14:47:58 +00:00
cui fliter
821e31042a all: add missing copyright header
Change-Id: Ia5a090953d324f0f8aa9c1808c88125ad5eb6f98
Reviewed-on: https://go-review.googlesource.com/c/go/+/448955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-11-09 14:05:53 +00:00
Guoqi Chen
3a41094107 runtime: using wyrand for fastrand on linux/loong64
Benchmarks on linux/loong64:
name               old time/op    new time/op    delta
Fastrand           4.06ns ± 0%    3.60ns ± 0%    -11.29%  (p=0.000 n=32+27)
Fastrand64         7.20ns ± 0%    7.16ns ± 0%     -0.52%  (p=0.000 n=23+31)
FastrandHashiter   49.5ns ± 1%    48.9ns ± 2%     -1.24%  (p=0.000 n=32+32)
Fastrandn/2        4.45ns ± 0%    3.81ns ± 0%    -14.37%  (p=0.000 n=32+32)
Fastrandn/3        4.45ns ± 0%    3.81ns ± 0%    -14.32%  (p=0.000 n=32+32)
Fastrandn/4        4.45ns ± 0%    3.81ns ± 0%    -14.33%  (p=0.000 n=31+32)
Fastrandn/5        4.44ns ± 0%    3.81ns ± 0%    -14.26%  (p=0.000 n=31+30)

Change-Id: I0aba7d2331221426c44cc0d0dddecca3b585fda4
Reviewed-on: https://go-review.googlesource.com/c/go/+/446896
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-11-09 06:30:59 +00:00
Wayne Zuo
268f4629df cmd/compile: enable brachelim pass on loong64
Change-Id: I4fd1c307901c265ab9865bf8a74460ddc15e5d14
Reviewed-on: https://go-review.googlesource.com/c/go/+/416735
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
2022-11-09 06:10:55 +00:00
cui fliter
6b45863e47 all: fix some comments
Change-Id: I163ea3a770f2228f67d4fb1374653566e64b91f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/448575
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-11-09 04:03:15 +00:00
Daulet Zhanguzin
27c3814275 io: correctly process result of sendfile(2) when src returns 0 bytes
Fixes #53658. io.Copy() uses sendfile(2) to avoid allocating extra buffers when src is a file and dst is a TCPConn. However if src returns no bytes current logic treats it as failure and falls back to copying via user space. The following is a benchmark that illustrates the bug.

Benchmark: https://go.dev/play/p/zgZwpjUatSq

Before:
BenchmarkCopy-16          541006              2137 ns/op            4077 B/op          0 allocs/op

After:
BenchmarkCopy-16          490383              2365 ns/op             174 B/op          8 allocs/op

Change-Id: I703376d53b20e080c6204a73c96867cce16b24cf
GitHub-Last-Rev: 3a50be4f16
GitHub-Pull-Request: golang/go#53659
Reviewed-on: https://go-review.googlesource.com/c/go/+/415834
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-09 03:01:33 +00:00
Constantin Konstantinidis
f13849a7af encoding/xml: error when closing tag does not match opening tag
Comparing opening and closing tag is done using the prefix when available.
Documentation states that Token returns URI in the Space part of the Name.
Translation has been moved for the End tag before the namespace is removed
from the stack.

After closing a tag using a namespace, the valid namespace must be taken
from the opening tag. Tests added.

Fixes #20685

Change-Id: I4d90b19f7e21a76663f0ea1c1db6c6bf9fd2a389
Reviewed-on: https://go-review.googlesource.com/c/go/+/107255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-11-09 03:01:28 +00:00
Constantin Konstantinidis
b459166219 encoding/xml: add check of namespaces to detect field names conflicts
Test added.

Fixes #8535

Change-Id: Ic89c2781e81d963a653180812748b3fc95fb7fae
Reviewed-on: https://go-review.googlesource.com/c/go/+/106575
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-11-09 03:01:25 +00:00
Matthew Horsnell
fe4e59e78b runtime internal/cpu: rename "Zeus" "NeoverseV1".
Rename "Zeus" to "NeoverseV1" for the partnum 0xd40 to be
consistent with the documentation of MIDR_EL1 as described in
https://developer.arm.com/documentation/101427/0101/?lang=en

Change-Id: I2e3d5ec76b953a831cb4ab0438bc1c403648644b
Reviewed-on: https://go-review.googlesource.com/c/go/+/414775
Reviewed-by: Jonathan Swinney <jswinney@amazon.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-11-08 23:11:32 +00:00
Russ Cox
896faf306c net: allocate res_state entirely in C memory
The linux-amd64-wsl builder was failing because the res_nsearch
implementation was storing pointer to the res_state's own fields
in other fields in the res_state. If the res_state is Go memory, this
looks like pointers to Go pointers. Moving the res_state to C memory
avoids the problem.

The linux-amd64-wsl builder has been fixed a different way by
replacing res_nsearch with res_search on Linux, where it is thread-safe.
But other systems that still need to use res_nsearch (such as macOS)
may run into the same kind of problem, so it is probably still worth
arranging for the res_state to live entirely in C memory.

Fixes #56658 (again).

Change-Id: I58a14e72c866eaceb02ad828854a1f626b9b8e73
Reviewed-on: https://go-review.googlesource.com/c/go/+/448798
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-08 22:14:56 +00:00
Xiangdong Ji
8befe0e408 runtime: fix uncondition calls to traceGCSTWDone
startTheWorldWithSema should call traceGCSTWDone only when
the tracing is enabled.

Change-Id: Ibc7181834f68af3923e4b2aee01a57492ab6213e
Reviewed-on: https://go-review.googlesource.com/c/go/+/330835
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-08 21:50:06 +00:00
Jakub Ciolek
2df6c1abce runtime: remove the started field from sweepdata
This bool doesn't seem to be used anymore. Remove it.

Change-Id: Ic73346a98513c392d89482c5e1d818a90d713516
Reviewed-on: https://go-review.googlesource.com/c/go/+/419654
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-11-08 21:31:58 +00:00
Matthew Dempsky
9944ba757b cmd/compile: fix transitive inlining of generic functions
If an imported, non-generic function F transitively calls a generic
function G[T], we may need to call CanInline on G[T].

While here, we can also take advantage of the fact that we know G[T]
was already seen and compiled in an imported package, so we don't need
to call InlineCalls or add it to typecheck.Target.Decls. This saves us
from wasting compile time re-creating DUPOK symbols that we know
already exist in the imported package's link objects.

Fixes #56280.

Change-Id: I3336786bee01616ee9f2b18908738e4ca41c8102
Reviewed-on: https://go-review.googlesource.com/c/go/+/443535
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2022-11-08 21:26:09 +00:00
Russ Cox
a7538d7821 net: fix res_search uses on alpine, android, dragonfly
On Android and Dragonfly, don't use -lresolv. It doesn't exist there.

On Linux, use res_search instead of res_nsearch.
glibc makes res_search thread-safe by having a per-thread __res.
It still also provides res_nsearch.
musl makes res_search thread-safe by ignoring __res completely.
It does not provide res_nsearch at all.
Changing to res_search on Linux will fix builds on musl-based systems
while keeping glibc-based systems working.

Fixes #56657.
Fixes #56660.

Change-Id: Id87dde6c8bbf6c0d34543c09782f3871489c8712
Reviewed-on: https://go-review.googlesource.com/c/go/+/448797
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-08 20:59:42 +00:00
Russ Cox
12ab0ac184 net: pass C string to res_nsearch, in case it stores the pointer
The current code passes a Go pointer to a NUL-terminated C string
to the C function res_nsearch (or res_search), but that function may
in turn store the pointer into the res_state, which is a violation of the
cgo pointer rules and is being detected on the linux-amd64-wsl builder.

Allocating the string in C memory is safer and should resolve
the cgo pointer check. When using libc/syscall mode, the memory
is still allocated Go-side, which could potentially be a problem
if we ever add a moving collector. For now it is OK.

Fixes #56658.

Change-Id: Ibd84a9665be16c71994ddb1eedf09d45a6553a3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/448795
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
2022-11-08 20:59:36 +00:00
Damien Neil
a6642e67e1 net/textproto: reject invalid header keys/values in ReadMIMEHeader
Return an error when parsing a MIME header containing bytes in the
key or value outside the set allowed by RFC 7230.

For historical compatibility, accept spaces in keys (but do not
canonicalize the key in this case).

For #53188.

Change-Id: I195319362a2fc69c4e506644f78c5026db070379
Reviewed-on: https://go-review.googlesource.com/c/go/+/410714
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-11-08 20:36:15 +00:00
qmuntal
41be62e168 cmd/go: fix svn vctest on Windows and make them timezone agnostic
This CL updates svn vctest so they work on Windows.

Side effect is that svn logs are no longer timezone dependant, as this
updated the `svn log` command to format logs using XML, which contain
UTC dates instead of local dates. Therefore it supersedes
https://go-review.googlesource.com/c/go/+/447795.

Fixes #56555
Fixes #56527

Change-Id: I5a654fd0a0f741e0a8a6ca7021ad699c07b974d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/447935
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2022-11-08 19:37:03 +00:00
Cherry Mui
4b43b74171 cmd/go: add -pgo build flag
Add a -pgo flag for "go build" (and other build actions), to
specify the file path of a profile used for PGO. Special name
"off" turns off PGO.

The given profile path is passed to the compiler.

The build cache is sensitive to the content of the given PGO
profile.

TODO: auto mode.

For #55022.

Change-Id: Ieee1b131b4c041f9502fd0a1acf112f3e44246be
Reviewed-on: https://go-review.googlesource.com/c/go/+/438736
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-08 18:50:59 +00:00
Michael Anthony Knyszek
41795528b0 runtime: smooth cons/mark with a moving average and use actual trigger
This change modifies the pacer in two ways:
* It replaces the PI controller used as a smoothing function with a
  simple two-cycle moving average.
* It makes the pacer use the actual GC trigger point for cons/mark (and
  other) calculations instead of the precomputed one.

The second part of this change was attempted in the Go 1.19 release
cycle, but could not be done because although it resulted in a
better-behaved pacer, it exploited the PI controller's sensitivity to
history in a way that was ultimately unfavorable for most applications.

This sensitivity is complex to reason about, and forces us into choices
that don't really make sense (like using the precomputed trigger over
the actual one -- that's really a bug fix).

The net effect of this change is intended to be:
* The pacer computes a more stable estimate of the actual cons/mark
  ratio, making it easier to understand.
* The pacer is much more accurate at hitting the heap goal, so the GC
  respects GOGC much more often and reliably.
* The pacer forces a more stable rate of GC assists in the
  steady-state overall.

See https://perf.golang.org/search?q=upload:20221106.10 for benchmark
results and #53892 for complete context. The benchmarks that regress
in memory use appear to be not worth worrying about. In all cases, it appears that the GC was triggering super early, resulting in a lack
of adherence to rule of GOGC.

The fogleman benchmarks just have a single final GC that triggers
early and also happens to be the peak heap size. The tile38
WithinCircle benchmark only has 4 GC cycles in the benchmarked region,
so it's very sensitive to pacing. In this case, the old smoothing
function is getting lucky by starting way too early, avoiding assists. Meanwhile the 2-cycle moving average is more accurate on the heap
goal, but the 1st and 2nd cycle after the initialization phase are operating on a cons/mark from the initialization phase which is much
less active, resulting in a cons/mark that's too low, causing the GC
to start too late, increasing assists, and therefore latency (but
only transiently, at this phase change). I really do think the PI
controller is just getting lucky here with a particular history,
because I've definitely observed it oscillating wildly in response to
a phase change.

This change also moves the PI controller out of mgcpacer.go, because
it's no longer used there. It now lives in mgcscavenge.go, where it's
actually used.

Fixes #53892.

Change-Id: I3f875a2e40f31f381920f91d8b090556b17a2b16
Reviewed-on: https://go-review.googlesource.com/c/go/+/417558
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-08 18:45:45 +00:00
Tobias Klauser
26b2c9a620 reflect: use unsafe.String in name.name and name.tag
Change-Id: I9f54f1463b0682d0d76cd57e5fef318565883a87
Reviewed-on: https://go-review.googlesource.com/c/go/+/448675
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-11-08 18:33:21 +00:00
Cherry Mui
e5d2814576 cmd/compile: adjust PGO debug output slightly
- Include the callee names in hot call inlining message.
- Print the graph when pgoinline >= 2.

Change-Id: Iceb89b5f18cefc69ab9256aca9a910743d22ec0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/448496
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-11-08 18:10:43 +00:00
Cherry Mui
efe541d4e5 cmd/compile/internal/pgo: allow and ignore profiles with no sample
Passing a profile with no sample is arguably not a user error.
Accept such a profile, and ignore it as it doesn't indicate any
optimizations. This also makes testing easier.

Change-Id: Iae49a4260e20757419643153f50d8d5d51478411
Reviewed-on: https://go-review.googlesource.com/c/go/+/448495
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-11-08 18:10:34 +00:00
Cherry Mui
0409314db3 cmd/compile: fix PGO line offset matching
Appears to be a typo in CL 447315.

Change-Id: I9f380a3c7521f5ac5a1d7e271eaa60bd4bbcfb29
Reviewed-on: https://go-review.googlesource.com/c/go/+/448515
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-11-08 16:35:09 +00:00
Russ Cox
6939659a08 net: unify CNAME handling across ports
Unix and Windows differ in how they handle LookupCNAME(name).

If name exists in DNS with an A or AAAA record but no CNAME,
then on all operating systems and in the pure Go resolver,
LookupCNAME returns the name associated with the A/AAAA record
(the original name).

TestLookupCNAME has been testing this, because www.google.com
has no CNAME. I think it did at one point, but not anymore, and the
tests are still passing. Also added google.com as a test, since
top-level domains are disallowed from having CNAMEs.

If name exists in DNS with a CNAME record pointing to a record that
does not exist or that has no A or AAAA record,
then Windows has always reported the CNAME value,
but Unix-based systems and the pure Go resolver have reported
a failure instead. cname-to-txt.go4.org is an test record that is
a CNAME to a non-A/AAAA target (the target only has a TXT record).

This CL changes the Unix-based systems and the pure Go resolver
to match the Windows behavior, allowing LookupCNAME to succeed
whenever a CNAME exists.

TestLookupCNAME nows tests the new behavior by looking up
cname-to-txt.go4.org (run by bradfitz).

Fixes #50101.

Change-Id: Ieff5026c8535760e6313c7a41ebd5ff24de6d9be
Reviewed-on: https://go-review.googlesource.com/c/go/+/446179
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-08 14:54:25 +00:00