Skip to content

Commit 98e8c99

Browse files
committed
Merge remote-tracking branch 'go/release-branch.go1.24' into update-go1.24.3
2 parents 982da8f + 431f75a commit 98e8c99

38 files changed

+339
-151
lines changed

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
go1.24.2
2-
time 2025-03-26T19:09:39Z
1+
go1.24.3
2+
time 2025-04-30T18:13:34Z

src/cmd/cgo/internal/test/issue42018_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func test42018(t *testing.T) {
2727
recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i)))
2828
}
2929

30+
//go:noinline
3031
func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
3132
if n > 0 {
3233
recurseHANDLE(n-1, p, v)
@@ -36,6 +37,7 @@ func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
3637
}
3738
}
3839

40+
//go:noinline
3941
func recurseHWND(n int, p C.HWND, v uintptr) {
4042
if n > 0 {
4143
recurseHWND(n-1, p, v)

src/cmd/compile/internal/inline/inl.go

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,8 @@ func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) {
170170
}
171171

172172
ir.VisitFuncsBottomUp(funcs, func(funcs []*ir.Func, recursive bool) {
173-
numfns := numNonClosures(funcs)
174-
175173
for _, fn := range funcs {
176-
if !recursive || numfns > 1 {
177-
// We allow inlining if there is no
178-
// recursion, or the recursion cycle is
179-
// across more than one function.
180-
CanInline(fn, profile)
181-
} else {
182-
if base.Flag.LowerM > 1 && fn.OClosure == nil {
183-
fmt.Printf("%v: cannot inline %v: recursive\n", ir.Line(fn), fn.Nname)
184-
}
185-
}
174+
CanInline(fn, profile)
186175
if inlheur.Enabled() {
187176
analyzeFuncProps(fn, profile)
188177
}
@@ -1023,68 +1012,6 @@ func canInlineCallExpr(callerfn *ir.Func, n *ir.CallExpr, callee *ir.Func, bigCa
10231012
}
10241013
}
10251014

1026-
if callee == callerfn {
1027-
// Can't recursively inline a function into itself.
1028-
if log && logopt.Enabled() {
1029-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to %s", ir.FuncName(callerfn)))
1030-
}
1031-
return false, 0, false
1032-
}
1033-
1034-
isClosureParent := func(closure, parent *ir.Func) bool {
1035-
for p := closure.ClosureParent; p != nil; p = p.ClosureParent {
1036-
if p == parent {
1037-
return true
1038-
}
1039-
}
1040-
return false
1041-
}
1042-
if isClosureParent(callerfn, callee) {
1043-
// Can't recursively inline a parent of the closure into itself.
1044-
if log && logopt.Enabled() {
1045-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to closure parent: %s, %s", ir.FuncName(callerfn), ir.FuncName(callee)))
1046-
}
1047-
return false, 0, false
1048-
}
1049-
if isClosureParent(callee, callerfn) {
1050-
// Can't recursively inline a closure if there's a call to the parent in closure body.
1051-
if ir.Any(callee, func(node ir.Node) bool {
1052-
if call, ok := node.(*ir.CallExpr); ok {
1053-
if name, ok := call.Fun.(*ir.Name); ok && isClosureParent(callerfn, name.Func) {
1054-
return true
1055-
}
1056-
}
1057-
return false
1058-
}) {
1059-
if log && logopt.Enabled() {
1060-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to closure parent: %s, %s", ir.FuncName(callerfn), ir.FuncName(callee)))
1061-
}
1062-
return false, 0, false
1063-
}
1064-
}
1065-
do := func(fn *ir.Func) bool {
1066-
// Can't recursively inline a function if the function body contains
1067-
// a call to a function f, which the function f is one of the call arguments.
1068-
return ir.Any(fn, func(node ir.Node) bool {
1069-
if call, ok := node.(*ir.CallExpr); ok {
1070-
for _, arg := range call.Args {
1071-
if call.Fun == arg {
1072-
return true
1073-
}
1074-
}
1075-
}
1076-
return false
1077-
})
1078-
}
1079-
for _, fn := range []*ir.Func{callerfn, callee} {
1080-
if do(fn) {
1081-
if log && logopt.Enabled() {
1082-
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to function: %s", ir.FuncName(fn)))
1083-
}
1084-
return false, 0, false
1085-
}
1086-
}
1087-
10881015
if base.Flag.Cfg.Instrumenting && types.IsNoInstrumentPkg(callee.Sym().Pkg) {
10891016
// Runtime package must not be instrumented.
10901017
// Instrument skips runtime package. However, some runtime code can be

src/cmd/go/internal/load/pkg.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,12 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
25712571
vers := revInfo.Version
25722572
if vers != "" {
25732573
if st.Uncommitted {
2574-
vers += "+dirty"
2574+
// SemVer build metadata is dot-separated https://semver.org/#spec-item-10
2575+
if strings.HasSuffix(vers, "+incompatible") {
2576+
vers += ".dirty"
2577+
} else {
2578+
vers += "+dirty"
2579+
}
25752580
}
25762581
info.Main.Version = vers
25772582
}

src/cmd/go/testdata/script/build_version_stamping_git.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ go version -m example$GOEXE
108108
stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2e239bf29c13\s+'
109109
rm example$GOEXE
110110

111+
# Create +incompatible module
112+
exec git checkout v1.0.4
113+
exec git rm go.mod
114+
exec git commit -m 'commit 6'
115+
exec git tag v2.0.0
116+
exec git checkout HEAD^ go.mod
117+
# And make the tree +dirty
118+
mv README4 README5
119+
go build
120+
go version -m example$GOEXE
121+
stdout '\s+mod\s+example\s+v2.0.0\+incompatible.dirty\s+'
122+
rm example$GOEXE
123+
111124
-- $WORK/repo/go.mod --
112125
module example
113126

src/cmd/internal/obj/wasm/wasmobj.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,10 @@ func genWasmExportWrapper(s *obj.LSym, appendp func(p *obj.Prog, as obj.As, args
10061006
// In the unwinding case, we call wasm_pc_f_loop_export to handle stack switch and rewinding,
10071007
// until a normal return (non-unwinding) back to this function.
10081008
p = appendp(p, AIf)
1009-
p = appendp(p, AI32Const, retAddr)
1010-
p = appendp(p, AI32Const, constAddr(16))
1011-
p = appendp(p, AI32ShrU)
1009+
p = appendp(p, AI64Const, retAddr)
1010+
p = appendp(p, AI64Const, constAddr(16))
1011+
p = appendp(p, AI64ShrU)
1012+
p = appendp(p, AI32WrapI64)
10121013
p = appendp(p, ACall, obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: wasm_pc_f_loop_export})
10131014
p = appendp(p, AEnd)
10141015

src/cmd/link/internal/loader/loader.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,16 @@ func (st *loadState) addSym(name string, ver int, r *oReader, li uint32, kind in
432432
return i
433433
}
434434
// symbol already exists
435+
// Fix for issue #47185 -- given two dupok or BSS symbols with
436+
// different sizes, favor symbol with larger size. See also
437+
// issue #46653 and #72032.
438+
oldsz := l.SymSize(oldi)
439+
sz := int64(r.Sym(li).Siz())
435440
if osym.Dupok() {
436441
if l.flags&FlagStrictDups != 0 {
437442
l.checkdup(name, r, li, oldi)
438443
}
439-
// Fix for issue #47185 -- given two dupok symbols with
440-
// different sizes, favor symbol with larger size. See
441-
// also issue #46653.
442-
szdup := l.SymSize(oldi)
443-
sz := int64(r.Sym(li).Siz())
444-
if szdup < sz {
444+
if oldsz < sz {
445445
// new symbol overwrites old symbol.
446446
l.objSyms[oldi] = objSym{r.objidx, li}
447447
}
@@ -452,11 +452,24 @@ func (st *loadState) addSym(name string, ver int, r *oReader, li uint32, kind in
452452
if oldsym.Dupok() {
453453
return oldi
454454
}
455-
overwrite := r.DataSize(li) != 0
455+
// If one is a DATA symbol (i.e. has content, DataSize != 0)
456+
// and the other is BSS, the one with content wins.
457+
// If both are BSS, the one with larger size wins.
458+
// Specifically, the "overwrite" variable and the final result are
459+
//
460+
// new sym old sym overwrite
461+
// ---------------------------------------------
462+
// DATA DATA true => ERROR
463+
// DATA lg/eq BSS sm/eq true => new wins
464+
// DATA small BSS large true => ERROR
465+
// BSS large DATA small true => ERROR
466+
// BSS large BSS small true => new wins
467+
// BSS sm/eq D/B lg/eq false => old wins
468+
overwrite := r.DataSize(li) != 0 || oldsz < sz
456469
if overwrite {
457470
// new symbol overwrites old symbol.
458471
oldtyp := sym.AbiSymKindToSymKind[objabi.SymKind(oldsym.Type())]
459-
if !(oldtyp.IsData() && oldr.DataSize(oldli) == 0) {
472+
if !(oldtyp.IsData() && oldr.DataSize(oldli) == 0) || oldsz > sz {
460473
log.Fatalf("duplicated definition of symbol %s, from %s and %s", name, r.unit.Lib.Pkg, oldr.unit.Lib.Pkg)
461474
}
462475
l.objSyms[oldi] = objSym{r.objidx, li}

src/cmd/link/link_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
imacho "cmd/internal/macho"
23+
"cmd/internal/objfile"
2324
"cmd/internal/sys"
2425
)
2526

@@ -1541,3 +1542,53 @@ func TestCheckLinkname(t *testing.T) {
15411542
})
15421543
}
15431544
}
1545+
1546+
func TestLinknameBSS(t *testing.T) {
1547+
// Test that the linker chooses the right one as the definition
1548+
// for linknamed variables. See issue #72032.
1549+
testenv.MustHaveGoBuild(t)
1550+
t.Parallel()
1551+
1552+
tmpdir := t.TempDir()
1553+
1554+
src := filepath.Join("testdata", "linkname", "sched.go")
1555+
exe := filepath.Join(tmpdir, "sched.exe")
1556+
cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", exe, src)
1557+
out, err := cmd.CombinedOutput()
1558+
if err != nil {
1559+
t.Fatalf("build failed unexpectedly: %v:\n%s", err, out)
1560+
}
1561+
1562+
// Check the symbol size.
1563+
f, err := objfile.Open(exe)
1564+
if err != nil {
1565+
t.Fatalf("fail to open executable: %v", err)
1566+
}
1567+
defer f.Close()
1568+
syms, err := f.Symbols()
1569+
if err != nil {
1570+
t.Fatalf("fail to get symbols: %v", err)
1571+
}
1572+
found := false
1573+
for _, s := range syms {
1574+
if s.Name == "runtime.sched" || s.Name == "_runtime.sched" {
1575+
found = true
1576+
if s.Size < 100 {
1577+
// As of Go 1.25 (Mar 2025), runtime.sched has 6848 bytes on
1578+
// darwin/arm64. It should always be larger than 100 bytes on
1579+
// all platforms.
1580+
t.Errorf("runtime.sched symbol size too small: want > 100, got %d", s.Size)
1581+
}
1582+
}
1583+
}
1584+
if !found {
1585+
t.Errorf("runtime.sched symbol not found")
1586+
}
1587+
1588+
// Executable should run.
1589+
cmd = testenv.Command(t, exe)
1590+
out, err = cmd.CombinedOutput()
1591+
if err != nil {
1592+
t.Errorf("executable failed to run: %v\n%s", err, out)
1593+
}
1594+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import _ "unsafe"
8+
9+
type schedt struct{}
10+
11+
//go:linkname sched runtime.sched
12+
var sched schedt
13+
14+
func main() {
15+
select {
16+
default:
17+
println("hello")
18+
}
19+
}

src/crypto/tls/ech.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,28 @@ func decodeInnerClientHello(outer *clientHelloMsg, encoded []byte) (*clientHello
381381
return nil, errInvalidECHExt
382382
}
383383

384-
if len(inner.supportedVersions) != 1 || (len(inner.supportedVersions) >= 1 && inner.supportedVersions[0] != VersionTLS13) {
385-
return nil, errors.New("tls: client sent encrypted_client_hello extension and offered incompatible versions")
384+
hasTLS13 := false
385+
for _, v := range inner.supportedVersions {
386+
// Skip GREASE values (values of the form 0x?A0A).
387+
// GREASE (Generate Random Extensions And Sustain Extensibility) is a mechanism used by
388+
// browsers like Chrome to ensure TLS implementations correctly ignore unknown values.
389+
// GREASE values follow a specific pattern: 0x?A0A, where ? can be any hex digit.
390+
// These values should be ignored when processing supported TLS versions.
391+
if v&0x0F0F == 0x0A0A && v&0xff == v>>8 {
392+
continue
393+
}
394+
395+
// Ensure at least TLS 1.3 is offered.
396+
if v == VersionTLS13 {
397+
hasTLS13 = true
398+
} else if v < VersionTLS13 {
399+
// Reject if any non-GREASE value is below TLS 1.3, as ECH requires TLS 1.3+.
400+
return nil, errors.New("tls: client sent encrypted_client_hello extension with unsupported versions")
401+
}
402+
}
403+
404+
if !hasTLS13 {
405+
return nil, errors.New("tls: client sent encrypted_client_hello extension but did not offer TLS 1.3")
386406
}
387407

388408
return inner, nil

src/internal/runtime/maps/runtime_fast32_swiss.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
func runtime_mapaccess1_fast32(typ *abi.SwissMapType, m *Map, key uint32) unsafe.Pointer {
1818
if race.Enabled && m != nil {
1919
callerpc := sys.GetCallerPC()
20-
pc := abi.FuncPCABIInternal(runtime_mapaccess1)
20+
pc := abi.FuncPCABIInternal(runtime_mapaccess1_fast32)
2121
race.ReadPC(unsafe.Pointer(m), callerpc, pc)
2222
}
2323

@@ -86,7 +86,7 @@ func runtime_mapaccess1_fast32(typ *abi.SwissMapType, m *Map, key uint32) unsafe
8686
func runtime_mapaccess2_fast32(typ *abi.SwissMapType, m *Map, key uint32) (unsafe.Pointer, bool) {
8787
if race.Enabled && m != nil {
8888
callerpc := sys.GetCallerPC()
89-
pc := abi.FuncPCABIInternal(runtime_mapaccess1)
89+
pc := abi.FuncPCABIInternal(runtime_mapaccess2_fast32)
9090
race.ReadPC(unsafe.Pointer(m), callerpc, pc)
9191
}
9292

@@ -198,7 +198,7 @@ func runtime_mapassign_fast32(typ *abi.SwissMapType, m *Map, key uint32) unsafe.
198198
}
199199
if race.Enabled {
200200
callerpc := sys.GetCallerPC()
201-
pc := abi.FuncPCABIInternal(runtime_mapassign)
201+
pc := abi.FuncPCABIInternal(runtime_mapassign_fast32)
202202
race.WritePC(unsafe.Pointer(m), callerpc, pc)
203203
}
204204
if m.writing != 0 {
@@ -332,7 +332,7 @@ func runtime_mapassign_fast32ptr(typ *abi.SwissMapType, m *Map, key unsafe.Point
332332
}
333333
if race.Enabled {
334334
callerpc := sys.GetCallerPC()
335-
pc := abi.FuncPCABIInternal(runtime_mapassign)
335+
pc := abi.FuncPCABIInternal(runtime_mapassign_fast32ptr)
336336
race.WritePC(unsafe.Pointer(m), callerpc, pc)
337337
}
338338
if m.writing != 0 {
@@ -458,7 +458,7 @@ outer:
458458
func runtime_mapdelete_fast32(typ *abi.SwissMapType, m *Map, key uint32) {
459459
if race.Enabled {
460460
callerpc := sys.GetCallerPC()
461-
pc := abi.FuncPCABIInternal(runtime_mapassign)
461+
pc := abi.FuncPCABIInternal(runtime_mapdelete_fast32)
462462
race.WritePC(unsafe.Pointer(m), callerpc, pc)
463463
}
464464

0 commit comments

Comments
 (0)