Skip to content

Commit 64f7854

Browse files
committed
Update to Go 1.23.5
2 parents 161c3b7 + ab44565 commit 64f7854

Some content is hidden

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

44 files changed

+1035
-379
lines changed

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
go1.23.3
2-
time 2024-11-06T18:46:45Z
1+
go1.23.5
2+
time 2025-01-10T16:44:59Z

src/cmd/cgo/internal/testcarchive/carchive_test.go

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"unicode"
3434
)
3535

36-
var globalSkip = func(t *testing.T) {}
36+
var globalSkip = func(t testing.TB) {}
3737

3838
// Program to run.
3939
var bin []string
@@ -59,12 +59,12 @@ func TestMain(m *testing.M) {
5959

6060
func testMain(m *testing.M) int {
6161
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
62-
globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
62+
globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
6363
return m.Run()
6464
}
6565
if runtime.GOOS == "linux" {
6666
if _, err := os.Stat("/etc/alpine-release"); err == nil {
67-
globalSkip = func(t *testing.T) { t.Skip("skipping failing test on alpine - go.dev/issue/19938") }
67+
globalSkip = func(t testing.TB) { t.Skip("skipping failing test on alpine - go.dev/issue/19938") }
6868
return m.Run()
6969
}
7070
}
@@ -1291,8 +1291,8 @@ func TestPreemption(t *testing.T) {
12911291
}
12921292
}
12931293

1294-
// Issue 59294. Test calling Go function from C after using some
1295-
// stack space.
1294+
// Issue 59294 and 68285. Test calling Go function from C after with
1295+
// various stack space.
12961296
func TestDeepStack(t *testing.T) {
12971297
globalSkip(t)
12981298
testenv.MustHaveGoBuild(t)
@@ -1350,6 +1350,53 @@ func TestDeepStack(t *testing.T) {
13501350
}
13511351
}
13521352

1353+
func BenchmarkCgoCallbackMainThread(b *testing.B) {
1354+
// Benchmark for calling into Go fron C main thread.
1355+
// See issue #68587.
1356+
//
1357+
// It uses a subprocess, which is a C binary that calls
1358+
// Go on the main thread b.N times. There is some overhead
1359+
// for launching the subprocess. It is probably fine when
1360+
// b.N is large.
1361+
1362+
globalSkip(b)
1363+
testenv.MustHaveGoBuild(b)
1364+
testenv.MustHaveCGO(b)
1365+
testenv.MustHaveBuildMode(b, "c-archive")
1366+
1367+
if !testWork {
1368+
defer func() {
1369+
os.Remove("testp10" + exeSuffix)
1370+
os.Remove("libgo10.a")
1371+
os.Remove("libgo10.h")
1372+
}()
1373+
}
1374+
1375+
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
1376+
out, err := cmd.CombinedOutput()
1377+
b.Logf("%v\n%s", cmd.Args, out)
1378+
if err != nil {
1379+
b.Fatal(err)
1380+
}
1381+
1382+
ccArgs := append(cc, "-o", "testp10"+exeSuffix, "main10.c", "libgo10.a")
1383+
out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
1384+
b.Logf("%v\n%s", ccArgs, out)
1385+
if err != nil {
1386+
b.Fatal(err)
1387+
}
1388+
1389+
argv := cmdToRun("./testp10")
1390+
argv = append(argv, fmt.Sprint(b.N))
1391+
cmd = exec.Command(argv[0], argv[1:]...)
1392+
1393+
b.ResetTimer()
1394+
err = cmd.Run()
1395+
if err != nil {
1396+
b.Fatal(err)
1397+
}
1398+
}
1399+
13531400
func TestSharedObject(t *testing.T) {
13541401
// Test that we can put a Go c-archive into a C shared object.
13551402
globalSkip(t)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2024 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 "C"
8+
9+
//export GoF
10+
func GoF() {}
11+
12+
func main() {}

src/cmd/cgo/internal/testcarchive/testdata/libgo9/a.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,29 @@ package main
66

77
import "runtime"
88

9+
// extern void callGoWithVariousStack(int);
910
import "C"
1011

1112
func main() {}
1213

1314
//export GoF
14-
func GoF() { runtime.GC() }
15+
func GoF(p int32) {
16+
runtime.GC()
17+
if p != 0 {
18+
panic("panic")
19+
}
20+
}
21+
22+
//export callGoWithVariousStackAndGoFrame
23+
func callGoWithVariousStackAndGoFrame(p int32) {
24+
if p != 0 {
25+
defer func() {
26+
e := recover()
27+
if e == nil {
28+
panic("did not panic")
29+
}
30+
runtime.GC()
31+
}()
32+
}
33+
C.callGoWithVariousStack(C.int(p));
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 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+
#include <stdio.h>
6+
#include <stdlib.h>
7+
8+
#include "libgo10.h"
9+
10+
int main(int argc, char **argv) {
11+
int n, i;
12+
13+
if (argc != 2) {
14+
perror("wrong arg");
15+
return 2;
16+
}
17+
n = atoi(argv[1]);
18+
for (i = 0; i < n; i++)
19+
GoF();
20+
21+
return 0;
22+
}

src/cmd/cgo/internal/testcarchive/testdata/main9.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66

77
void use(int *x) { (*x)++; }
88

9-
void callGoFWithDeepStack() {
9+
void callGoFWithDeepStack(int p) {
1010
int x[10000];
1111

1212
use(&x[0]);
1313
use(&x[9999]);
1414

15-
GoF();
15+
GoF(p);
1616

1717
use(&x[0]);
1818
use(&x[9999]);
1919
}
2020

21+
void callGoWithVariousStack(int p) {
22+
GoF(0); // call GoF without using much stack
23+
callGoFWithDeepStack(p); // call GoF with a deep stack
24+
GoF(0); // again on a shallow stack
25+
}
26+
2127
int main() {
22-
GoF(); // call GoF without using much stack
23-
callGoFWithDeepStack(); // call GoF with a deep stack
28+
callGoWithVariousStack(0);
29+
30+
callGoWithVariousStackAndGoFrame(0); // normal execution
31+
callGoWithVariousStackAndGoFrame(1); // panic and recover
2432
}

src/cmd/compile/internal/escape/solve.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ func containsClosure(f, c *ir.Func) bool {
318318
return false
319319
}
320320

321-
// Closures within function Foo are named like "Foo.funcN..." or "Foo-rangeN".
322-
// TODO(mdempsky): Better way to recognize this.
323-
fn := f.Sym().Name
324-
cn := c.Sym().Name
325-
return len(cn) > len(fn) && cn[:len(fn)] == fn && (cn[len(fn)] == '.' || cn[len(fn)] == '-')
321+
for p := c.ClosureParent; p != nil; p = p.ClosureParent {
322+
if p == f {
323+
return true
324+
}
325+
}
326+
return false
326327
}

src/cmd/compile/internal/importer/gcimporter_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,23 @@ func TestIssue25596(t *testing.T) {
582582
compileAndImportPkg(t, "issue25596")
583583
}
584584

585+
func TestIssue70394(t *testing.T) {
586+
testenv.MustHaveGoBuild(t)
587+
588+
// This package only handles gc export data.
589+
if runtime.Compiler != "gc" {
590+
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
591+
}
592+
593+
pkg := compileAndImportPkg(t, "alias")
594+
obj := lookupObj(t, pkg.Scope(), "A")
595+
596+
typ := obj.Type()
597+
if _, ok := typ.(*types2.Alias); !ok {
598+
t.Fatalf("type of %s is %s, wanted an alias", obj, typ)
599+
}
600+
}
601+
585602
func importPkg(t *testing.T, path, srcDir string) *types2.Package {
586603
pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil)
587604
if err != nil {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2024 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 testdata
6+
7+
type A = int32

src/cmd/compile/internal/importer/ureader.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
2929
pr := pkgReader{
3030
PkgDecoder: input,
3131

32-
ctxt: ctxt,
33-
imports: imports,
34-
// Currently, the compiler panics when using Alias types.
35-
// TODO(gri) set to true once this is fixed (issue #66873)
36-
enableAlias: false,
32+
ctxt: ctxt,
33+
imports: imports,
34+
enableAlias: true,
3735

3836
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
3937
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),

0 commit comments

Comments
 (0)