Skip to content

Commit c456ab7

Browse files
committed
[dev.simd] all: merge master (a33bbf1) into dev.simd
Merge List: + 2025-12-08 a33bbf1 weak: fix weak pointer test to correctly iterate over weak pointers after GC + 2025-12-08 a88a963 cmd/cgo: use doc link for cgo.Handle + 2025-12-08 276cc4d cmd/link: fix AIX builds after recent linker changes + 2025-12-08 f2d9627 runtime/trace: update TestSubscribers to dump traces + 2025-12-08 4837bcc internal/trace: skip tests for alloc/free experiment by default + 2025-12-08 b5f6816 cmd/link: generate DWARF for moduledata + 2025-12-08 44a39c9 runtime: only run TestNotInGoMetricCallback when building with cgo + 2025-12-08 3a6a034 runtime: disable TestNotInGoMetricCallback on FreeBSD + race + 2025-12-08 4122d3e runtime: use atomic C types with atomic C functions + 2025-12-08 3439786 runtime: deflake TestProfBufWakeup + 2025-12-08 d4972f6 runtime: mark getfp as nosplit + 2025-12-05 0d0d5c9 test/codegen: test negation with add/sub on riscv64 + 2025-12-05 2e509e6 cmd/go: convert some more tests to script tests + 2025-12-05 c270e71 cmd/go/internal/vet: skip -fix on pkgs from vendor or non-main mod + 2025-12-05 7453497 runtime: don't count nGsyscallNoP for extra Ms in C + 2025-12-05 f3d572d cmd/go: fix race applying fixes in fix and vet -fix modes + 2025-12-05 7634553 runtime: expand Pinner documentation + 2025-12-05 b133524 cmd/go/testdata/script: skip vet_cache in short mode + 2025-12-05 96e142b runtime: skip TestArenaCollision if we run out of hints + 2025-12-05 fe4952f runtime: relax threadsSlack in TestReadMetricsSched + 2025-12-05 8947f09 runtime: skip mayMoreStackMove in goroutine leak tests + 2025-12-05 44cb824 runtime/race: set missing argument frame for ppc64x atomic And/Or wrappers + 2025-12-05 435e61c runtime: reject any goroutine leak test failure that failed to execute + 2025-12-05 54e5540 runtime: print output in case of segfault in goroutine leak tests + 2025-12-05 9616c33 runtime: don't specify GOEXPERIMENT=greenteagc in goroutine leak tests + 2025-12-05 2244bd7 crypto/subtle: add speculation barrier after DIT + 2025-12-05 f84f8d8 cmd/compile: fix mis-infer bounds in slice len/cap calculations + 2025-12-05 a70addd all: fix some comment issues + 2025-12-05 93b49f7 internal/runtime/maps: clarify probeSeq doc comment + 2025-12-04 91267f0 all: update vendored x/tools + 2025-12-04 a753a9e cmd/internal/fuzztest: move fuzz tests out of cmd/go test suite + 2025-12-04 1681c3b crypto: use rand.IsDefaultReader instead of comparing to boring.RandReader + 2025-12-04 7b67b68 cmd/compile: use isUnsignedPowerOfTwo rather than isPowerOfTwo for unsigneds + 2025-12-03 2b62144 all: REVERSE MERGE dev.simd (9ac524a) into master Change-Id: Ia0cdf06cdde89b6a4db30ed15ed8e0bcbac6ae30
2 parents 1d8711e + a33bbf1 commit c456ab7

File tree

108 files changed

+1445
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1445
-428
lines changed

src/cmd/cgo/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ and of course there is nothing stopping the C code from doing anything
425425
it likes. However, programs that break these rules are likely to fail
426426
in unexpected and unpredictable ways.
427427
428-
The runtime/cgo.Handle type can be used to safely pass Go values
429-
between Go and C. See the runtime/cgo package documentation for details.
428+
The type [runtime/cgo.Handle] can be used to safely pass Go values
429+
between Go and C.
430430
431431
Note: the current implementation has a bug. While Go code is permitted
432432
to write nil or a C pointer (but not a Go pointer) to C memory, the

src/cmd/compile/internal/ssa/prove.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,10 @@ func (ft *factsTable) detectSliceLenRelation(v *Value) {
21192119
if bound := ow.Args[0]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice {
21202120
lenOffset = ow.Args[1]
21212121
} else if bound := ow.Args[1]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice {
2122-
lenOffset = ow.Args[0]
2122+
// Do not infer K - slicelen, see issue #76709.
2123+
if ow.Op == OpAdd64 {
2124+
lenOffset = ow.Args[0]
2125+
}
21232126
}
21242127
if lenOffset == nil || lenOffset.Op != OpConst64 {
21252128
continue
@@ -2885,9 +2888,9 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) {
28852888
xl := ft.limits[x.ID]
28862889
y := v.Args[1]
28872890
yl := ft.limits[y.ID]
2888-
if xl.umin == xl.umax && isPowerOfTwo(int64(xl.umin)) ||
2891+
if xl.umin == xl.umax && isUnsignedPowerOfTwo(xl.umin) ||
28892892
xl.min == xl.max && isPowerOfTwo(xl.min) ||
2890-
yl.umin == yl.umax && isPowerOfTwo(int64(yl.umin)) ||
2893+
yl.umin == yl.umax && isUnsignedPowerOfTwo(yl.umin) ||
28912894
yl.min == yl.max && isPowerOfTwo(yl.min) {
28922895
// 0,1 * a power of two is better done as a shift
28932896
break

src/cmd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
golang.org/x/sys v0.38.1-0.20251125153526-08e54827f670
1212
golang.org/x/telemetry v0.0.0-20251128220624-abf20d0e57ec
1313
golang.org/x/term v0.37.0
14-
golang.org/x/tools v0.39.1-0.20251130212600-1ad6f3d02713
14+
golang.org/x/tools v0.39.1-0.20251205000126-062ef7b6ced2
1515
)
1616

1717
require (

src/cmd/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
2222
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
2323
golang.org/x/text v0.31.1-0.20251128220601-087616b6cde9 h1:IjQf87/qLz2y0SiCc0uY3DwajALXkAgP1Pxal0mmdrM=
2424
golang.org/x/text v0.31.1-0.20251128220601-087616b6cde9/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
25-
golang.org/x/tools v0.39.1-0.20251130212600-1ad6f3d02713 h1:i4GzAuZW4RuKXltwKyLYAfk7E1TSKQBxRAI7XKfLjSk=
26-
golang.org/x/tools v0.39.1-0.20251130212600-1ad6f3d02713/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
25+
golang.org/x/tools v0.39.1-0.20251205000126-062ef7b6ced2 h1:2Qqv605Nus9iUp3ErvEU/q92Q3HAzeROztzl9pzAno8=
26+
golang.org/x/tools v0.39.1-0.20251205000126-062ef7b6ced2/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
2727
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
2828
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=

src/cmd/go/go_test.go

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -972,19 +972,6 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
972972
tg.wantNotStale("p1", "", "./testgo list claims p1 is stale after building with old release")
973973
}
974974

975-
func TestPackageMainTestCompilerFlags(t *testing.T) {
976-
tg := testgo(t)
977-
defer tg.cleanup()
978-
tg.parallel()
979-
tg.makeTempdir()
980-
tg.setenv("GOPATH", tg.path("."))
981-
tg.tempFile("src/p1/p1.go", "package main\n")
982-
tg.tempFile("src/p1/p1_test.go", "package main\nimport \"testing\"\nfunc Test(t *testing.T){}\n")
983-
tg.run("test", "-c", "-n", "p1")
984-
tg.grepBothNot(`([\\/]compile|gccgo).* (-p main|-fgo-pkgpath=main).*p1\.go`, "should not have run compile -p main p1.go")
985-
tg.grepStderr(`([\\/]compile|gccgo).* (-p p1|-fgo-pkgpath=p1).*p1\.go`, "should have run compile -p p1 p1.go")
986-
}
987-
988975
// Issue 4104.
989976
func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
990977
tooSlow(t, "links and runs a test")
@@ -1070,43 +1057,6 @@ func TestGoListDeps(t *testing.T) {
10701057
}
10711058
}
10721059

1073-
func TestGoListTest(t *testing.T) {
1074-
skipIfGccgo(t, "gccgo does not have standard packages")
1075-
tg := testgo(t)
1076-
defer tg.cleanup()
1077-
tg.parallel()
1078-
tg.makeTempdir()
1079-
tg.setenv("GOCACHE", tg.tempdir)
1080-
1081-
tg.run("list", "-test", "-deps", "bytes")
1082-
tg.grepStdout(`^bytes.test$`, "missing test main")
1083-
tg.grepStdout(`^bytes$`, "missing real bytes")
1084-
tg.grepStdout(`^bytes \[bytes.test\]$`, "missing test copy of bytes")
1085-
tg.grepStdout(`^testing \[bytes.test\]$`, "missing test copy of testing")
1086-
tg.grepStdoutNot(`^testing$`, "unexpected real copy of testing")
1087-
1088-
tg.run("list", "-test", "bytes")
1089-
tg.grepStdout(`^bytes.test$`, "missing test main")
1090-
tg.grepStdout(`^bytes$`, "missing real bytes")
1091-
tg.grepStdout(`^bytes \[bytes.test\]$`, "unexpected test copy of bytes")
1092-
tg.grepStdoutNot(`^testing \[bytes.test\]$`, "unexpected test copy of testing")
1093-
tg.grepStdoutNot(`^testing$`, "unexpected real copy of testing")
1094-
1095-
tg.run("list", "-test", "cmd/buildid", "cmd/gofmt")
1096-
tg.grepStdout(`^cmd/buildid$`, "missing cmd/buildid")
1097-
tg.grepStdout(`^cmd/gofmt$`, "missing cmd/gofmt")
1098-
tg.grepStdout(`^cmd/gofmt\.test$`, "missing cmd/gofmt test")
1099-
tg.grepStdoutNot(`^cmd/buildid\.test$`, "unexpected cmd/buildid test")
1100-
tg.grepStdoutNot(`^testing`, "unexpected testing")
1101-
1102-
tg.run("list", "-test", "runtime/cgo")
1103-
tg.grepStdout(`^runtime/cgo$`, "missing runtime/cgo")
1104-
1105-
tg.run("list", "-deps", "-f", "{{if .DepOnly}}{{.ImportPath}}{{end}}", "sort")
1106-
tg.grepStdout(`^internal/reflectlite$`, "missing internal/reflectlite")
1107-
tg.grepStdoutNot(`^sort`, "unexpected sort")
1108-
}
1109-
11101060
func TestGoListCompiledCgo(t *testing.T) {
11111061
tooSlow(t, "compiles cgo files")
11121062

@@ -1528,40 +1478,6 @@ func main() {}
15281478
tg.run("run", tg.path("bar.go"))
15291479
}
15301480

1531-
func TestListTemplateContextFunction(t *testing.T) {
1532-
t.Parallel()
1533-
for _, tt := range []struct {
1534-
v string
1535-
want string
1536-
}{
1537-
{"GOARCH", runtime.GOARCH},
1538-
{"GOOS", runtime.GOOS},
1539-
{"GOROOT", testGOROOT},
1540-
{"GOPATH", os.Getenv("GOPATH")},
1541-
{"CgoEnabled", ""},
1542-
{"UseAllFiles", ""},
1543-
{"Compiler", ""},
1544-
{"BuildTags", ""},
1545-
{"ReleaseTags", ""},
1546-
{"InstallSuffix", ""},
1547-
} {
1548-
tt := tt
1549-
t.Run(tt.v, func(t *testing.T) {
1550-
tg := testgo(t)
1551-
tg.parallel()
1552-
defer tg.cleanup()
1553-
tmpl := "{{context." + tt.v + "}}"
1554-
tg.run("list", "-f", tmpl)
1555-
if tt.want == "" {
1556-
return
1557-
}
1558-
if got := strings.TrimSpace(tg.getStdout()); got != tt.want {
1559-
t.Errorf("go list -f %q: got %q; want %q", tmpl, got, tt.want)
1560-
}
1561-
})
1562-
}
1563-
}
1564-
15651481
// Test that you cannot use a local import in a package
15661482
// accessed by a non-local import (found in a GOPATH/GOROOT).
15671483
// See golang.org/issue/17475.
@@ -2247,23 +2163,6 @@ func TestCacheCoverage(t *testing.T) {
22472163
tg.run("test", "-cover", "-short", "math", "strings")
22482164
}
22492165

2250-
func TestIssue22588(t *testing.T) {
2251-
// Don't get confused by stderr coming from tools.
2252-
tg := testgo(t)
2253-
defer tg.cleanup()
2254-
tg.parallel()
2255-
2256-
tg.wantNotStale("runtime", "", "must be non-stale to compare staleness under -toolexec")
2257-
2258-
if _, err := os.Stat("/usr/bin/time"); err != nil {
2259-
t.Skip(err)
2260-
}
2261-
2262-
tg.run("list", "-f={{.Stale}}", "runtime")
2263-
tg.run("list", "-toolexec=/usr/bin/time", "-f={{.Stale}}", "runtime")
2264-
tg.grepStdout("false", "incorrectly reported runtime as stale")
2265-
}
2266-
22672166
func TestIssue22531(t *testing.T) {
22682167
tooSlow(t, "links binaries")
22692168
if gocacheverify.Value() == "1" {

src/cmd/go/internal/test/test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
736736
// Otherwise, if fuzzing identifies a failure it could corrupt checksums in
737737
// the module cache (or permanently alter the behavior of std tests for all
738738
// users) by writing the failing input to the package's testdata directory.
739-
// (See https://golang.org/issue/48495 and test_fuzz_modcache.txt.)
739+
// (See https://golang.org/issue/48495 and cmd/internal/fuzztest/test_fuzz_modcache.txt.)
740740
mainMods := moduleLoaderState.MainModules
741741
if m := pkgs[0].Module; m != nil && m.Path != "" {
742742
if !mainMods.Contains(m.Path) {
@@ -1371,7 +1371,7 @@ func addTestVet(loaderstate *modload.State, b *work.Builder, p *load.Package, ru
13711371
return
13721372
}
13731373

1374-
vet := b.VetAction(loaderstate, work.ModeBuild, work.ModeBuild, p)
1374+
vet := b.VetAction(loaderstate, work.ModeBuild, work.ModeBuild, false, p)
13751375
runAction.Deps = append(runAction.Deps, vet)
13761376
// Install will clean the build directory.
13771377
// Make sure vet runs first.

src/cmd/go/internal/vet/vet.go

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package vet
77

88
import (
9+
"archive/zip"
10+
"bytes"
911
"context"
1012
"encoding/json"
1113
"errors"
@@ -176,6 +178,7 @@ func run(ctx context.Context, cmd *base.Command, args []string) {
176178

177179
work.VetExplicit = len(toolFlags) > 0
178180

181+
applyFixes := false
179182
if cmd.Name() == "fix" || *vetFixFlag {
180183
// fix mode: 'go fix' or 'go vet -fix'
181184
if jsonFlag {
@@ -186,6 +189,8 @@ func run(ctx context.Context, cmd *base.Command, args []string) {
186189
toolFlags = append(toolFlags, "-fix")
187190
if diffFlag {
188191
toolFlags = append(toolFlags, "-diff")
192+
} else {
193+
applyFixes = true
189194
}
190195
}
191196
if contextFlag != -1 {
@@ -226,13 +231,21 @@ func run(ctx context.Context, cmd *base.Command, args []string) {
226231
base.Fatalf("no packages to %s", cmd.Name())
227232
}
228233

234+
// Build action graph.
229235
b := work.NewBuilder("", moduleLoaderState.VendorDirOrEmpty)
230236
defer func() {
231237
if err := b.Close(); err != nil {
232238
base.Fatal(err)
233239
}
234240
}()
235241

242+
root := &work.Action{Mode: "go " + cmd.Name()}
243+
244+
addVetAction := func(p *load.Package) {
245+
act := b.VetAction(moduleLoaderState, work.ModeBuild, work.ModeBuild, applyFixes, p)
246+
root.Deps = append(root.Deps, act)
247+
}
248+
236249
// To avoid file corruption from duplicate application of
237250
// fixes (in fix mode), and duplicate reporting of diagnostics
238251
// (in vet mode), we must run the tool only once for each
@@ -248,9 +261,16 @@ func run(ctx context.Context, cmd *base.Command, args []string) {
248261
// We needn't worry about intermediate test variants, as they
249262
// will only be executed in VetxOnly mode, for facts but not
250263
// diagnostics.
251-
252-
root := &work.Action{Mode: "go " + cmd.Name()}
253264
for _, p := range pkgs {
265+
// Don't apply fixes to vendored packages, including
266+
// the GOROOT vendor packages that are part of std,
267+
// or to packages from non-main modules (#76479).
268+
if applyFixes {
269+
if p.Standard && strings.HasPrefix(p.ImportPath, "vendor/") ||
270+
p.Module != nil && !p.Module.Main {
271+
continue
272+
}
273+
}
254274
_, ptest, pxtest, perr := load.TestPackagesFor(moduleLoaderState, ctx, pkgOpts, p, nil)
255275
if perr != nil {
256276
base.Errorf("%v", perr.Error)
@@ -262,13 +282,65 @@ func run(ctx context.Context, cmd *base.Command, args []string) {
262282
}
263283
if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 {
264284
// The test package includes all the files of primary package.
265-
root.Deps = append(root.Deps, b.VetAction(moduleLoaderState, work.ModeBuild, work.ModeBuild, ptest))
285+
addVetAction(ptest)
266286
}
267287
if pxtest != nil {
268-
root.Deps = append(root.Deps, b.VetAction(moduleLoaderState, work.ModeBuild, work.ModeBuild, pxtest))
288+
addVetAction(pxtest)
269289
}
270290
}
271291
b.Do(ctx, root)
292+
293+
// Apply fixes.
294+
//
295+
// We do this as a separate phase after the build to avoid
296+
// races between source file updates and reads of those same
297+
// files by concurrent actions of the ongoing build.
298+
//
299+
// If a file is fixed by multiple actions, they must be consistent.
300+
if applyFixes {
301+
contents := make(map[string][]byte)
302+
// Gather the fixes.
303+
for _, act := range root.Deps {
304+
if act.FixArchive != "" {
305+
if err := readZip(act.FixArchive, contents); err != nil {
306+
base.Errorf("reading archive of fixes: %v", err)
307+
return
308+
}
309+
}
310+
}
311+
// Apply them.
312+
for filename, content := range contents {
313+
if err := os.WriteFile(filename, content, 0644); err != nil {
314+
base.Errorf("applying fix: %v", err)
315+
}
316+
}
317+
}
318+
}
319+
320+
// readZip reads the zipfile entries into the provided map.
321+
// It reports an error if updating the map would change an existing entry.
322+
func readZip(zipfile string, out map[string][]byte) error {
323+
r, err := zip.OpenReader(zipfile)
324+
if err != nil {
325+
return err
326+
}
327+
defer r.Close() // ignore error
328+
for _, f := range r.File {
329+
rc, err := f.Open()
330+
if err != nil {
331+
return err
332+
}
333+
content, err := io.ReadAll(rc)
334+
rc.Close() // ignore error
335+
if err != nil {
336+
return err
337+
}
338+
if prev, ok := out[f.Name]; ok && !bytes.Equal(prev, content) {
339+
return fmt.Errorf("inconsistent fixes to file %v", f.Name)
340+
}
341+
out[f.Name] = content
342+
}
343+
return nil
272344
}
273345

274346
// printJSONDiagnostics parses JSON (from the tool's stdout) and

src/cmd/go/internal/work/action.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ type Action struct {
109109
actionID cache.ActionID // cache ID of action input
110110
buildID string // build ID of action output
111111

112-
VetxOnly bool // Mode=="vet": only being called to supply info about dependencies
113-
needVet bool // Mode=="build": need to fill in vet config
114-
needBuild bool // Mode=="build": need to do actual build (can be false if needVet is true)
115-
vetCfg *vetConfig // vet config
116-
output []byte // output redirect buffer (nil means use b.Print)
112+
VetxOnly bool // Mode=="vet": only being called to supply info about dependencies
113+
needVet bool // Mode=="build": need to fill in vet config
114+
needBuild bool // Mode=="build": need to do actual build (can be false if needVet is true)
115+
needFix bool // Mode=="vet": need secondary target, a .zip file containing fixes
116+
vetCfg *vetConfig // vet config
117+
FixArchive string // the created .zip file containing fixes (if needFix)
118+
output []byte // output redirect buffer (nil means use b.Print)
117119

118120
sh *Shell // lazily created per-Action shell; see Builder.Shell
119121

@@ -869,9 +871,10 @@ func (b *Builder) cgoAction(p *load.Package, objdir string, deps []*Action, hasC
869871
// It depends on the action for compiling p.
870872
// If the caller may be causing p to be installed, it is up to the caller
871873
// to make sure that the install depends on (runs after) vet.
872-
func (b *Builder) VetAction(s *modload.State, mode, depMode BuildMode, p *load.Package) *Action {
874+
func (b *Builder) VetAction(s *modload.State, mode, depMode BuildMode, needFix bool, p *load.Package) *Action {
873875
a := b.vetAction(s, mode, depMode, p)
874876
a.VetxOnly = false
877+
a.needFix = needFix
875878
return a
876879
}
877880

0 commit comments

Comments
 (0)