Loading and calling testHookCanceledDial in the function passed to
context.AfterFunc is racey, because the function runs in a separate
goroutine, and is not synchronized with the test code that restores
the original testHookCanceledDial value.
We could add a channel and wait for the "AfterFunc" to return in
the deferred function, but that's a lot of synchronization overhead
just for a bit of test code. Instead we simply load
testHookCanceledDial into a local variable synchronously. This fixes
the race without introducing any overhead.
Fixes #75474
Change-Id: If8fbd0f5f65375577c2ded64a13a15b406c45ecc
Reviewed-on: https://go-review.googlesource.com/c/go/+/704455 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Damien Neil [Mon, 15 Sep 2025 22:18:57 +0000 (15:18 -0700)]
net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.
The race occurs when:
- A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
and receives an isNoCachedConn error. The call removes the pconn from
the idle conn pool and decrements the connCount for its host.
- A second RoundTrip call on the same pconn succeeds,
and delivers the pconn to a third RoundTrip waiting for a conn.
- The third RoundTrip receives the pconn at the same moment its request
context is canceled. It places the pconn back into the idle conn pool.
At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.
Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.
Fixes #61474
Change-Id: I104d6cf85a54d0382eebf3fcf5dda99c69a7c3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703936
Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Damien Neil [Thu, 18 Sep 2025 18:15:47 +0000 (11:15 -0700)]
context: don't return a non-nil from Err before Done is closed
The Context.Err documentation states that it returns nil if the
context's done channel is not closed. Fix a race condition introduced
by CL 653795 where Err could return a non-nil error slightly before
the Done channel is closed.
No impact on Err performance when returning nil.
Slows down Err when returning non-nil by about 3x,
but that's still almost 2x faster than before CL 653795
and the performance of this path is less important.
(A tight loop checking Err for doneness will be terminated
by the first Err call to return a non-nil result.)
goos: darwin
goarch: arm64
pkg: context
cpu: Apple M4 Pro
│ /tmp/bench.0 │ /tmp/bench.1 │
│ sec/op │ sec/op vs base │
ErrOK-14 1.806n ± 1% 1.774n ± 0% -1.77% (p=0.000 n=8)
ErrCanceled-14 1.821n ± 1% 7.525n ± 3% +313.23% (p=0.000 n=8)
geomean 1.813n 3.654n +101.47%
Fixes #75533
Change-Id: Iea22781a199ace7e7f70cf65168c36e090cd2e2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/705235
TryBot-Bypass: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Michael Pratt [Wed, 17 Sep 2025 17:25:03 +0000 (13:25 -0400)]
runtime: make explicit nil check in heapSetTypeSmallHeader
This is another case very similar to CL 684015 and #74375.
In spans with type headers, mallocgc always writes to the page before
returning the allocated memory. This initial write is done by
runtime.heapSetTypeSmallHeader. Prior to the write, the compiler inserts
a nil check, implemented as a dummy instruction reading from memory.
On a freshly mapped page, this read triggers a page fault, mapping the
zero page read-only. Immediately afterwards, the write triggers another
page fault, copying to a writeable page and performing a TLB flush.
This problem is exacerbated as the process scales up. At GOMAXPROCS=6,
the tile38 sweet benchmark spends around 0.1% of cycles directly
handling these page faults. On the same machine at GOMAXPROCS=192, it
spends about 2.7% of cycles directly handling these page faults.
Replacing the read with an explicit nil check reduces the direct cost of
these page faults down to around 0.1% at GOMAXPROCS=192. There are
additional positive side-effects due to reduced contention, so the
overall time spent in page faults drops from around 12.8% to 6.8%. Most
of the remaining time in page faults is spent on automatic NUMA page
migration (completely unrelated to this issue).
cmd/internal/obj/riscv: add support for Zicond instructions
This patch implement assembler for the Zicond extension: CZEROEQZ and CZERONEZ.
Follow-up to CL 631576
Updates #75350
Change-Id: Icf4be131fe61c3b7a3bde4811cf42dc807660907
GitHub-Last-Rev: 6539cc86cbf3c49c3247ed935bcbbb31bb886dea
GitHub-Pull-Request: golang/go#75408
Reviewed-on: https://go-review.googlesource.com/c/go/+/702677 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
TryBot-Bypass: Joel Sing <joel@sing.id.au>
Roland Shoemaker [Wed, 17 Sep 2025 21:10:11 +0000 (21:10 +0000)]
runtime: don't enable heap randomization if MSAN or ASAN is enabled
MSAN and ASAN do confusing things to the memory layout, which are likely
to conflict with heap base randomization, so if they are enabled,
ignore randomizedHeapBase64.
We already didn't turn it on when TSAN was enabled.
Change-Id: I41e59dfc33d8bb059c208a9595442571fb31eea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/704856
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Roland Shoemaker [Wed, 17 Sep 2025 21:04:56 +0000 (21:04 +0000)]
runtime: fix CheckScavengedBitsCleared with randomized heap base
We cannot easily determine the base address of the arena we added the
random padding pages to, which can cause confusing
TestScavengedBitsCleared failures when the arena we padded does not have
the lowest address of all of the arenas.
Instead of attempting to determine the correct arena to ignore when
checking the scav and alloc bits, switch to just tolerating _one_ arena
having mismatches, which is expected when randomizedHeapBase64 is
enabled. Any other number of arenas having mismatches is likely a real
error.
Fixes #75502
Change-Id: Iacc445b2905824f9f71970c7abd33f187793cf39
Reviewed-on: https://go-review.googlesource.com/c/go/+/704855 Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Kir Kolyshkin [Wed, 3 Sep 2025 19:48:44 +0000 (12:48 -0700)]
path/filepath: fix EvalSymlinks to return ENOTDIR on plan9
CL 155597 added a test to check EvalSymlinks returns ENOTDIR
for existing path which ends with a slash.
CL 404954 added a separate evalSymlinks implementation for plan9,
which has a kludge to ensure the ENOTDIR is returned in the above case.
Apparently the added kludge is not working now (and maybe never worked),
as seen in [1]:
=== RUN TestIssue29372
path_test.go:1730: test#0: want "not a directory", got "stat /tmp/TestIssue293724085649913/001/file.txt/: not a directory: '/tmp/TestIssue293724085649913/001/file.txt/'"
--- FAIL: TestIssue29372 (0.00s)
This happens because on plan9 errors are strings and they contain the
file name after the error text, and the check assumes the "not a
directory" text is at the end of the message.
The fix is to check whether the error is somewhere in the error text,
not ends with it (as it is done in other plan9 code, for example, see
checkErrMessageContent added in CL 163058).
This should fix the above test failure.
PS perhaps the kludge should be moved up the call chain to os.Stat/Lstat?
[1]: https://ci.chromium.org/ui/p/golang/builders/try/gotip-plan9-amd64/b8704772617873749345/test-results?q=ExactID%3Apath%2Ffilepath.TestIssue29372+VHash%3Aa63f5798e9f8f502
Change-Id: I6afb68be5f65a28929b2f717247ab34ff3b4a812
Reviewed-on: https://go-review.googlesource.com/c/go/+/700775
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Richard Miller <millerresearch@gmail.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
go/ast: document that (*ast.File).Comments is sorted by position
This is the way that go/parser produces it and in every AST manipulation
that we do, we preserve such property. Also printer expects it is such
order.
Change-Id: I6a6a696424a679a2cf1f9bb7eb41bdd47523efa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/704255 Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
qmuntal [Tue, 13 May 2025 09:24:30 +0000 (11:24 +0200)]
cmd/link: simplify PE relocations mapping
The code for mapping Windows PE relocations to Go relocations was
difficult to follow and contains some duplicated code. Also, it was
mapping IMAGE_REL_AMD64_ADDR32 to R_PCREL instead of R_ADDR.
This CL commit simplifies the code and fixes the mapping. I haven't been
able to coerce mingw-w64 to generate IMAGE_REL_AMD64_ADDR32 relocations,
so I haven't been able to test this change. However, the previous
implementation was clearly wrong.
While here, remove code supporting the unsupported windows/arm support.
Updates #71671
Updates #75485
Change-Id: Id0d6f352fa7d5df9e00509fcdf09ca0cb91ca524
Reviewed-on: https://go-review.googlesource.com/c/go/+/672155 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Kir Kolyshkin [Thu, 11 Sep 2025 19:22:43 +0000 (12:22 -0700)]
os/user: align test file name and build tags
TestNegativeUid tests code in cgo_lookup_unix.go, so let's use
the very same go:build line for the test file, and rename
the test file accordingly.
Change-Id: Iee3dbc25aeb8a7659c734d97dde3e9c670e80fae
Reviewed-on: https://go-review.googlesource.com/c/go/+/702976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
cmd/go: check pattern for utf8 validity before call regexp.MustCompile
Do not panic if the package path or the package version contains
invalid UTF-8 characters.
Fixes #75251
Change-Id: Ib787e74277cf814253857b911d378ea5e53d8824
Reviewed-on: https://go-review.googlesource.com/c/go/+/700815 Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Alexander <jitsu@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist
CL 621995 disrupted the behavior
introduced by CL 450739, now restore it.
Fixes #75340
Change-Id: Icd1a0eb970876995f9446e0547ceb9e78990f6ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/703555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Ian Alexander <jitsu@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
Sean Liao [Sun, 14 Sep 2025 15:24:57 +0000 (16:24 +0100)]
bytes,strings: remove reference to non-existent SplitFunc
Fixes #75462
Updates #72841
Change-Id: Ie2cbbdb031578a3138ecc6e60c0025807f1990e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Joel Sing [Fri, 12 Sep 2025 10:54:49 +0000 (20:54 +1000)]
cmd/internal/obj/riscv: improve handling of float point moves
Translate moves from an integer register to a floating point register, or
from a floating point register to an integer register, to the appropriate
move instruction (i.e. FMVXW/FMVWX/FMVXD/FMVDX).
Add support for MOVF with a constant - we previously added support for MOVD
but not for MOVF. Add special handling for 0.0, which we can translate to
a move from the zero register to a floating point register (leveraging the
above mentioned change).
Change-Id: If8df2f5610e69b4ec0af85efb884951024685f5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/703216 Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Oleksandr Redko [Fri, 18 Jul 2025 10:30:55 +0000 (13:30 +0300)]
crypto/x509/internal/macos: standardize package name
Rename "macOS" to "macos".
Change-Id: I33ca7afaa14c910a97a19ead518894fb4917662c
Reviewed-on: https://go-review.googlesource.com/c/go/+/688695 Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Roland Shoemaker <roland@golang.org>
cmd/link: remove support for windows/arm relocations
The windows/arm port is no longer supported. We can remove the
related code from cmd/link/internal/arm.
For #71671
Change-Id: I00de1231482cc2f28ec5fc9dc62e81f0ba3fe481
Reviewed-on: https://go-review.googlesource.com/c/go/+/703778
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
cmd/link: remove support for darwin/386 relocations
The darwin/386 port has been unsupported for years, but some
relocation handling specific to it has managed to survive till now.
Updates #37610
Change-Id: I27ae2ac5462c5f3ec219e9cb5dce6f83b037b816
Reviewed-on: https://go-review.googlesource.com/c/go/+/703777 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
https://github.com/riscv/riscv-opcodes/pull/361. After this pr was
merged, riscv-opcode can generate RVV segment load/store instructions
for Go. Implement vector segment load/store instuctions.
Change-Id: I154bb75be70c0a45e2279a75c67f68b5bb57c36e
Reviewed-on: https://go-review.googlesource.com/c/go/+/691695 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cmd/asm: add double precision comparision testcases for riscv64
Change-Id: If8e03dfdb332a22ec9c6a0021d7e7955520f3ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/702136 Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Michael Knyszek <mknyszek@google.com>
The various TestSehUnwind tests recently started to fail due an
unrelated refactor (in CL 698098) that made the stack frames to
not match the expected pattern. This CL updates the tests to
be more robust to such changes.
Fixes #75467
Change-Id: I7950332bb6ca54e4bf693d13e2490b3d9d901dde
Reviewed-on: https://go-review.googlesource.com/c/go/+/703779
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
In Go 1.25+, strings.SplitSeq offers better
performance. Here are the benchmark results comparing
strings.Split and strings.SplitSeq in a for-loop, with the
benchmark code located in src/strings/iter_test.go:
cmd/compile: combine doubling with shift on riscv64
Change-Id: I4bee2770fedf97e35b5a5b9187a8ba3c41f9ec2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/702697 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Michael Anthony Knyszek [Thu, 11 Sep 2025 23:50:00 +0000 (23:50 +0000)]
cmd/internal/testdir: re-enable default all codegen flag on linux-amd64
This was limited to just the mainline linux-amd64 builder, but we don't
use that name anymore. Use the LUCI name instead, gotip-linux-amd64.
Change-Id: Ib4377ad336c529512d9939ff9dce0ea242528b74
Reviewed-on: https://go-review.googlesource.com/c/go/+/703136
Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change-Id: I823f2da9ebbdbef943cb37123d44a7ad2e6d708b
Reviewed-on: https://go-review.googlesource.com/c/go/+/703896 Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
Kir Kolyshkin [Thu, 11 Sep 2025 02:00:19 +0000 (19:00 -0700)]
os: add and use errProcessReleased
This error is already used in three places, so let's define it.
Change-Id: I73565d94aebcf3d5a278201d96839d82db85a2d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/702436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Michael Pratt <mpratt@google.com>
Kir Kolyshkin [Wed, 3 Sep 2025 23:12:39 +0000 (16:12 -0700)]
internal/syscall/unix: add KernelVersionGE
There are a few places in the code which checks that the running kernel
is greater than or equal to x.y. The check takes a few lines and the
checking code is somewhat distracting.
Let's abstract this check into a simple function, KernelVersionGE,
and convert the users accordingly.
Add a test case (I'm not sure it has much value, can be dropped).
Change-Id: I8ec91dcc7452363361f95e46794701c0ae57d956
Reviewed-on: https://go-review.googlesource.com/c/go/+/700796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
Cherry Mui [Fri, 12 Sep 2025 17:46:31 +0000 (13:46 -0400)]
cmd/link: support race mode with MSVC clang
I couldn't make --print-file-name work with -msvc clang. (The
library name is synchronization.lib, but even with that name it
still doesn't print the full path.) Assume it always
synchronization.lib.
Change-Id: I22e8f14824f7f7e96b71b913217b1f604f1e2da7
Reviewed-on: https://go-review.googlesource.com/c/go/+/703398 Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Florian Zenker <floriank@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
test/codegen: check zerobase for newobject on 0-sized types
This CL also adds riscv64 checks
Change-Id: I693e4e606f470615f6b49085592d6d5ca61473d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/703716 Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
qmuntal [Tue, 26 Aug 2025 09:47:51 +0000 (11:47 +0200)]
runtime: deduplicate syscall assembly for darwin
The darwin port provides different syscall functions that only
differ on how they handle the errors, and they are all written
in assembly.
This duplication can be removed by factoring out the error handling
logic to arch-agnostic Go code and leaving the assembly functions
with the only reponsibility of making the syscall and mapping
parameters between ABIs.
Updates #51087
Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64-longtest,gotip-darwin-amd64-longtest
Change-Id: I9524377f3ef9c9a638412c7e87c8f46a33ee3453
Reviewed-on: https://go-review.googlesource.com/c/go/+/699135 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
database64128 [Wed, 27 Aug 2025 09:38:13 +0000 (17:38 +0800)]
net: use context.AfterFunc in connect
This saves a goroutine when ctx can be but is not canceled during
the connect call.
The redundant fd.Close() call is removed, because the caller closes
the fd on error.
Change-Id: I124d7e480294a48ef74d5650d8ef0489bdfc64d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/699256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Mark Freeman <markfreeman@google.com>
Alan Donovan [Thu, 11 Sep 2025 15:02:03 +0000 (11:02 -0400)]
cmd/go/internal/work: copy vet tool's stdout to our stdout
The go command connects both the stdout and stderr files of
its child commands (cmd/compile, cmd/vet, etc) to the go
command's own stderr. If the child command is supposed to
produce structure output on stderr, as is the case for
go vet -json or go fix -diff, it will be merged with the
error stream, making it useless.
This change to the go vet <-> unitchecker protocol specifies
the name of a file into which the vet tool should write its
stdout. On success, the go command will then copy the entire
content of that file to its own stdout, under a lock.
This ensures that partial writes to stdout in case of failure,
concurrent writes to stdout by parallel vet tasks, or other
junk on stderr, cannot interfere with the integrity of the
go command's structure output on stdout.
CL 702835 is the corresponding change on the x/tools side.
For #75432
Change-Id: Ib4db25b6b0095d359152d7543bd9bf692551bbfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/702815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Cherry Mui [Fri, 12 Sep 2025 16:36:38 +0000 (12:36 -0400)]
cmd/link: don't count tbss section in TestFlagD
TestFlagD looks for a data-like section at the lowest address.
On OpenBSD, the .tbss section matches the current condition, which
has address 0, causing the test fail. Don't count TLS sections.
Also, print the section name on error.
Fixes #75444.
Change-Id: Ic0aa1a2bb7c6bd5c0023d4482405a482095ff68b
Reviewed-on: https://go-review.googlesource.com/c/go/+/703375 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This fires in just one place; stkframe.go's stkobjinit. But, it does
make the struct literal entirely constants.
Change-Id: Ice76cb3cddd97adee011fdaab40597839da2e89f
Reviewed-on: https://go-review.googlesource.com/c/go/+/701300 Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
cmd/compile, reflect: further allow inlining of TypeFor
Previous CLs optimized direct use of abi.Type, but reflect.Type is
indirected, so was not benefiting.
For TypeFor, we can use toRType directly without a nil check because the
types are statically known.
Normally, I'd think SSA would remove the nil check, but due to some
oddity (specifically, late fuse being required to remove the nil check,
but opt doesn't run that late) means that the nil check persists and
gets in the way.
Manually writing the code in this instance seems to fix the problem.
It also exposed another problem; depending on the ordering, writeType
could get to a type symbol before SSA, thereby preventing Extra from
being created on the symbol for later lookups that don't go through
TypeLinksym directly. In writeType, for non-shape types, call
TypeLinksym to ensure that the type is set up for later callers. That
change itself passed toolstash -cmp.
All up, this stack put through compilecmp shows a lot of improvement in
various reflect-using packages, and reflect itself. It is too big to fit
in the commit message but here's some info:
compilecmp master -> HEAD
master (d767064170): cmd/compile: mark abi.PtrType.Elem sym as used
HEAD (846a94c568): cmd/compile, reflect: further allow inlining of TypeFor
Change-Id: I9eb750cf0b7ebf532589f939431feb0a899e42ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/701301 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Michael Matloob [Mon, 17 Mar 2025 15:45:52 +0000 (11:45 -0400)]
internal/goexperiment: add a sizespecializedmalloc goexperiment setting
Change-Id: I6a6a696497f2a0b0d403bbb11d7502f62edec78b
Reviewed-on: https://go-review.googlesource.com/c/go/+/696535
Auto-Submit: Michael Matloob <matloob@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Cherry Mui [Thu, 11 Sep 2025 21:42:30 +0000 (17:42 -0400)]
cmd/link: support MSVC clang
Currently on Windows, for cgo, we support MinGW-based C toolchain,
that is, with a -windows-gnu target. This CL makes it work with
clang with a -windows-msvc target. The LLVM toolchain bundled in
MSVC (https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild)
is such an example.
Currently it is expecting lld-link as the C linker, which is also
bundled in MSVC, can be requested with -fuse-ld=lld, but is not
the default.
This is the first step, which makes it generate a working cgo
binary. There are still more work to do, e.g. there are some
linker warnings, and the binary doesn't have symbol table.
all.bat doesn't pass with this setting.
Change-Id: I54d33f7dd5f5eeeafa0735cd52f4127fe4865636
Reviewed-on: https://go-review.googlesource.com/c/go/+/703055 Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Florian Zenker <floriank@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Support is added for the generic RISC-V CSR operations; CSRRC, CSRRCI,
CSRRS, CSRRSI, CSRRW, CSRRWI. These instructions require special
handling as their second operand is a symbolic CSR register name and
not an immediate value or a register. CSR names are implemented as
special operands.
RISC-V CSRs are not currently saved and restored when a go routine is
asynchronously pre-empted so it is only safe to use these instructions
in hand written assembler. Note that CSRRS was already partially
supported by the assembler so this restriction predates this commit.
We mention it here as this commit makes CSRRS much easier to use.
Change-Id: I9ff8d804328b418a879d463e7d9cc31f489c7a00
Reviewed-on: https://go-review.googlesource.com/c/go/+/630519 Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Michael Matloob [Fri, 8 Aug 2025 21:35:43 +0000 (17:35 -0400)]
cmd/go: run cgo and cgo compiles in their own actions
This change splits package builds further into even more actions.
Between the cache action (and cover action, if present) and the actual
build action we insert three layers of actions:
Check Cache Action
| |
| V
| Run Cover Action (if cover requested)
| |
| V
New Layer 1 | Run Cgo Action (if package is built with cgo)
| | | | (multiple arrows representing fan-out to
| V V V multiple actions)
New Layer 2 | gcc Compile Action for each C/C++/S/F/M file (if cgo)
| |/ (arrow represeting fan-in to single action)
| V
New Layer 3 | Cgo collect action (if cgo)
| |
\ V
Build action
The first run cgo action takes the input source files and runs cgo on
them to produce the cgo-processed go files, which are given to the
compiler, and to produce additional C files to compile and headers to
use in the following compilations. The action also takes care of running
SWIG before running cgo if there are swig files. This will produce
additional cgo sources that are inputs to cgo.
The run cgo action action fans out to multiple actions to do each of the
C/C++/Obj-C/assembly/Fortran compilations for the non-Go files in the
package, as well as those produced as outputs by the cgo command
invocation.
These actions then join into a single noop "collect" action which
primarily exists so that we don't pollute the build action's
dependencies with a bunch of non-go compile actions. (The build action
expects its dependencies to mostly be other build actions).
All of this work in the new actions was previously being done in the
build action itself. There's still a remnant of the original cgo logic
left in the build action to run the cgo command with -dynimport to
produce a go file to be built with the rest of the package, and do some
checks.
Most of this CL consists of moving code around. Just like the previous
CL breaking out the coverage logic into a separate action, we don't
cache the outputs of the cgo actions, and just treat all the actions
used to build a single package as one cacheable unit. This makes things
a bit simpler. If we decide in a future CL to cache the outputs
separately, we could remove the dependency on the cover action on the
check cache action (which in turn depends on all the package's
dependencies) and could start non-go compilation pretty much as early as
we want in the build.
The 'cgoAction' function in action.go takes care of creating the layers
of cgo action dependencies, which are inserted as dependencies of the
build action. It's mostly straightforward, except for the fact that we
need to tell each non-go compile action which non-go file to compile, so
we need to compute the names of the generated files. (Alternatively we
could give each action a number and have it build the nth file produced
by the run cgo action, but that seems even more complicated). The actors
produced to run the action logic are pretty light wrappers around the
execution logic in exec.go.
In the 'build' function in exec.go, most of the new code mainly checks
for the information from the cgo actions to use instead of running it,
and then passes it to the processCgoOutputs function. The only other
weird thing in the build functian is that we we call the logic to
compute the nonGoOverlay separately just for the C files that are being
built with gccgo. We compute the overlay for the non-go files used in a
cgo build in the run cgo action.
The 'cgo' function that previously ran the cgo logic for the build has
now been split into three: the first half, which runs cgo is now in the
runCgo function, the center part, which compiles the non-go files is now
partly in creating the invididual non-go compile actions, as well as the
cgoCompileActor's Act function. And the final part, which runs
cgo -dynimport is now in processCgoOutputs. These parts communicate with
each other through the providers that are set on the cgo actions.
One further improvement we can make to this change in the future is to
compile the dynimport file separately from the build action: its output
is only needed by the linker. This would remove any dependencies from
dependent packages' build actions on the cgo compile actions, allowing
more flexibility for scheduling actions.
Fixes #9887
Change-Id: Ie3c70bbf985148ba73094cddfc78c39dc6faad6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/694475 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com>
David Finkel [Sun, 31 Aug 2025 17:34:47 +0000 (13:34 -0400)]
testing: exit B.Loop early upon saturation
There's a cap of 1 billion benchmark iterations because more than that
is usually not going to give more useful data. Unfortunately, the
existing implementation neglected to check whether the 1e9 cap had
already been exceeded when it adjusted the number of iterations in the
B.Loop slow path (stopOrScaleBLoop), since it's only when that cap is hit
that it needed to terminate early.
As a result, for _very_ cheap benchmarks (e.g. testing assembly
implementations with just a few instructions), the B.Loop would stop
incrementing the number of iterations, but wouldn't terminate early,
making it re-enter the slow-path _every_ iteration until the benchmark
time was exhausted.
This wasn't normally visible with the default -benchtime 2s, but when
raised to 5s, it would cause benchmarks that took <5ns/op to be reported
as exactly 5ns/op. (which looks a bit suspicious)
Notably, one can use -count for larger groupings to compute statistics.
golang.org/x/perf/cmd/benchstat is valuable for coalescing larger
run-counts from -count into more useful statistics.
Add a test which allows for fewer iterations on slow/contended
platforms but guards against reintroducing a bug of this nature.
Fixes #75210
Change-Id: Ie7f0b2e6c737b064448434f3ed565bfef8c4f020
Reviewed-on: https://go-review.googlesource.com/c/go/+/700275 Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Alan Donovan [Thu, 11 Sep 2025 17:40:24 +0000 (13:40 -0400)]
cmd/go/internal/work: remove deps[1]="fmt" vet hack
The Builder.vet operation has not needed an artificial
dependency on the fmt package since CL 176439 in 2019.
Remove it now.
Change-Id: I398a6d2d57175c12843520d9f19ffd023e676123
Reviewed-on: https://go-review.googlesource.com/c/go/+/702856
Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Joe Tsai [Wed, 10 Sep 2025 00:24:20 +0000 (17:24 -0700)]
archive/tar: fix typo in benchmark name
This was accidentally introduced in CL 662835.
Change-Id: I5c7ac67337e33e82037414377912b57d2a45be91
Reviewed-on: https://go-review.googlesource.com/c/go/+/702275 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Dmitri Shuralyov [Wed, 10 Sep 2025 19:08:27 +0000 (15:08 -0400)]
syscall: actually remove unreachable code
CL 702415 claimed to remove unreachable code, but in reality merely hid
it from vet's unreachable pass. Since the unreachable code isn't serving
an active role in the test, do remove it to simplify code.
Change-Id: I5905b8b566e4ca013bdd1202d1492e3eae6a5ede
Reviewed-on: https://go-review.googlesource.com/c/go/+/702575 Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
debug/macho: filter non-external symbols when reading imported symbols without LC_DYSYMTAB
File.ImportedSymbols will return symbols with a type that has one of the
N_STAB (0xe0) bits set and no section. That's not the expected behavior,
as those symbols might not be external.
We should expand the type check to also account for the N_EXT bit.
The section check is not necessary, as N_EXT symbols never have it set.
I have found this issue in the wild by running "go tool cgo -dynimport",
but unfortuantely I couldn't get a minimal C code that generates
N_STAB symbols without section, so this CL doesn't add any new test.
Change-Id: Ib0093ff66b50c7cc2f39d83936314fc293236917
Reviewed-on: https://go-review.googlesource.com/c/go/+/702296 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Keith Randall [Thu, 21 Aug 2025 00:33:14 +0000 (17:33 -0700)]
runtime/internal/maps: only conditionally clear groups when sparse
We only want to do the work of clearing slots
if they are full. But we also don't want to do too
much work to figure out whether a slot is full or not,
especially if clearing a slot is cheap.
1) We decide group-by-group instead of slot-by-slot.
If any slot in a group is full, we zero the whole group.
2) If groups are unlikely to be empty, don't bother
testing for it.
3) If groups are 50%/50% likely to be empty, also don't
bother testing, as it confuses the branch predictor. See #75097.
4) But if a group is really large, do the test anyway, as
clearing is expensive.
Fixes #75097
Change-Id: I9191865dd3e0fe887751cffe6082ac27d8d8439c
Reviewed-on: https://go-review.googlesource.com/c/go/+/697876 Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Youlin Feng <fengyoulin@live.com>
Change-Id: I69adff73d1c9631e07df63fc84c80ec0204d49d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/700835 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TestReadMetricsSched/running can take some time to enter in steady state
on busy systems. We currently only allow 1 second for that, we should
let it run unlimitedly until success or the test time's out.
Fixes #75049
Change-Id: I452059e1837caf12a2d2d9cae1f70a0ef2d4f518
Reviewed-on: https://go-review.googlesource.com/c/go/+/702295
Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Keith Randall [Fri, 5 Sep 2025 17:19:17 +0000 (10:19 -0700)]
cmd/compile: when CSEing two values, prefer the statement marked one
Fixes #75249
Change-Id: Ifd61bf5341f23ce2c9735e607e00d987489caacf
Reviewed-on: https://go-review.googlesource.com/c/go/+/701295 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Alexander Musman <alexander.musman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reason for revert: Causes miscompilations. See issue 75365.
Change-Id: Icd1fcfeb23d2ec524b16eb556030f43875e1c90d
Reviewed-on: https://go-review.googlesource.com/c/go/+/702455 Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>
Dmitri Shuralyov [Wed, 10 Sep 2025 14:55:19 +0000 (10:55 -0400)]
go/token, syscall: annotate if blocks that defeat vet's unreachable pass
Since putting code in an "if true" block is unusual, make it easier
for readers to understand the purpose of doing this.
For #73998.
Change-Id: I3fd8d65130211c7c01d424366a3c662482d80add
Reviewed-on: https://go-review.googlesource.com/c/go/+/702416 Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Revert "crypto/internal/fips140: update frozen module version to "v1.0.0""
This reverts CL 701518. This should land just before CL 701520 to avoid
breaking the builders for long.
Fixes #75343
Change-Id: If1ae1fe933fe443ca9776888967d80875b02f41a
Reviewed-on: https://go-review.googlesource.com/c/go/+/702255 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Joe Tsai [Tue, 9 Sep 2025 00:33:47 +0000 (17:33 -0700)]
encoding/json/v2: document context annotation with SemanticError
When the json package calls
Marshaler, MarshalerTo, Unmarshaler, or UnmarshalerFrom methods
and a SemanticError is returned, it will automatically
annotate the error with context.
Document this behavior.
Change-Id: Id8e775a7c1c2a6ffc29ea518913591915e8aff87
Reviewed-on: https://go-review.googlesource.com/c/go/+/701956 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Ian Lance Taylor [Sat, 6 Sep 2025 05:24:37 +0000 (22:24 -0700)]
runtime: when using cgo on 386, call C sigaction function
On 386 the C sigaction function assumes that the caller does not set
the SA_RESTORER flag. It does not copy the C sa_restorer field to
the kernel sa_restorer field. The effect is that the kernel sees
the SA_RESTORER flag but a NULL sa_restorer field, and the program
crashes when returning from a signal handler.
On the other hand, the C sigaction function will return the SA_RESTORER
flag and the sa_restorer field stored in the kernel.
This means that if the Go runtime installs a signal handler,
with SA_RESTORER as is required when calling the kernel,
and the Go program calls C code that calls the C sigaction function
to query the current signal handler, that C code will get a result
that it can't pass back to sigaction.
This CL fixes the problem by using the C sigaction function
for 386 programs that use cgo. This reuses the functionality
used on amd64 and other GOARCHs to support the race detector.
See #75253, or runtime/testdata/testprogcgo/eintr.go, for sample
code that used to fail on 386. No new test case is required,
we just remove the skip we used to have for eintr.go.
Fixes #75253
Change-Id: I803059b1fb9e09e9fbb43f68eccb6a59a92c2991
Reviewed-on: https://go-review.googlesource.com/c/go/+/701375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Change-Id: I987d9f49fbd2650eef4224f72271bf752c54d39c
Reviewed-on: https://go-review.googlesource.com/c/go/+/700538 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Change-Id: I43681ca029880025558b33ddc4295da3947c9b28
Reviewed-on: https://go-review.googlesource.com/c/go/+/700537
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>
Change-Id: Iea1da734ff8eaf1b5a2822ae2bdb7f4fd9b65651
Reviewed-on: https://go-review.googlesource.com/c/go/+/699635 Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
Meng Zhuo [Mon, 18 Aug 2025 09:59:43 +0000 (17:59 +0800)]
cmd/compile: simplify zerorange on riscv64
Drop large zeroing cases, part of removing duff support.
Change-Id: Ia2936f649901886f3eb1d7ba1f90e3bf40ea2dee
Reviewed-on: https://go-review.googlesource.com/c/go/+/697615 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Julian Zhu <jz531210@gmail.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
matloob [Mon, 25 Aug 2025 21:22:01 +0000 (17:22 -0400)]
cmd/cgo: run gcc to get errors and debug info in parallel
This change kicks off the work to load the debug info when processing
each file, and then waits for all the files to be processed before
starting the single-goroutined part that processes them. The processing
is very order dependent so we won't try to make it concurrent. Though
in a later CL we can wait for only the relevant package to have been
processed concurrently before doing the single-goroutined processing for
it instead of waiting for all packages to be processed concurrently
before the single goroutine section.
We use a par.Queue to make sure we're not running too many gcc compiles
at the same time. The change to cmd/dist makes the par package available
to cgo.
Fixes #75167
Change-Id: I6a6a6964fb7f3a3684118b5ee66f1ad856b3ee59
Reviewed-on: https://go-review.googlesource.com/c/go/+/699020 Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
For programs with very large environments, calling unsetenv(3) for each
environment variable can be very expensive because of CGo overhead, but
clearenv(3) is much faster. The only thing we have to track is whether
GODEBUG is being unset by the operation, which can be done very quickly
without resorting to doing unsetenv(3) for every variable.
This change makes syscall.Clearenv() >98% faster when run in an
environment with as little as 100 environment variables. (Note that due
to golang/go#27217, it is necessary to modify BenchmarkClearenv to use
t.StopTimer() and -benchtime=100x in order to get these benchmark times
-- otherwise syscall.Setenv() time is included and the benchmarks give a
more pessimistic 50% performance improvement.)
The above benchmarks are CGo builds, which require CGo overhead for
every setenv(2). If you run the same benchmarks for a non-CGo package
(i.e., outside of the "syscall" package), you get slightly more modest
performance improvements:
When slicing, ignore expressions which could be elided, as in slicing
starting at 0 or ending at len(v).
Fixes #75278
Change-Id: I9c18e29c3d4da9bef89bd25bb261d3cb60e66392
Reviewed-on: https://go-review.googlesource.com/c/go/+/701216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com>