Skip to content

Commit

Permalink
all: support Go 1.23 for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Aug 14, 2024
1 parent 5b30842 commit 667988f
Show file tree
Hide file tree
Showing 79 changed files with 3,013 additions and 6 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go: ['1.19.13', '1.20.14', '1.21.13', '1.22.6']
go: ['1.19.13', '1.20.14', '1.21.13', '1.22.6', '1.23.0']
name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
Expand Down Expand Up @@ -45,7 +45,6 @@ jobs:
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math/rand"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v -test.short runtime"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/debug"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/atomic"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/math"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/sys"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v strconv"
Expand All @@ -55,8 +54,18 @@ jobs:
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v sync/atomic"
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v time"
- name: Test (Linux, arm64, Go <=1.22)
if: runner.os == 'Linux' && (startsWith(matrix.go, '1.19.') || startsWith(matrix.go, '1.20.') || startsWith(matrix.go, '1.21.') || startsWith(matrix.go, '1.22.'))
run: |
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/atomic"
- name: Test (Linux, arm64, Go >=1.23)
if: runner.os == 'Linux' && startsWith(matrix.go, '1.23.')
run: |
GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/atomic"
- name: Test (amd64)
if: ${{ runner.os == 'Linux' || (runner.os == 'Windows' && !startsWith(matrix.go, '1.22.')) }}
if: runner.os == 'Linux' || (runner.os == 'Windows' && !startsWith(matrix.go, '1.22.') && !startsWith(matrix.go, '1.23.'))
run: |
go run test.go -args="-test.run=^Test -test.v fmt"
go run test.go -args="-test.run=^Test -test.v internal/abi"
Expand All @@ -73,7 +82,6 @@ jobs:
# Set an environment to do the default tests.
GO_RAND_TEST_HELPER_CODE=1 go run test.go -args="-test.run=^Test -test.v math/rand"
go run test.go -args="-test.run=^Test -test.v runtime/debug"
go run test.go -args="-test.run=^Test -test.v runtime/internal/atomic"
go run test.go -args="-test.run=^Test -test.v runtime/internal/math"
go run test.go -args="-test.run=^Test -test.v runtime/internal/sys"
go run test.go -args="-test.run=^Test -test.v strconv"
Expand All @@ -83,9 +91,19 @@ jobs:
go run test.go -args="-test.run=^Test -test.v sync/atomic"
go run test.go -args="-test.run=^Test -test.v time"
- name: Test (amd64, Go <=1.22)
if: (runner.os == 'Linux' || (runner.os == 'Windows' && !startsWith(matrix.go, '1.22.'))) && (startsWith(matrix.go, '1.19.') || startsWith(matrix.go, '1.20.') || startsWith(matrix.go, '1.21.') || startsWith(matrix.go, '1.22.'))
run: |
go run test.go -args="-test.run=^Test -test.v runtime/internal/atomic"
- name: Test (amd64, Go >=1.23)
if: (runner.os == 'Linux' || (runner.os == 'Windows' && !startsWith(matrix.go, '1.23.'))) && startsWith(matrix.go, '1.23.')
run: |
go run test.go -args="-test.run=^Test -test.v internal/runtime/atomic"
- name: Test (amd64, runtime)
# Skip runtime tests with Go 1.19 and Windows, as there is an issue (probably golang/go#51007 and golang/go#57455).
# For Go 1.22, Windows is not supported yet.
if: ${{ runner.os != 'Windows' || (!startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.22.')) }}
# For Go 1.22 and Go 1.23, Windows is not supported yet.
if: runner.os != 'Windows' || (!startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.22.') && !startsWith(matrix.go, '1.23.'))
run: |
go run test.go -args="-test.run=^Test -test.v -test.short runtime"
5 changes: 5 additions & 0 deletions 1.23_linux/internal/reflectlite/reflect_mirror_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func TestMirrorWithReflect(t *testing.T) {
//--to
func TestMirrorWithReflect(t *testing.T) {
t.Skip("file is not supported in this environment")
23 changes: 23 additions & 0 deletions 1.23_linux/internal/runtime/syscall/asm_linux_amd64.s.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//--from
TEXT ·Syscall6<ABIInternal>(SB),NOSPLIT,$0
// a6 already in R9.
// a5 already in R8.
MOVQ SI, R10 // a4
MOVQ DI, DX // a3
MOVQ CX, SI // a2
MOVQ BX, DI // a1
// num already in AX.
SYSCALL
CMPQ AX, $0xfffffffffffff001
JLS ok
NEGQ AX
MOVQ AX, CX // errno
MOVQ $-1, AX // r1
MOVQ $0, BX // r2
RET
ok:
// r1 already in AX.
MOVQ DX, BX // r2
MOVQ $0, CX // errno
RET
//--to
24 changes: 24 additions & 0 deletions 1.23_linux/internal/runtime/syscall/asm_linux_arm64.s.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//--from
TEXT ·Syscall6(SB),NOSPLIT,$0-80
MOVD num+0(FP), R8 // syscall entry
MOVD a1+8(FP), R0
MOVD a2+16(FP), R1
MOVD a3+24(FP), R2
MOVD a4+32(FP), R3
MOVD a5+40(FP), R4
MOVD a6+48(FP), R5
SVC
CMN $4095, R0
BCC ok
MOVD $-1, R4
MOVD R4, r1+56(FP)
MOVD ZR, r2+64(FP)
NEG R0, R0
MOVD R0, errno+72(FP)
RET
ok:
MOVD R0, r1+56(FP)
MOVD R1, r2+64(FP)
MOVD ZR, errno+72(FP)
RET
//--to
8 changes: 8 additions & 0 deletions 1.23_linux/internal/runtime/syscall/syscall_linux.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//--from
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
//--to
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) {
println("not implemented syscall at Syscall6", num)
panic("syscall.Syscall6")
return 0, 0, 0x26 // ENOSYS
}
22 changes: 22 additions & 0 deletions 1.23_linux/internal/runtime/syscall/syscall_linux_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//--from
import (
"internal/runtime/syscall"
"testing"
)
//--to
import (
"testing"
)
//--from
func TestEpollctlErrorSign(t *testing.T) {
v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{})

const EBADF = 0x09
if v != EBADF {
t.Errorf("epollctl = %v, want %v", v, EBADF)
}
}
//--to
func TestEpollctlErrorSign(t *testing.T) {
t.Skip("Epollctl is not supported in this environment")
}
12 changes: 12 additions & 0 deletions 1.23_linux/internal/syscall/unix/fcntl_unix.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//--from
func Fcntl(fd int, cmd int, arg int) (int, error) {
val, errno := fcntl(int32(fd), int32(cmd), int32(arg))
if val == -1 {
return int(val), syscall.Errno(errno)
}
return int(val), nil
}
//--to
func Fcntl(fd int, cmd int, arg int) (int, error) {
return 0, syscall.ENOSYS
}
5 changes: 5 additions & 0 deletions 1.23_linux/internal/testenv/exec.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func tryExec() error {
//--to
func tryExec() error {
return fmt.Errorf("can't probe for exec support")
5 changes: 5 additions & 0 deletions 1.23_linux/internal/testenv/testenv.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func HasGoBuild() bool {
//--to
func HasGoBuild() bool {
return false
4 changes: 4 additions & 0 deletions 1.23_linux/internal/testenv/testenv_notunix.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build windows || plan9 || (js && wasm) || wasip1
//--to
//go:build windows || plan9 || (js && wasm) || wasip1 || linux
4 changes: 4 additions & 0 deletions 1.23_linux/internal/testenv/testenv_unix.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build unix
//--to
//go:build unix && !linux
5 changes: 5 additions & 0 deletions 1.23_linux/math/big/link_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func TestLinkerGC(t *testing.T) {
//--to
func TestLinkerGC(t *testing.T) {
t.Skip("go tools are not supported in this environment")
5 changes: 5 additions & 0 deletions 1.23_linux/math/rand/default_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func TestDefaultRace(t *testing.T) {
//--to
func TestDefaultRace(t *testing.T) {
t.Skip("os.Getenv and creating processes are not supported in this environment")
5 changes: 5 additions & 0 deletions 1.23_linux/runtime/align_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//--from
func TestAtomicAlignment(t *testing.T) {
//--to
func TestAtomicAlignment(t *testing.T) {
t.Skip("file is not supported in this environment")
15 changes: 15 additions & 0 deletions 1.23_linux/runtime/callers_test.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//--from
func TestCallersNilPointerPanic(t *testing.T) {
//--to
func TestCallersNilPointerPanic(t *testing.T) {
t.Skip("handling nil pointer access is not supported in this environment")
//--from
func TestCallersDeferNilFuncPanic(t *testing.T) {
//--to
func TestCallersDeferNilFuncPanic(t *testing.T) {
t.Skip("handling nil pointer access is not supported in this environment")
//--from
func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) {
//--to
func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) {
t.Skip("handling nil pointer access is not supported in this environment")
8 changes: 8 additions & 0 deletions 1.23_linux/runtime/cgo/cgo.go.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//--from
*/
import "C"
//--to
#cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all
#cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup
*/
import "C"
69 changes: 69 additions & 0 deletions 1.23_linux/runtime/cgo/gcc_linux_amd64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//--from
#include <pthread.h>
#include <errno.h>
#include <string.h> // strerror
#include <signal.h>
#include <stdlib.h>
#include "libcgo.h"
#include "libcgo_unix.h"
//--to
#include <pthread.h>
#include <errno.h>
#include <string.h> // strerror
#include <stdlib.h>
#include "libcgo.h"
#include "libcgo_unix.h"
//--from
void
_cgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p;
size_t size;
int err;

sigfillset(&ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);

pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

pthread_sigmask(SIG_SETMASK, &oset, nil);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
//--to
void
_cgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
pthread_t p;
size_t size;
int err;

pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
//--from
static void*
threadentry(void *v)
{
//--to
static void*
threadentry(void *v)
{
extern void hitsumabushi_initializeThread(void);
hitsumabushi_initializeThread();
62 changes: 62 additions & 0 deletions 1.23_linux/runtime/cgo/gcc_linux_arm64.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//--from
void
_cgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p;
size_t size;
int err;

sigfillset(&ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);

pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

pthread_sigmask(SIG_SETMASK, &oset, nil);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
//--to
void
_cgo_sys_thread_start(ThreadStart *ts)
{
pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p;
size_t size;
int err;

sigfillset(&ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);

pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments
pthread_attr_getstacksize(&attr, &size);
// Leave stacklo=0 and set stackhi=size; mstart will do the rest.
ts->g->stackhi = size;
err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);

pthread_sigmask(SIG_SETMASK, &oset, nil);

if (err != 0) {
fatalf("pthread_create failed: %s", strerror(err));
}
}
//--from
static void*
threadentry(void *v)
{
//--to
static void*
threadentry(void *v)
{
// Note that threadentry will also be defined in gcc_linux.go in Go 1.22.
extern void hitsumabushi_initializeThread(void);
hitsumabushi_initializeThread();
26 changes: 26 additions & 0 deletions 1.23_linux/runtime/cgo/gcc_setenv.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//--from
void
x_cgo_setenv(char **arg)
{
_cgo_tsan_acquire();
setenv(arg[0], arg[1], 1);
_cgo_tsan_release();
}
//--to
void
x_cgo_setenv(char **arg)
{
}
//--from
void
x_cgo_unsetenv(char **arg)
{
_cgo_tsan_acquire();
unsetenv(arg[0]);
_cgo_tsan_release();
}
//--to
void
x_cgo_unsetenv(char **arg)
{
}
4 changes: 4 additions & 0 deletions 1.23_linux/runtime/cgo/gcc_sigaction.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//--from
//go:build linux && (amd64 || arm64 || ppc64le)
//--to
//go:build linux && (arm64 || ppc64le)
Loading

0 comments on commit 667988f

Please sign in to comment.