From 10556e53f26a40c3f2af7892b90b97d45c8fe687 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 15 Aug 2024 22:31:11 -0400 Subject: [PATCH 01/59] CGO support for Netbsd --- dlfcn_netbsd.go | 33 ++++++++++++++++++++++++++++++++ examples/libc/main.go | 2 ++ examples/libc/main_unix.go | 2 +- internal/cgo/dlfcn_cgo_unix.go | 2 +- internal/cgo/syscall_cgo_unix.go | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 dlfcn_netbsd.go diff --git a/dlfcn_netbsd.go b/dlfcn_netbsd.go new file mode 100644 index 00000000..ddb95e07 --- /dev/null +++ b/dlfcn_netbsd.go @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +package purego + +import "github.com/ebitengine/purego/internal/cgo" + +// Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h + +const ( + intSize = 32 << (^uint(0) >> 63) // 32 or 64 + RTLD_DEFAULT = 1< Date: Thu, 15 Aug 2024 22:32:27 -0400 Subject: [PATCH 02/59] missing build tag --- internal/load/load_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/load/load_unix.go b/internal/load/load_unix.go index 024c591e..2fbd3830 100644 --- a/internal/load/load_unix.go +++ b/internal/load/load_unix.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd package load From 92769ac5933aa5f725ffe8e0f60af112be64118b Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 07:09:40 -0400 Subject: [PATCH 03/59] syscallArgs --- syscall_cgo_netbsd.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 syscall_cgo_netbsd.go diff --git a/syscall_cgo_netbsd.go b/syscall_cgo_netbsd.go new file mode 100644 index 00000000..db5f8b90 --- /dev/null +++ b/syscall_cgo_netbsd.go @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2024 The Ebitengine Authors + +//go:build cgo + +package purego + +import ( + "github.com/ebitengine/purego/internal/cgo" +) + +var syscall15XABI0 = uintptr(cgo.Syscall15XABI0) + +//go:nosplit +func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { + return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) +} + +func NewCallback(_ interface{}) uintptr { + panic("purego: NewCallback on Linux is only supported on amd64/arm64") +} From 000117cfbc56e9ebd02fe5a087bf2d490ced5dcf Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 07:26:29 -0400 Subject: [PATCH 04/59] syscall15Args --- syscall.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syscall.go b/syscall.go index c30688dd..0a730311 100644 --- a/syscall.go +++ b/syscall.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux || windows +//go:build darwin || freebsd || linux || netbsd || windows package purego From b23644e179533b3c179e2b27b209dbf9054faf40 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 07:44:55 -0400 Subject: [PATCH 05/59] some more --- func.go | 2 +- go_runtime.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/func.go b/func.go index a8a3d620..fa91b8fe 100644 --- a/func.go +++ b/func.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux || windows +//go:build darwin || freebsd || linux || netbsd || windows package purego diff --git a/go_runtime.go b/go_runtime.go index 13671ff2..b327f786 100644 --- a/go_runtime.go +++ b/go_runtime.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux || windows +//go:build darwin || freebsd || linux || netbsd || windows package purego From 68d652cde3ad46c301b697e79cc0532254efe6ac Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 07:45:19 -0400 Subject: [PATCH 06/59] build tag --- cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgo.go b/cgo.go index 7d5abef3..31dc8f19 100644 --- a/cgo.go +++ b/cgo.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build cgo && (darwin || freebsd || linux) +//go:build cgo && (darwin || freebsd || netbsd || linux) package purego From cf0745db2deefad23e886fb015145fba2db56a15 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 07:46:15 -0400 Subject: [PATCH 07/59] test --- dlfcn_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlfcn_test.go b/dlfcn_test.go index 6ffab82c..9eddeb9a 100644 --- a/dlfcn_test.go +++ b/dlfcn_test.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd package purego_test From 3c3731e9ae8e0e21f7418648cb0a83144cdd3e79 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 10:56:18 -0400 Subject: [PATCH 08/59] build tag for netbsd --- internal/cgo/dlfcn_cgo_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cgo/dlfcn_cgo_unix.go b/internal/cgo/dlfcn_cgo_unix.go index f8b180b3..14d09d73 100644 --- a/internal/cgo/dlfcn_cgo_unix.go +++ b/internal/cgo/dlfcn_cgo_unix.go @@ -6,7 +6,7 @@ package cgo /* - #cgo LDFLAGS: -ldl + #cgo !netbsd LDFLAGS: -ldl #include #include From e87d728fadf61d3a7429e615b460c3a9b9212bb6 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Fri, 16 Aug 2024 20:10:13 -0400 Subject: [PATCH 09/59] some more stuff needed fixing --- dlfcn_test.go | 2 +- func_test.go | 4 +++- internal/cgo/dlfcn_cgo_unix.go | 2 +- internal/cgo/syscall_cgo_unix.go | 2 +- syscall_cgo_netbsd.go | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dlfcn_test.go b/dlfcn_test.go index 9eddeb9a..02e9a243 100644 --- a/dlfcn_test.go +++ b/dlfcn_test.go @@ -54,7 +54,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { } var args []string - if runtime.GOOS == "freebsd" { + if runtime.GOOS == "freebsd" || runtime.GOOS == "netbsd" { args = []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile} } else { args = []string{"-shared", "-Wall", "-Werror", "-o", libFile} diff --git a/func_test.go b/func_test.go index bb8e2159..dc62ef9e 100644 --- a/func_test.go +++ b/func_test.go @@ -23,6 +23,8 @@ func getSystemLibrary() (string, error) { return "libc.so.7", nil case "windows": return "ucrtbase.dll", nil + case "netbsd": + return "libc.so", nil default: return "", fmt.Errorf("GOOS=%s is not supported", runtime.GOOS) } @@ -111,7 +113,7 @@ func TestRegisterFunc_Floats(t *testing.T) { } func TestRegisterLibFunc_Bool(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { t.Skip("Platform doesn't support callbacks") return } diff --git a/internal/cgo/dlfcn_cgo_unix.go b/internal/cgo/dlfcn_cgo_unix.go index 14d09d73..6d0571ab 100644 --- a/internal/cgo/dlfcn_cgo_unix.go +++ b/internal/cgo/dlfcn_cgo_unix.go @@ -6,7 +6,7 @@ package cgo /* - #cgo !netbsd LDFLAGS: -ldl +#cgo !netbsd LDFLAGS: -ldl #include #include diff --git a/internal/cgo/syscall_cgo_unix.go b/internal/cgo/syscall_cgo_unix.go index 072ea11c..6b2c4989 100644 --- a/internal/cgo/syscall_cgo_unix.go +++ b/internal/cgo/syscall_cgo_unix.go @@ -9,7 +9,7 @@ package cgo // because Cgo and assembly files can't be in the same package. /* - #cgo LDFLAGS: -ldl +#cgo !netbsd LDFLAGS: -ldl #include #include diff --git a/syscall_cgo_netbsd.go b/syscall_cgo_netbsd.go index db5f8b90..c964864d 100644 --- a/syscall_cgo_netbsd.go +++ b/syscall_cgo_netbsd.go @@ -17,5 +17,5 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a } func NewCallback(_ interface{}) uintptr { - panic("purego: NewCallback on Linux is only supported on amd64/arm64") + panic("purego: NewCallback is not supported on NetBSD") } From 0b92ec5b3adc77595af142c63e34252f37adb565 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 17 Aug 2024 07:48:01 -0400 Subject: [PATCH 10/59] ignore tests --- func_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/func_test.go b/func_test.go index dc62ef9e..048eebb3 100644 --- a/func_test.go +++ b/func_test.go @@ -17,14 +17,14 @@ func getSystemLibrary() (string, error) { switch runtime.GOOS { case "darwin": return "/usr/lib/libSystem.B.dylib", nil - case "linux": - return "libc.so.6", nil case "freebsd": return "libc.so.7", nil - case "windows": - return "ucrtbase.dll", nil + case "linux": + return "libc.so.6", nil case "netbsd": return "libc.so", nil + case "windows": + return "ucrtbase.dll", nil default: return "", fmt.Errorf("GOOS=%s is not supported", runtime.GOOS) } @@ -45,7 +45,7 @@ func TestRegisterFunc(t *testing.T) { } func Test_qsort(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { t.Skip("Platform doesn't support Floats") return } @@ -74,7 +74,7 @@ func Test_qsort(t *testing.T) { } func TestRegisterFunc_Floats(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { t.Skip("Platform doesn't support Floats") return } From 68c9fa4b51986d9281229549b251aa97db3b7789 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sun, 18 Aug 2024 13:32:06 -0400 Subject: [PATCH 11/59] github actions --- .github/workflows/test.yml | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1adf8fc..621ee32d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -209,6 +209,81 @@ jobs: echo "=> go test CGO_ENABLED=1" env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... + if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then + echo "=> go test race" + go test -race -shuffle=on -v -count=10 ./... + fi + netbsd: + strategy: + matrix: + go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.6', '1.23.0'] + name: Test with Go ${{ matrix.go }} on NetBSD + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Run in netbsd + uses: vmactions/netbsd-vm@v1 + with: + usesh: true + prepare: | + /usr/sbin/pkg_add curl + run: | + echo "Running tests on $(uname -a) at $PWD" + + # verify Go is available + go version + + echo "=> go build" + go build -v ./... + # Compile without optimization to check potential stack overflow. + # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. + # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. + go build "-gcflags=all=-N -l" -v ./... + + # Check cross-compiling Windows binaries. + env GOOS=windows GOARCH=386 go build -v ./... + env GOOS=windows GOARCH=amd64 go build -v ./... + env GOOS=windows GOARCH=arm go build -v ./... + env GOOS=windows GOARCH=arm64 go build -v ./... + + # Check cross-compiling macOS binaries. + env GOOS=darwin GOARCH=amd64 go build -v ./... + env GOOS=darwin GOARCH=arm64 go build -v ./... + + # Check cross-compiling Linux binaries. + env GOOS=linux GOARCH=amd64 go build -v ./... + env GOOS=linux GOARCH=arm64 go build -v ./... + + # Check cross-compiling FreeBSD binaries. + env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + echo "=> go build (plugin)" + # Make sure that plugin buildmode works since we save the R15 register (#254) + go build -buildmode=plugin ./examples/libc + + echo "=> go mod vendor" + mkdir /tmp/vendoring + cd /tmp/vendoring + go mod init foo + echo 'package main' > main.go + echo 'import (' >> main.go + echo ' _ "github.com/ebitengine/purego"' >> main.go + echo ')' >> main.go + echo 'func main() {}' >> main.go + go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE + go mod tidy + go mod vendor + go build -v . + + # TODO: uncomment once Cgo is not required for FreeBSD + # cd $GITHUB_WORKSPACE + # echo "=> go test CGO_ENABLED=0" + # env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... + + echo "=> go test CGO_ENABLED=1" + env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... + if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then echo "=> go test race" go test -race -shuffle=on -v -count=10 ./... From 4d8201204783845c3a3d7a11c3e74f82e11aff71 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sun, 18 Aug 2024 13:55:04 -0400 Subject: [PATCH 12/59] include go --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 621ee32d..324746ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -227,6 +227,9 @@ jobs: usesh: true prepare: | /usr/sbin/pkg_add curl + fetch https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz + rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz + ln -s /usr/local/go/bin/go /usr/local/bin run: | echo "Running tests on $(uname -a) at $PWD" From f37da236922d364b882d9f6d175b37f4d6a7144b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 22 Aug 2024 20:35:35 +0900 Subject: [PATCH 13/59] examples/window: replace deprecated functions (#269) --- examples/window/main_windows.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/window/main_windows.go b/examples/window/main_windows.go index 5d81dcd1..6e7d91bd 100644 --- a/examples/window/main_windows.go +++ b/examples/window/main_windows.go @@ -96,7 +96,10 @@ func init() { } func main() { - className := windows.StringToUTF16Ptr("Sample Window Class") + className, err := windows.UTF16PtrFromString("Sample Window Class") + if err != nil { + panic(err) + } inst := GetModuleHandle(className) wc := WNDCLASSEX{ @@ -114,10 +117,14 @@ func main() { Right: 320, Bottom: 240, } + title, err := windows.UTF16PtrFromString("My Title") + if err != nil { + panic(err) + } AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, false) hwnd := CreateWindowEx( 0, className, - windows.StringToUTF16Ptr("My Title"), + title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, int(wr.Right-wr.Left), int(wr.Bottom-wr.Top), 0, 0, inst, nil, From f8c77421835650ec1f408ad4281da1d76583d6b0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 22 Aug 2024 22:03:01 +0900 Subject: [PATCH 14/59] all: remove dependencies on golang.org/x/sys (#271) The example still has the dependency on golang.org/x/sys. Updates #270 --- internal/load/load_windows.go | 8 +++++--- syscall_windows.go | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/load/load_windows.go b/internal/load/load_windows.go index b8593d7c..713aac48 100644 --- a/internal/load/load_windows.go +++ b/internal/load/load_windows.go @@ -3,13 +3,15 @@ package load -import "golang.org/x/sys/windows" +import ( + "syscall" +) func OpenLibrary(name string) (uintptr, error) { - handle, err := windows.LoadLibrary(name) + handle, err := syscall.LoadLibrary(name) return uintptr(handle), err } func OpenSymbol(lib uintptr, name string) (uintptr, error) { - return windows.GetProcAddress(windows.Handle(lib), name) + return syscall.GetProcAddress(syscall.Handle(lib), name) } diff --git a/syscall_windows.go b/syscall_windows.go index 708948bb..5fbfcabf 100644 --- a/syscall_windows.go +++ b/syscall_windows.go @@ -6,8 +6,6 @@ package purego import ( "reflect" "syscall" - - "golang.org/x/sys/windows" ) var syscall15XABI0 uintptr @@ -44,5 +42,5 @@ func NewCallback(fn interface{}) uintptr { } func loadSymbol(handle uintptr, name string) (uintptr, error) { - return windows.GetProcAddress(windows.Handle(handle), name) + return syscall.GetProcAddress(syscall.Handle(handle), name) } From 128551e7e45ca3932e5ab5af35a89b1b340b4859 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sun, 25 Aug 2024 09:00:14 -0400 Subject: [PATCH 15/59] Clarify Example section and Dl* windows equivalents (#274) --- README.md | 3 ++- dlerror.go | 2 ++ dlfcn.go | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d783be6b..f1ff9053 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ except for float arguments and return values. ## Example -This example only works on macOS and Linux. For a complete example look at [libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD. +The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can +be seen in the complete example at [examples/libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD. ```go package main diff --git a/dlerror.go b/dlerror.go index cf4c0505..95cdfe16 100644 --- a/dlerror.go +++ b/dlerror.go @@ -6,6 +6,8 @@ package purego // Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose. +// +// This type is not available on Windows as there is no counterpart to it on Windows. type Dlerror struct { s string } diff --git a/dlfcn.go b/dlfcn.go index 8fe31e1c..87ddd6f2 100644 --- a/dlfcn.go +++ b/dlfcn.go @@ -33,6 +33,10 @@ func init() { // A second call to Dlopen with the same path will return the same handle, but the internal // reference count for the handle will be incremented. Therefore, all // Dlopen calls should be balanced with a Dlclose call. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.NewLazyDLL], or +// [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead. func Dlopen(path string, mode int) (uintptr, error) { u := fnDlopen(path, mode) if u == 0 { @@ -45,6 +49,9 @@ func Dlopen(path string, mode int) (uintptr, error) { // It returns the address where that symbol is loaded into memory. If the symbol is not found, // in the specified library or any of the libraries that were automatically loaded by Dlopen // when that library was loaded, Dlsym returns zero. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.GetProcAddress] for Windows instead. func Dlsym(handle uintptr, name string) (uintptr, error) { u := fnDlsym(handle, name) if u == 0 { @@ -56,6 +63,9 @@ func Dlsym(handle uintptr, name string) (uintptr, error) { // Dlclose decrements the reference count on the dynamic library handle. // If the reference count drops to zero and no other loaded libraries // use symbols in it, then the dynamic library is unloaded. +// +// This function is not available on Windows. +// Use [golang.org/x/sys/windows.FreeLibrary] for Windows instead. func Dlclose(handle uintptr) error { if fnDlclose(handle) { return Dlerror{fnDlerror()} From 5ad94152a5e01e3c061dfc6348e1a9b51f450aed Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 25 Aug 2024 22:23:03 +0900 Subject: [PATCH 16/59] purego: mention LoadLibraryEx at Dlopen (#275) Updates #273 --- dlfcn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlfcn.go b/dlfcn.go index 87ddd6f2..f70a2458 100644 --- a/dlfcn.go +++ b/dlfcn.go @@ -35,8 +35,8 @@ func init() { // Dlopen calls should be balanced with a Dlclose call. // // This function is not available on Windows. -// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.NewLazyDLL], or -// [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead. +// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.LoadLibraryEx], +// [golang.org/x/sys/windows.NewLazyDLL], or [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead. func Dlopen(path string, mode int) (uintptr, error) { u := fnDlopen(path, mode) if u == 0 { From c3f4c9c274c333112cd6901e5c2be717f517ef89 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 4 Sep 2024 00:08:04 +0900 Subject: [PATCH 17/59] examples: remove depdencies on golang.org/x/sys/windows (#278) Closes #270 --- examples/libc/main_windows.go | 6 ++++-- examples/window/main_windows.go | 19 +++++++++++-------- go.mod | 2 -- go.sum | 2 -- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/libc/main_windows.go b/examples/libc/main_windows.go index b120ea50..3f3270a4 100644 --- a/examples/libc/main_windows.go +++ b/examples/libc/main_windows.go @@ -3,9 +3,11 @@ package main -import "golang.org/x/sys/windows" +import "syscall" func openLibrary(name string) (uintptr, error) { - handle, err := windows.LoadLibrary(name) + // Use [syscall.LoadLibrary] here to avoid external dependencies (#270). + // For actual use cases, [golang.org/x/sys/windows.NewLazySystemDLL] is recommended. + handle, err := syscall.LoadLibrary(name) return uintptr(handle), err } diff --git a/examples/window/main_windows.go b/examples/window/main_windows.go index 6e7d91bd..1f3d9412 100644 --- a/examples/window/main_windows.go +++ b/examples/window/main_windows.go @@ -5,10 +5,9 @@ package main import ( "runtime" + "syscall" "unsafe" - "golang.org/x/sys/windows" - "github.com/ebitengine/purego" ) @@ -78,10 +77,14 @@ var ( ) func init() { - kernel32 := windows.NewLazySystemDLL("kernel32.dll").Handle() + // Use [syscall.NewLazyDLL] here to avoid external dependencies (#270). + // For actual use cases, [golang.org/x/sys/windows.NewLazySystemDLL] is recommended. + kernel32 := syscall.NewLazyDLL("kernel32.dll").Handle() purego.RegisterLibFunc(&GetModuleHandle, kernel32, "GetModuleHandleW") - user32 := windows.NewLazySystemDLL("user32.dll").Handle() + // Use [syscall.NewLazyDLL] here to avoid external dependencies (#270). + // For actual use cases, [golang.org/x/sys/windows.NewLazySystemDLL] is recommended. + user32 := syscall.NewLazyDLL("user32.dll").Handle() purego.RegisterLibFunc(&RegisterClassEx, user32, "RegisterClassExW") purego.RegisterLibFunc(&CreateWindowEx, user32, "CreateWindowExW") purego.RegisterLibFunc(&AdjustWindowRect, user32, "AdjustWindowRect") @@ -96,7 +99,7 @@ func init() { } func main() { - className, err := windows.UTF16PtrFromString("Sample Window Class") + className, err := syscall.UTF16PtrFromString("Sample Window Class") if err != nil { panic(err) } @@ -104,7 +107,7 @@ func main() { wc := WNDCLASSEX{ Size: uint32(unsafe.Sizeof(WNDCLASSEX{})), - WndProc: windows.NewCallback(wndProc), + WndProc: syscall.NewCallback(wndProc), Instance: inst, ClassName: className, } @@ -117,7 +120,7 @@ func main() { Right: 320, Bottom: 240, } - title, err := windows.UTF16PtrFromString("My Title") + title, err := syscall.UTF16PtrFromString("My Title") if err != nil { panic(err) } @@ -130,7 +133,7 @@ func main() { 0, 0, inst, nil, ) if hwnd == 0 { - panic(windows.GetLastError()) + panic(syscall.GetLastError()) } ShowWindow(hwnd, SW_SHOW) diff --git a/go.mod b/go.mod index bdab0415..ea4133e8 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/ebitengine/purego go 1.18 - -require golang.org/x/sys v0.23.0 diff --git a/go.sum b/go.sum index d9ec23b2..e69de29b 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From f091b66cf7d42bad14c086015dce69a904cddbc0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 24 Sep 2024 00:23:10 +0900 Subject: [PATCH 18/59] all: release v0.9.0-alpha From 570751ca5a78aef97c831007592579df75f7bf53 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sun, 25 Aug 2024 08:15:14 -0400 Subject: [PATCH 19/59] test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 324746ef..a42eaccd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -228,7 +228,7 @@ jobs: prepare: | /usr/sbin/pkg_add curl fetch https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz - rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz + rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: | echo "Running tests on $(uname -a) at $PWD" From 4b324b2bb88f043a152af6e4d2ee0f5edfa6f7ca Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Mon, 14 Oct 2024 19:51:48 -0400 Subject: [PATCH 20/59] fix install Go on freebsd --- .github/ISSUE_TEMPLATE/00-bug.yml | 1 + .github/workflows/test.yml | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/00-bug.yml b/.github/ISSUE_TEMPLATE/00-bug.yml index 91350864..c5dc1b80 100644 --- a/.github/ISSUE_TEMPLATE/00-bug.yml +++ b/.github/ISSUE_TEMPLATE/00-bug.yml @@ -17,6 +17,7 @@ body: - label: macOS - label: Linux - label: FreeBSD + - label: NetBSD - label: Android - label: iOS validations: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a42eaccd..de2c982c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -226,8 +226,7 @@ jobs: with: usesh: true prepare: | - /usr/sbin/pkg_add curl - fetch https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz + pkg_add -v https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: | @@ -279,7 +278,7 @@ jobs: go mod vendor go build -v . - # TODO: uncomment once Cgo is not required for FreeBSD + # TODO: uncomment once Cgo is not required for NetBSD # cd $GITHUB_WORKSPACE # echo "=> go test CGO_ENABLED=0" # env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... From 7ab881212ecba248af97d2f876ee3b39a513b1b2 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Mon, 14 Oct 2024 19:58:16 -0400 Subject: [PATCH 21/59] fix install Go on freebsd --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de2c982c..6d071640 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -226,7 +226,7 @@ jobs: with: usesh: true prepare: | - pkg_add -v https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz + /usr/sbin/pkg_add -v https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: | From 3b55709edf6832854987b985dae2fcb82876add0 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 07:33:31 -0400 Subject: [PATCH 22/59] fix install Go --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d071640..674b29f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -226,7 +226,7 @@ jobs: with: usesh: true prepare: | - /usr/sbin/pkg_add -v https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz + ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: | From ec53690b29dbce69136800acd7ac95bdb7e948b0 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 07:53:11 -0400 Subject: [PATCH 23/59] remove Go versions that dl doesn't have downloads for --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 674b29f4..0cc8421f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -216,7 +216,7 @@ jobs: netbsd: strategy: matrix: - go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.6', '1.23.0'] + go: ['1.21.13', '1.22.6', '1.23.0'] name: Test with Go ${{ matrix.go }} on NetBSD runs-on: ubuntu-22.04 steps: From 49cf092fc3d85ee22480871bcbb6486f06681772 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 09:51:35 -0400 Subject: [PATCH 24/59] mkdir --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cc8421f..8d179335 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -227,6 +227,7 @@ jobs: usesh: true prepare: | ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz + mkdir /usr/local rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: | From ae1d516120c7475d0b5e4bc43fa82e52c1c7f09f Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 10:31:14 -0400 Subject: [PATCH 25/59] specify default shell --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d179335..0b2d1e7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -219,6 +219,9 @@ jobs: go: ['1.21.13', '1.22.6', '1.23.0'] name: Test with Go ${{ matrix.go }} on NetBSD runs-on: ubuntu-22.04 + defaults: + run: + shell: sh steps: - uses: actions/checkout@v4 - name: Run in netbsd From 6c57d3f7efb597e50fa31fe0b598986d6917d3e8 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 10:50:56 -0400 Subject: [PATCH 26/59] disabled syncing to host VM --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b2d1e7a..06b5c241 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -228,6 +228,7 @@ jobs: uses: vmactions/netbsd-vm@v1 with: usesh: true + sync: no prepare: | ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz mkdir /usr/local From ed60fb80d93d11eeede08b09e9ccc1c7aed1c214 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 10:56:38 -0400 Subject: [PATCH 27/59] try installing bash --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06b5c241..3a3799d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -230,6 +230,7 @@ jobs: usesh: true sync: no prepare: | + pkg_add -v bash ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz mkdir /usr/local rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz From c5caadb655fef92334d93ad84d23cb2cc4a7b05d Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 11:00:48 -0400 Subject: [PATCH 28/59] prefix pkg_add --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a3799d9..d3832104 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -230,7 +230,7 @@ jobs: usesh: true sync: no prepare: | - pkg_add -v bash + /usr/sbin/pkg_add -v bash ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz mkdir /usr/local rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz From d66821117bb1c485ee4d73aba2cd033da50c3849 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 11:07:46 -0400 Subject: [PATCH 29/59] try bash --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3832104..c9b8d6d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -221,7 +221,7 @@ jobs: runs-on: ubuntu-22.04 defaults: run: - shell: sh + shell: bash steps: - uses: actions/checkout@v4 - name: Run in netbsd @@ -237,6 +237,8 @@ jobs: ln -s /usr/local/go/bin/go /usr/local/bin run: | echo "Running tests on $(uname -a) at $PWD" + + export PATH=$PATH:/usr/local/bin # verify Go is available go version From 85a72ad55e063ff3a8308030ecb1ae39107d9bd0 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 11:15:23 -0400 Subject: [PATCH 30/59] remove some bash references --- .github/workflows/test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9b8d6d1..a5d27656 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -219,16 +219,12 @@ jobs: go: ['1.21.13', '1.22.6', '1.23.0'] name: Test with Go ${{ matrix.go }} on NetBSD runs-on: ubuntu-22.04 - defaults: - run: - shell: bash steps: - uses: actions/checkout@v4 - name: Run in netbsd uses: vmactions/netbsd-vm@v1 with: usesh: true - sync: no prepare: | /usr/sbin/pkg_add -v bash ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz @@ -238,7 +234,8 @@ jobs: run: | echo "Running tests on $(uname -a) at $PWD" - export PATH=$PATH:/usr/local/bin + export PATH=$PATH:/usr/local/go/bin/ + echo $PATH # verify Go is available go version From 7773c24ad617e0219dc6af004aa81081f3717a1c Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 11:20:01 -0400 Subject: [PATCH 31/59] go plugin not supported on netbsd --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5d27656..6fca1ac6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -265,10 +265,6 @@ jobs: env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - echo "=> go build (plugin)" - # Make sure that plugin buildmode works since we save the R15 register (#254) - go build -buildmode=plugin ./examples/libc - echo "=> go mod vendor" mkdir /tmp/vendoring cd /tmp/vendoring From 9ddd0665385805f4b47bc51b5cab866f220e5a39 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Tue, 15 Oct 2024 11:21:58 -0400 Subject: [PATCH 32/59] remove echo --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fca1ac6..b7287078 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -235,7 +235,6 @@ jobs: echo "Running tests on $(uname -a) at $PWD" export PATH=$PATH:/usr/local/go/bin/ - echo $PATH # verify Go is available go version From 2a940f5413d376fa8ef46f8c3df629ee929421a0 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 6 Mar 2025 16:17:42 -0500 Subject: [PATCH 33/59] No Cgo on NetBSD? --- README.md | 1 + dlerror.go | 2 +- dlfcn.go | 2 +- dlfcn_netbsd.go | 18 ----- dlfcn_nocgo_netbsd.go | 9 +++ dlfcn_stubs.s | 2 +- internal/fakecgo/callbacks.go | 2 +- internal/fakecgo/doc.go | 2 +- internal/fakecgo/gen.go | 9 ++- internal/fakecgo/go_libinit.go | 2 +- internal/fakecgo/go_netbsd_amd64.go | 95 +++++++++++++++++++++++++++ internal/fakecgo/go_netbsd_arm64.go | 98 ++++++++++++++++++++++++++++ internal/fakecgo/go_setenv.go | 2 +- internal/fakecgo/go_util.go | 2 +- internal/fakecgo/iscgo.go | 2 +- internal/fakecgo/libcgo.go | 2 +- internal/fakecgo/libcgo_netbsd.go | 16 +++++ internal/fakecgo/netbsd.go | 23 +++++++ internal/fakecgo/setenv.go | 2 +- internal/fakecgo/symbols.go | 2 +- internal/fakecgo/symbols_netbsd.go | 29 ++++++++ internal/fakecgo/trampolines_stubs.s | 2 +- nocgo.go | 2 +- sys_amd64.s | 2 +- sys_arm64.s | 2 +- sys_unix_arm64.s | 2 +- syscall_cgo_netbsd.go | 21 ------ syscall_sysv.go | 2 +- zcallback_amd64.s | 2 +- zcallback_arm64.s | 2 +- 30 files changed, 297 insertions(+), 62 deletions(-) create mode 100644 dlfcn_nocgo_netbsd.go create mode 100644 internal/fakecgo/go_netbsd_amd64.go create mode 100644 internal/fakecgo/go_netbsd_arm64.go create mode 100644 internal/fakecgo/libcgo_netbsd.go create mode 100644 internal/fakecgo/netbsd.go create mode 100644 internal/fakecgo/symbols_netbsd.go delete mode 100644 syscall_cgo_netbsd.go diff --git a/README.md b/README.md index f1ff9053..f4c93840 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ This is a list of the copied files: * `internal/fakecgo/iscgo.go` from package `runtime/cgo` * `internal/fakecgo/setenv.go` from package `runtime/cgo` * `internal/fakecgo/freebsd.go` from package `runtime/cgo` +* `internal/fakecgo/netbsd.go` from package `runtime/cgo` The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of `#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636)) diff --git a/dlerror.go b/dlerror.go index 95cdfe16..ad52b436 100644 --- a/dlerror.go +++ b/dlerror.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd package purego diff --git a/dlfcn.go b/dlfcn.go index f70a2458..54110943 100644 --- a/dlfcn.go +++ b/dlfcn.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build (darwin || freebsd || linux) && !android && !faketime +//go:build (darwin || freebsd || linux || netbsd) && !android && !faketime package purego diff --git a/dlfcn_netbsd.go b/dlfcn_netbsd.go index ddb95e07..8aa4763d 100644 --- a/dlfcn_netbsd.go +++ b/dlfcn_netbsd.go @@ -3,8 +3,6 @@ package purego -import "github.com/ebitengine/purego/internal/cgo" - // Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h const ( @@ -15,19 +13,3 @@ const ( RTLD_LOCAL = 0x00000000 // All symbols are not made available for relocation processing by other modules. RTLD_GLOBAL = 0x00000100 // All symbols are available for relocation processing of other modules. ) - -func Dlopen(path string, mode int) (uintptr, error) { - return cgo.Dlopen(path, mode) -} - -func Dlsym(handle uintptr, name string) (uintptr, error) { - return cgo.Dlsym(handle, name) -} - -func Dlclose(handle uintptr) error { - return cgo.Dlclose(handle) -} - -func loadSymbol(handle uintptr, name string) (uintptr, error) { - return Dlsym(handle, name) -} diff --git a/dlfcn_nocgo_netbsd.go b/dlfcn_nocgo_netbsd.go new file mode 100644 index 00000000..468f4841 --- /dev/null +++ b/dlfcn_nocgo_netbsd.go @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2025 The Ebitengine Authors + +package purego + +//go:cgo_import_dynamic purego_dlopen dlopen "libc.so" +//go:cgo_import_dynamic purego_dlsym dlsym "libc.so" +//go:cgo_import_dynamic purego_dlerror dlerror "libc.so" +//go:cgo_import_dynamic purego_dlclose dlclose "libc.so" diff --git a/dlfcn_stubs.s b/dlfcn_stubs.s index 4befc589..9801e2dc 100644 --- a/dlfcn_stubs.s +++ b/dlfcn_stubs.s @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || !cgo && (freebsd || linux) && !faketime +//go:build darwin || !cgo && (freebsd || linux || netbsd) && !faketime #include "textflag.h" diff --git a/internal/fakecgo/callbacks.go b/internal/fakecgo/callbacks.go index f29e690c..27d4c98c 100644 --- a/internal/fakecgo/callbacks.go +++ b/internal/fakecgo/callbacks.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/doc.go b/internal/fakecgo/doc.go index be82f7df..e482c120 100644 --- a/internal/fakecgo/doc.go +++ b/internal/fakecgo/doc.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go. // This allows code that calls into C to function properly when CGO_ENABLED=0. diff --git a/internal/fakecgo/gen.go b/internal/fakecgo/gen.go index 74c316f8..6d2ed98c 100644 --- a/internal/fakecgo/gen.go +++ b/internal/fakecgo/gen.go @@ -20,7 +20,7 @@ const templateSymbols = `// Code generated by 'go generate' with gen.go. DO NOT // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo @@ -85,7 +85,7 @@ const templateTrampolinesStubs = `// Code generated by 'go generate' with gen.go // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) #include "textflag.h" @@ -198,7 +198,7 @@ func run() error { if err != nil { return err } - for _, goos := range []string{"darwin", "linux", "freebsd"} { + for _, goos := range []string{"darwin", "freebsd", "linux", "netbsd"} { f, err = os.Create(fmt.Sprintf("symbols_%s.go", goos)) defer f.Close() if err != nil { @@ -216,6 +216,9 @@ func run() error { case "linux": libcSO = "libc.so.6" pthreadSO = "libpthread.so.0" + case "netbsd": + libcSO = "libc.so" + pthreadSO = "libpthread.so" default: return fmt.Errorf("unsupported OS: %s", goos) } diff --git a/internal/fakecgo/go_libinit.go b/internal/fakecgo/go_libinit.go index e5cb46be..8e5d2af7 100644 --- a/internal/fakecgo/go_libinit.go +++ b/internal/fakecgo/go_libinit.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/go_netbsd_amd64.go b/internal/fakecgo/go_netbsd_amd64.go new file mode 100644 index 00000000..cc487f61 --- /dev/null +++ b/internal/fakecgo/go_netbsd_amd64.go @@ -0,0 +1,95 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + 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 = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))` + // but this should be OK since we are taking the address of the first variable in this function. + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/internal/fakecgo/go_netbsd_arm64.go b/internal/fakecgo/go_netbsd_arm64.go new file mode 100644 index 00000000..e3a060b9 --- /dev/null +++ b/internal/fakecgo/go_netbsd_arm64.go @@ -0,0 +1,98 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo + +package fakecgo + +import "unsafe" + +//go:nosplit +func _cgo_sys_thread_start(ts *ThreadStart) { + var attr pthread_attr_t + var ign, oset sigset_t + var p pthread_t + var size size_t + var err int + + // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug + 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 = uintptr(size) + + err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) + + pthread_sigmask(SIG_SETMASK, &oset, nil) + + if err != 0 { + print("fakecgo: pthread_create failed: ") + println(err) + abort() + } +} + +// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function +// +//go:linkname x_threadentry_trampoline threadentry_trampoline +var x_threadentry_trampoline byte +var threadentry_trampolineABI0 = &x_threadentry_trampoline + +//go:nosplit +func threadentry(v unsafe.Pointer) unsafe.Pointer { + ts := *(*ThreadStart)(v) + free(v) + + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) + + // faking funcs in go is a bit a... involved - but the following works :) + fn := uintptr(unsafe.Pointer(&ts.fn)) + (*(*func())(unsafe.Pointer(&fn)))() + + return nil +} + +// here we will store a pointer to the provided setg func +var setg_func uintptr + +// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) +// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us +// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup +// This function can't be go:systemstack since go is not in a state where the systemcheck would work. +// +//go:nosplit +func x_cgo_init(g *G, setg uintptr) { + var size size_t + var attr *pthread_attr_t + + /* The memory sanitizer distributed with versions of clang + before 3.8 has a bug: if you call mmap before malloc, mmap + may return an address that is later overwritten by the msan + library. Avoid this problem by forcing a call to malloc + here, before we ever call malloc. + + This is only required for the memory sanitizer, so it's + unfortunate that we always run it. It should be possible + to remove this when we no longer care about versions of + clang before 3.8. The test for this is + misc/cgo/testsanitizers. + + GCC works hard to eliminate a seemingly unnecessary call to + malloc, so we actually use the memory we allocate. */ + + setg_func = setg + attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) + if attr == nil { + println("fakecgo: malloc failed") + abort() + } + pthread_attr_init(attr) + pthread_attr_getstacksize(attr, &size) + g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 + pthread_attr_destroy(attr) + free(unsafe.Pointer(attr)) +} diff --git a/internal/fakecgo/go_setenv.go b/internal/fakecgo/go_setenv.go index e42d84f0..dfc6629e 100644 --- a/internal/fakecgo/go_setenv.go +++ b/internal/fakecgo/go_setenv.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/go_util.go b/internal/fakecgo/go_util.go index 0ac10d1f..771cb525 100644 --- a/internal/fakecgo/go_util.go +++ b/internal/fakecgo/go_util.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/iscgo.go b/internal/fakecgo/iscgo.go index 28af41cc..12e52147 100644 --- a/internal/fakecgo/iscgo.go +++ b/internal/fakecgo/iscgo.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) // The runtime package contains an uninitialized definition // for runtime·iscgo. Override it to tell the runtime we're here. diff --git a/internal/fakecgo/libcgo.go b/internal/fakecgo/libcgo.go index 74626c64..696a7120 100644 --- a/internal/fakecgo/libcgo.go +++ b/internal/fakecgo/libcgo.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/libcgo_netbsd.go b/internal/fakecgo/libcgo_netbsd.go new file mode 100644 index 00000000..ca1f722c --- /dev/null +++ b/internal/fakecgo/libcgo_netbsd.go @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +type ( + pthread_cond_t uintptr + pthread_mutex_t uintptr +) + +var ( + PTHREAD_COND_INITIALIZER = pthread_cond_t(0) + PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) +) diff --git a/internal/fakecgo/netbsd.go b/internal/fakecgo/netbsd.go new file mode 100644 index 00000000..2d499814 --- /dev/null +++ b/internal/fakecgo/netbsd.go @@ -0,0 +1,23 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build netbsd + +package fakecgo + +import _ "unsafe" // for go:linkname + +// Supply environ and __progname, because we don't +// link against the standard NetBSD crt0.o and the +// libc dynamic library needs them. + +//go:linkname _environ environ +//go:linkname _progname __progname +//go:linkname ___ps_strings __ps_strings + +var ( + _environ uintptr + _progname uintptr + ___ps_strings uintptr +) diff --git a/internal/fakecgo/setenv.go b/internal/fakecgo/setenv.go index f30af0e1..82308b8c 100644 --- a/internal/fakecgo/setenv.go +++ b/internal/fakecgo/setenv.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/symbols.go b/internal/fakecgo/symbols.go index 3d19fd82..a813188b 100644 --- a/internal/fakecgo/symbols.go +++ b/internal/fakecgo/symbols.go @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package fakecgo diff --git a/internal/fakecgo/symbols_netbsd.go b/internal/fakecgo/symbols_netbsd.go new file mode 100644 index 00000000..a2205b73 --- /dev/null +++ b/internal/fakecgo/symbols_netbsd.go @@ -0,0 +1,29 @@ +// Code generated by 'go generate' with gen.go. DO NOT EDIT. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 The Ebitengine Authors + +//go:build !cgo + +package fakecgo + +//go:cgo_import_dynamic purego_malloc malloc "libc.so" +//go:cgo_import_dynamic purego_free free "libc.so" +//go:cgo_import_dynamic purego_setenv setenv "libc.so" +//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so" +//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so" +//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so" +//go:cgo_import_dynamic purego_abort abort "libc.so" +//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" +//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" +//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" +//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so" +//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so" +//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so" +//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so" +//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so" +//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so" +//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so" +//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so" diff --git a/internal/fakecgo/trampolines_stubs.s b/internal/fakecgo/trampolines_stubs.s index a65b2012..05a0dfb0 100644 --- a/internal/fakecgo/trampolines_stubs.s +++ b/internal/fakecgo/trampolines_stubs.s @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) #include "textflag.h" diff --git a/nocgo.go b/nocgo.go index 5b989ea8..b91b9796 100644 --- a/nocgo.go +++ b/nocgo.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build !cgo && (darwin || freebsd || linux) +//go:build !cgo && (darwin || freebsd || linux || netbsd) package purego diff --git a/sys_amd64.s b/sys_amd64.s index cabde1a5..a364dd0c 100644 --- a/sys_amd64.s +++ b/sys_amd64.s @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd #include "textflag.h" #include "abi_amd64.h" diff --git a/sys_arm64.s b/sys_arm64.s index a68fdb99..a4f5be72 100644 --- a/sys_arm64.s +++ b/sys_arm64.s @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux || windows +//go:build darwin || freebsd || linux || netbsd || windows #include "textflag.h" #include "go_asm.h" diff --git a/sys_unix_arm64.s b/sys_unix_arm64.s index 6da06b4d..cea803ef 100644 --- a/sys_unix_arm64.s +++ b/sys_unix_arm64.s @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd #include "textflag.h" #include "go_asm.h" diff --git a/syscall_cgo_netbsd.go b/syscall_cgo_netbsd.go deleted file mode 100644 index c964864d..00000000 --- a/syscall_cgo_netbsd.go +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors - -//go:build cgo - -package purego - -import ( - "github.com/ebitengine/purego/internal/cgo" -) - -var syscall15XABI0 = uintptr(cgo.Syscall15XABI0) - -//go:nosplit -func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { - return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) -} - -func NewCallback(_ interface{}) uintptr { - panic("purego: NewCallback is not supported on NetBSD") -} diff --git a/syscall_sysv.go b/syscall_sysv.go index cce171c8..8b546b5e 100644 --- a/syscall_sysv.go +++ b/syscall_sysv.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || (linux && (amd64 || arm64)) +//go:build darwin || freebsd || (linux && (amd64 || arm64)) || netbsd package purego diff --git a/zcallback_amd64.s b/zcallback_amd64.s index 6a778bfc..b2da0225 100644 --- a/zcallback_amd64.s +++ b/zcallback_amd64.s @@ -1,6 +1,6 @@ // Code generated by wincallback.go using 'go generate'. DO NOT EDIT. -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not diff --git a/zcallback_arm64.s b/zcallback_arm64.s index c079b803..3fea4af8 100644 --- a/zcallback_arm64.s +++ b/zcallback_arm64.s @@ -1,6 +1,6 @@ // Code generated by wincallback.go using 'go generate'. DO NOT EDIT. -//go:build darwin || freebsd || linux +//go:build darwin || freebsd || linux || netbsd // External code calls into callbackasm at an offset corresponding // to the callback index. Callbackasm is a table of MOV and B instructions. From daa834cec009a832c7a2a6f2bbbf4ee6f5401440 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 6 Mar 2025 16:24:49 -0500 Subject: [PATCH 34/59] add netbsd to build tag in examples/libc --- examples/libc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/libc/main.go b/examples/libc/main.go index f66d57e8..337c8b39 100644 --- a/examples/libc/main.go +++ b/examples/libc/main.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build darwin || freebsd || linux || windows +//go:build darwin || freebsd || linux || netbsd || windows package main From 2a19c6e100e6e5b8e2c7dab45206e14cfe3af0d9 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 6 Mar 2025 16:30:10 -0500 Subject: [PATCH 35/59] update pipeline --- .github/workflows/test.yml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9169ed80..63d1496a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,7 +65,11 @@ jobs: # gcflags -std is necessary to make fakecgo the Cgo for # FreeBSD to add the symbols that libc.so depends on. env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + # Check cross-compiling NetBSD binaries. + env GOOS=netbsd GOARCH=amd64 go build -v ./... + env GOOS=netbsd GOARCH=arm64 go build -v ./... - name: go build (plugin) if: runner.os == 'Linux' || runner.os == 'macOS' @@ -188,6 +192,10 @@ jobs: # Check cross-compiling FreeBSD binaries. env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + # Check cross-compiling NetBSD binaries. + env GOOS=netbsd GOARCH=amd64 go build -v ./... + env GOOS=netbsd GOARCH=arm64 go build -v ./... echo "=> go build (plugin)" # Make sure that plugin buildmode works since we save the R15 register (#254) @@ -227,7 +235,7 @@ jobs: netbsd: strategy: matrix: - go: ['1.21.13', '1.22.6', '1.23.0'] + go: ['1.21.13', '1.22.12', '1.23.6', '1.24.0'] name: Test with Go ${{ matrix.go }} on NetBSD runs-on: ubuntu-22.04 steps: @@ -274,6 +282,10 @@ jobs: # Check cross-compiling FreeBSD binaries. env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + # Check cross-compiling NetBSD binaries. + env GOOS=netbsd GOARCH=amd64 go build -v ./... + env GOOS=netbsd GOARCH=arm64 go build -v ./... echo "=> go mod vendor" mkdir /tmp/vendoring @@ -289,10 +301,9 @@ jobs: go mod vendor go build -v . - # TODO: uncomment once Cgo is not required for NetBSD - # cd $GITHUB_WORKSPACE - # echo "=> go test CGO_ENABLED=0" - # env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... + cd $GITHUB_WORKSPACE + echo "=> go test CGO_ENABLED=0" + env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./... echo "=> go test CGO_ENABLED=1" env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... From e7e52fe11647cffd7dfea946cd8f6cb041168942 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 6 Mar 2025 16:30:16 -0500 Subject: [PATCH 36/59] enable tests --- func_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/func_test.go b/func_test.go index 048eebb3..2a441625 100644 --- a/func_test.go +++ b/func_test.go @@ -45,7 +45,7 @@ func TestRegisterFunc(t *testing.T) { } func Test_qsort(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { t.Skip("Platform doesn't support Floats") return } @@ -74,7 +74,7 @@ func Test_qsort(t *testing.T) { } func TestRegisterFunc_Floats(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { t.Skip("Platform doesn't support Floats") return } @@ -113,7 +113,7 @@ func TestRegisterFunc_Floats(t *testing.T) { } func TestRegisterLibFunc_Bool(t *testing.T) { - if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" || runtime.GOOS == "netbsd" { + if runtime.GOARCH != "arm64" && runtime.GOARCH != "amd64" { t.Skip("Platform doesn't support callbacks") return } From 19cebb47d3d728303ea64553f525a4f1681c9a92 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 08:20:03 -0500 Subject: [PATCH 37/59] make code more in line with runtime/cgo --- internal/fakecgo/gen.go | 1 + .../{go_netbsd_amd64.go => go_netbsd.go} | 13 ++- internal/fakecgo/go_netbsd_arm64.go | 98 ------------------- internal/fakecgo/libcgo_darwin.go | 4 + internal/fakecgo/libcgo_freebsd.go | 4 + internal/fakecgo/libcgo_linux.go | 4 + internal/fakecgo/libcgo_netbsd.go | 10 ++ internal/fakecgo/symbols.go | 9 ++ internal/fakecgo/symbols_darwin.go | 1 + internal/fakecgo/symbols_freebsd.go | 1 + internal/fakecgo/symbols_linux.go | 1 + internal/fakecgo/symbols_netbsd.go | 1 + internal/fakecgo/trampolines_stubs.s | 4 + 13 files changed, 52 insertions(+), 99 deletions(-) rename internal/fakecgo/{go_netbsd_amd64.go => go_netbsd.go} (85%) delete mode 100644 internal/fakecgo/go_netbsd_arm64.go diff --git a/internal/fakecgo/gen.go b/internal/fakecgo/gen.go index 146f51da..cd5aa264 100644 --- a/internal/fakecgo/gen.go +++ b/internal/fakecgo/gen.go @@ -139,6 +139,7 @@ var ( {"sigfillset", [5]Arg{{"set", "*sigset_t"}}, "int32"}, {"nanosleep", [5]Arg{{"ts", "*syscall.Timespec"}, {"rem", "*syscall.Timespec"}}, "int32"}, {"abort", [5]Arg{}, ""}, + {"sigaltstack", [5]Arg{{"ss", "*stack_t"}, {"old_ss", "*stack_t"}}, "int32"}, } pthreadSymbols = []Symbol{ {"pthread_attr_init", [5]Arg{{"attr", "*pthread_attr_t"}}, "int32"}, diff --git a/internal/fakecgo/go_netbsd_amd64.go b/internal/fakecgo/go_netbsd.go similarity index 85% rename from internal/fakecgo/go_netbsd_amd64.go rename to internal/fakecgo/go_netbsd.go index cc487f61..935a334f 100644 --- a/internal/fakecgo/go_netbsd_amd64.go +++ b/internal/fakecgo/go_netbsd.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !cgo +//go:build !cgo && (amd64 || arm64) package fakecgo @@ -44,9 +44,20 @@ var threadentry_trampolineABI0 = &x_threadentry_trampoline //go:nosplit func threadentry(v unsafe.Pointer) unsafe.Pointer { + var ss stack_t ts := *(*ThreadStart)(v) free(v) + // On NetBSD, a new thread inherits the signal stack of the + // creating thread. That confuses minit, so we remove that + // signal stack here before calling the regular mstart. It's + // a bit baroque to remove a signal stack here only to add one + // in minit, but it's a simple change that keeps NetBSD + // working like other OS's. At this point all signals are + // blocked, so there is no race. + ss.ss_flags = SS_DISABLE + sigaltstack(&ss, nil) + setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) // faking funcs in go is a bit a... involved - but the following works :) diff --git a/internal/fakecgo/go_netbsd_arm64.go b/internal/fakecgo/go_netbsd_arm64.go deleted file mode 100644 index e3a060b9..00000000 --- a/internal/fakecgo/go_netbsd_arm64.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cgo - -package fakecgo - -import "unsafe" - -//go:nosplit -func _cgo_sys_thread_start(ts *ThreadStart) { - var attr pthread_attr_t - var ign, oset sigset_t - var p pthread_t - var size size_t - var err int - - // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug - 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 = uintptr(size) - - err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts) - - pthread_sigmask(SIG_SETMASK, &oset, nil) - - if err != 0 { - print("fakecgo: pthread_create failed: ") - println(err) - abort() - } -} - -// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function -// -//go:linkname x_threadentry_trampoline threadentry_trampoline -var x_threadentry_trampoline byte -var threadentry_trampolineABI0 = &x_threadentry_trampoline - -//go:nosplit -func threadentry(v unsafe.Pointer) unsafe.Pointer { - ts := *(*ThreadStart)(v) - free(v) - - setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g))) - - // faking funcs in go is a bit a... involved - but the following works :) - fn := uintptr(unsafe.Pointer(&ts.fn)) - (*(*func())(unsafe.Pointer(&fn)))() - - return nil -} - -// here we will store a pointer to the provided setg func -var setg_func uintptr - -// x_cgo_init(G *g, void (*setg)(void*)) (runtime/cgo/gcc_linux_amd64.c) -// This get's called during startup, adjusts stacklo, and provides a pointer to setg_gcc for us -// Additionally, if we set _cgo_init to non-null, go won't do it's own TLS setup -// This function can't be go:systemstack since go is not in a state where the systemcheck would work. -// -//go:nosplit -func x_cgo_init(g *G, setg uintptr) { - var size size_t - var attr *pthread_attr_t - - /* The memory sanitizer distributed with versions of clang - before 3.8 has a bug: if you call mmap before malloc, mmap - may return an address that is later overwritten by the msan - library. Avoid this problem by forcing a call to malloc - here, before we ever call malloc. - - This is only required for the memory sanitizer, so it's - unfortunate that we always run it. It should be possible - to remove this when we no longer care about versions of - clang before 3.8. The test for this is - misc/cgo/testsanitizers. - - GCC works hard to eliminate a seemingly unnecessary call to - malloc, so we actually use the memory we allocate. */ - - setg_func = setg - attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr))) - if attr == nil { - println("fakecgo: malloc failed") - abort() - } - pthread_attr_init(attr) - pthread_attr_getstacksize(attr, &size) - g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096 - pthread_attr_destroy(attr) - free(unsafe.Pointer(attr)) -} diff --git a/internal/fakecgo/libcgo_darwin.go b/internal/fakecgo/libcgo_darwin.go index af148333..ecdcb2e7 100644 --- a/internal/fakecgo/libcgo_darwin.go +++ b/internal/fakecgo/libcgo_darwin.go @@ -20,3 +20,7 @@ var ( PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB} PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7} ) + +type stack_t struct { + /* not implemented */ +} diff --git a/internal/fakecgo/libcgo_freebsd.go b/internal/fakecgo/libcgo_freebsd.go index ca1f722c..4bfb70c3 100644 --- a/internal/fakecgo/libcgo_freebsd.go +++ b/internal/fakecgo/libcgo_freebsd.go @@ -14,3 +14,7 @@ var ( PTHREAD_COND_INITIALIZER = pthread_cond_t(0) PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) ) + +type stack_t struct { + /* not implemented */ +} diff --git a/internal/fakecgo/libcgo_linux.go b/internal/fakecgo/libcgo_linux.go index c4b6e9ea..b08a44a1 100644 --- a/internal/fakecgo/libcgo_linux.go +++ b/internal/fakecgo/libcgo_linux.go @@ -14,3 +14,7 @@ var ( PTHREAD_COND_INITIALIZER = pthread_cond_t{} PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{} ) + +type stack_t struct { + /* not implemented */ +} diff --git a/internal/fakecgo/libcgo_netbsd.go b/internal/fakecgo/libcgo_netbsd.go index ca1f722c..d3f31dee 100644 --- a/internal/fakecgo/libcgo_netbsd.go +++ b/internal/fakecgo/libcgo_netbsd.go @@ -14,3 +14,13 @@ var ( PTHREAD_COND_INITIALIZER = pthread_cond_t(0) PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) ) + +// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/compat/linux/arch/m68k/linux_signal.h#L133 +type stack_t struct { + ss_sp uintptr + ss_flags int32 + ss_size uintptr +} + +// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261 +const SS_DISABLE = 0x004 diff --git a/internal/fakecgo/symbols.go b/internal/fakecgo/symbols.go index 3a3f35da..508497c5 100644 --- a/internal/fakecgo/symbols.go +++ b/internal/fakecgo/symbols.go @@ -55,6 +55,11 @@ func abort() { call5(abortABI0, 0, 0, 0, 0, 0) } +//go:nosplit +func sigaltstack(ss *stack_t, old_ss *stack_t) int32 { + return int32(call5(sigaltstackABI0, uintptr(unsafe.Pointer(ss)), uintptr(unsafe.Pointer(old_ss)), 0, 0, 0)) +} + //go:nosplit func pthread_attr_init(attr *pthread_attr_t) int32 { return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0)) @@ -148,6 +153,10 @@ var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep)) var _abort uintptr var abortABI0 = uintptr(unsafe.Pointer(&_abort)) +//go:linkname _sigaltstack _sigaltstack +var _sigaltstack uintptr +var sigaltstackABI0 = uintptr(unsafe.Pointer(&_sigaltstack)) + //go:linkname _pthread_attr_init _pthread_attr_init var _pthread_attr_init uintptr var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init)) diff --git a/internal/fakecgo/symbols_darwin.go b/internal/fakecgo/symbols_darwin.go index 54aaa462..8c4489f0 100644 --- a/internal/fakecgo/symbols_darwin.go +++ b/internal/fakecgo/symbols_darwin.go @@ -14,6 +14,7 @@ package fakecgo //go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic purego_sigaltstack sigaltstack "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib" diff --git a/internal/fakecgo/symbols_freebsd.go b/internal/fakecgo/symbols_freebsd.go index 81538119..bbe1bd57 100644 --- a/internal/fakecgo/symbols_freebsd.go +++ b/internal/fakecgo/symbols_freebsd.go @@ -14,6 +14,7 @@ package fakecgo //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7" //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7" //go:cgo_import_dynamic purego_abort abort "libc.so.7" +//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.7" //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" diff --git a/internal/fakecgo/symbols_linux.go b/internal/fakecgo/symbols_linux.go index 180057d0..21652650 100644 --- a/internal/fakecgo/symbols_linux.go +++ b/internal/fakecgo/symbols_linux.go @@ -14,6 +14,7 @@ package fakecgo //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6" //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6" //go:cgo_import_dynamic purego_abort abort "libc.so.6" +//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.6" //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0" //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0" //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0" diff --git a/internal/fakecgo/symbols_netbsd.go b/internal/fakecgo/symbols_netbsd.go index a2205b73..7c92bb0b 100644 --- a/internal/fakecgo/symbols_netbsd.go +++ b/internal/fakecgo/symbols_netbsd.go @@ -14,6 +14,7 @@ package fakecgo //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so" //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so" //go:cgo_import_dynamic purego_abort abort "libc.so" +//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so" //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so" //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so" //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so" diff --git a/internal/fakecgo/trampolines_stubs.s b/internal/fakecgo/trampolines_stubs.s index 05a0dfb0..c93d783d 100644 --- a/internal/fakecgo/trampolines_stubs.s +++ b/internal/fakecgo/trampolines_stubs.s @@ -37,6 +37,10 @@ TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0 JMP purego_abort(SB) RET +TEXT _sigaltstack(SB), NOSPLIT|NOFRAME, $0-0 + JMP purego_sigaltstack(SB) + RET + TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0 JMP purego_pthread_attr_init(SB) RET From 7d59f3932e80d6f9a6d9ce05e78cd1d3c472fe1c Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 08:26:03 -0500 Subject: [PATCH 38/59] use -fPIC on all platforms --- dlfcn_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dlfcn_test.go b/dlfcn_test.go index 02e9a243..6eadc095 100644 --- a/dlfcn_test.go +++ b/dlfcn_test.go @@ -53,12 +53,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { return errors.New("compiler not found") } - var args []string - if runtime.GOOS == "freebsd" || runtime.GOOS == "netbsd" { - args = []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile} - } else { - args = []string{"-shared", "-Wall", "-Werror", "-o", libFile} - } + args := []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile} if runtime.GOARCH == "386" { args = append(args, "-m32") } From bc9050fe0627b84b9541dd33d0cf54a723aa67b0 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 08:49:20 -0500 Subject: [PATCH 39/59] build tags and copyright years --- cgo.go | 2 +- dlfcn_netbsd.go | 2 +- internal/fakecgo/libcgo_netbsd.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cgo.go b/cgo.go index 31dc8f19..32bb256a 100644 --- a/cgo.go +++ b/cgo.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors -//go:build cgo && (darwin || freebsd || netbsd || linux) +//go:build cgo && (darwin || freebsd || linux || netbsd) package purego diff --git a/dlfcn_netbsd.go b/dlfcn_netbsd.go index 8aa4763d..220c7367 100644 --- a/dlfcn_netbsd.go +++ b/dlfcn_netbsd.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2024 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025 The Ebitengine Authors package purego diff --git a/internal/fakecgo/libcgo_netbsd.go b/internal/fakecgo/libcgo_netbsd.go index d3f31dee..650f6953 100644 --- a/internal/fakecgo/libcgo_netbsd.go +++ b/internal/fakecgo/libcgo_netbsd.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 The Ebitengine Authors +// SPDX-FileCopyrightText: 2025 The Ebitengine Authors //go:build !cgo From 3e44d74d9112d0b38c16956e599be1e2ed240a36 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 09:43:50 -0500 Subject: [PATCH 40/59] try merging freebsd and netbsd --- .github/workflows/test.yml | 229 ++++++++++++++----------------------- 1 file changed, 83 insertions(+), 146 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 63d1496a..8e8dedf6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -138,18 +138,96 @@ jobs: run: | go test -race -shuffle=on -v -count=10 ./... - freebsd: + bsd: strategy: matrix: + os: ['FreeBSD', 'NetBSD'] go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.6', '1.24.0'] - name: Test with Go ${{ matrix.go }} on FreeBSD + name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} runs-on: ubuntu-22.04 defaults: run: shell: bash steps: + - &shared_run + run: | + # FreeBSD & NetBSD tests run within QEMU on Ubuntu. + # vmactions/freebsd-vm only supports a single "step" where it + # brings down the VM at the end of the step, so all + # the commands to run need to be put into this single block. + + echo "Running tests on $(uname -a) at $PWD" + + # verify Go is available + go version + + echo "=> go build" + go build -v ./... + # Compile without optimization to check potential stack overflow. + # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. + # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. + go build "-gcflags=all=-N -l" -v ./... + + # Check cross-compiling Windows binaries. + env GOOS=windows GOARCH=386 go build -v ./... + env GOOS=windows GOARCH=amd64 go build -v ./... + env GOOS=windows GOARCH=arm go build -v ./... + env GOOS=windows GOARCH=arm64 go build -v ./... + + # Check cross-compiling macOS binaries. + env GOOS=darwin GOARCH=amd64 go build -v ./... + env GOOS=darwin GOARCH=arm64 go build -v ./... + + # Check cross-compiling Linux binaries. + env GOOS=linux GOARCH=amd64 go build -v ./... + env GOOS=linux GOARCH=arm64 go build -v ./... + + # Check cross-compiling FreeBSD binaries. + env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + # Check cross-compiling NetBSD binaries. + env GOOS=netbsd GOARCH=amd64 go build -v ./... + env GOOS=netbsd GOARCH=arm64 go build -v ./... + + echo "=> go build (plugin)" + # Make sure that plugin buildmode works since we save the R15 register (#254) + go build -buildmode=plugin ./examples/libc + + echo "=> go mod vendor" + mkdir /tmp/vendoring + cd /tmp/vendoring + go mod init foo + echo 'package main' > main.go + echo 'import (' >> main.go + echo ' _ "github.com/ebitengine/purego"' >> main.go + echo ')' >> main.go + echo 'func main() {}' >> main.go + go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE + go mod tidy + go mod vendor + go build -v . + + cd $GITHUB_WORKSPACE + echo "=> go test CGO_ENABLED=0" + env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... + + echo "=> go test CGO_ENABLED=1" + env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... + + echo "=> go test CGO_ENABLED=0 w/o optimization" + env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... + + echo "=> go test CGO_ENABLED=1 w/o optimization" + env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... + + if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then + echo "=> go test race" + go test -race -shuffle=on -v -count=10 ./... + fi - uses: actions/checkout@v4 - name: Run in freebsd + if: matrix.os == 'FreeBSD' uses: vmactions/freebsd-vm@v1 with: usesh: true @@ -157,90 +235,9 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - run: | - # FreeBSD tests run within QEMU on Ubuntu. - # vmactions/freebsd-vm only supports a single "step" where it - # brings down the VM at the end of the step, so all - # the commands to run need to be put into this single block. - - echo "Running tests on $(uname -a) at $PWD" - - # verify Go is available - go version - - echo "=> go build" - go build -v ./... - # Compile without optimization to check potential stack overflow. - # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. - # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. - go build "-gcflags=all=-N -l" -v ./... - - # Check cross-compiling Windows binaries. - env GOOS=windows GOARCH=386 go build -v ./... - env GOOS=windows GOARCH=amd64 go build -v ./... - env GOOS=windows GOARCH=arm go build -v ./... - env GOOS=windows GOARCH=arm64 go build -v ./... - - # Check cross-compiling macOS binaries. - env GOOS=darwin GOARCH=amd64 go build -v ./... - env GOOS=darwin GOARCH=arm64 go build -v ./... - - # Check cross-compiling Linux binaries. - env GOOS=linux GOARCH=amd64 go build -v ./... - env GOOS=linux GOARCH=arm64 go build -v ./... - - # Check cross-compiling FreeBSD binaries. - env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - - # Check cross-compiling NetBSD binaries. - env GOOS=netbsd GOARCH=amd64 go build -v ./... - env GOOS=netbsd GOARCH=arm64 go build -v ./... - - echo "=> go build (plugin)" - # Make sure that plugin buildmode works since we save the R15 register (#254) - go build -buildmode=plugin ./examples/libc - - echo "=> go mod vendor" - mkdir /tmp/vendoring - cd /tmp/vendoring - go mod init foo - echo 'package main' > main.go - echo 'import (' >> main.go - echo ' _ "github.com/ebitengine/purego"' >> main.go - echo ')' >> main.go - echo 'func main() {}' >> main.go - go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE - go mod tidy - go mod vendor - go build -v . - - cd $GITHUB_WORKSPACE - echo "=> go test CGO_ENABLED=0" - env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=1" - env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=0 w/o optimization" - env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... - - echo "=> go test CGO_ENABLED=1 w/o optimization" - env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... - - if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then - echo "=> go test race" - go test -race -shuffle=on -v -count=10 ./... - fi - netbsd: - strategy: - matrix: - go: ['1.21.13', '1.22.12', '1.23.6', '1.24.0'] - name: Test with Go ${{ matrix.go }} on NetBSD - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 + <<: *shared_run - name: Run in netbsd + if: matrix.os == 'NetBSD' uses: vmactions/netbsd-vm@v1 with: usesh: true @@ -250,65 +247,5 @@ jobs: mkdir /usr/local rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - run: | - echo "Running tests on $(uname -a) at $PWD" - export PATH=$PATH:/usr/local/go/bin/ - - # verify Go is available - go version - - echo "=> go build" - go build -v ./... - # Compile without optimization to check potential stack overflow. - # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. - # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. - go build "-gcflags=all=-N -l" -v ./... - - # Check cross-compiling Windows binaries. - env GOOS=windows GOARCH=386 go build -v ./... - env GOOS=windows GOARCH=amd64 go build -v ./... - env GOOS=windows GOARCH=arm go build -v ./... - env GOOS=windows GOARCH=arm64 go build -v ./... - - # Check cross-compiling macOS binaries. - env GOOS=darwin GOARCH=amd64 go build -v ./... - env GOOS=darwin GOARCH=arm64 go build -v ./... - - # Check cross-compiling Linux binaries. - env GOOS=linux GOARCH=amd64 go build -v ./... - env GOOS=linux GOARCH=arm64 go build -v ./... - - # Check cross-compiling FreeBSD binaries. - env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - - # Check cross-compiling NetBSD binaries. - env GOOS=netbsd GOARCH=amd64 go build -v ./... - env GOOS=netbsd GOARCH=arm64 go build -v ./... - - echo "=> go mod vendor" - mkdir /tmp/vendoring - cd /tmp/vendoring - go mod init foo - echo 'package main' > main.go - echo 'import (' >> main.go - echo ' _ "github.com/ebitengine/purego"' >> main.go - echo ')' >> main.go - echo 'func main() {}' >> main.go - go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE - go mod tidy - go mod vendor - go build -v . - - cd $GITHUB_WORKSPACE - echo "=> go test CGO_ENABLED=0" - env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=1" - env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... - - if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then - echo "=> go test race" - go test -race -shuffle=on -v -count=10 ./... - fi + <<: *shared_run From d1cfb861d08b2fc1086ffcd62171056e0d55a45e Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 09:53:07 -0500 Subject: [PATCH 41/59] another attempt at merging workflow --- .github/workflows/test.yml | 154 ++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 78 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e8dedf6..6396f280 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -149,82 +149,6 @@ jobs: run: shell: bash steps: - - &shared_run - run: | - # FreeBSD & NetBSD tests run within QEMU on Ubuntu. - # vmactions/freebsd-vm only supports a single "step" where it - # brings down the VM at the end of the step, so all - # the commands to run need to be put into this single block. - - echo "Running tests on $(uname -a) at $PWD" - - # verify Go is available - go version - - echo "=> go build" - go build -v ./... - # Compile without optimization to check potential stack overflow. - # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. - # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. - go build "-gcflags=all=-N -l" -v ./... - - # Check cross-compiling Windows binaries. - env GOOS=windows GOARCH=386 go build -v ./... - env GOOS=windows GOARCH=amd64 go build -v ./... - env GOOS=windows GOARCH=arm go build -v ./... - env GOOS=windows GOARCH=arm64 go build -v ./... - - # Check cross-compiling macOS binaries. - env GOOS=darwin GOARCH=amd64 go build -v ./... - env GOOS=darwin GOARCH=arm64 go build -v ./... - - # Check cross-compiling Linux binaries. - env GOOS=linux GOARCH=amd64 go build -v ./... - env GOOS=linux GOARCH=arm64 go build -v ./... - - # Check cross-compiling FreeBSD binaries. - env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - - # Check cross-compiling NetBSD binaries. - env GOOS=netbsd GOARCH=amd64 go build -v ./... - env GOOS=netbsd GOARCH=arm64 go build -v ./... - - echo "=> go build (plugin)" - # Make sure that plugin buildmode works since we save the R15 register (#254) - go build -buildmode=plugin ./examples/libc - - echo "=> go mod vendor" - mkdir /tmp/vendoring - cd /tmp/vendoring - go mod init foo - echo 'package main' > main.go - echo 'import (' >> main.go - echo ' _ "github.com/ebitengine/purego"' >> main.go - echo ')' >> main.go - echo 'func main() {}' >> main.go - go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE - go mod tidy - go mod vendor - go build -v . - - cd $GITHUB_WORKSPACE - echo "=> go test CGO_ENABLED=0" - env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=1" - env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=0 w/o optimization" - env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... - - echo "=> go test CGO_ENABLED=1 w/o optimization" - env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... - - if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then - echo "=> go test race" - go test -race -shuffle=on -v -count=10 ./... - fi - uses: actions/checkout@v4 - name: Run in freebsd if: matrix.os == 'FreeBSD' @@ -235,7 +159,81 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - <<: *shared_run + run: &shared_run | + # FreeBSD & NetBSD tests run within QEMU on Ubuntu. + # vmactions/freebsd-vm only supports a single "step" where it + # brings down the VM at the end of the step, so all + # the commands to run need to be put into this single block. + + echo "Running tests on $(uname -a) at $PWD" + + # verify Go is available + go version + + echo "=> go build" + go build -v ./... + # Compile without optimization to check potential stack overflow. + # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. + # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. + go build "-gcflags=all=-N -l" -v ./... + + # Check cross-compiling Windows binaries. + env GOOS=windows GOARCH=386 go build -v ./... + env GOOS=windows GOARCH=amd64 go build -v ./... + env GOOS=windows GOARCH=arm go build -v ./... + env GOOS=windows GOARCH=arm64 go build -v ./... + + # Check cross-compiling macOS binaries. + env GOOS=darwin GOARCH=amd64 go build -v ./... + env GOOS=darwin GOARCH=arm64 go build -v ./... + + # Check cross-compiling Linux binaries. + env GOOS=linux GOARCH=amd64 go build -v ./... + env GOOS=linux GOARCH=arm64 go build -v ./... + + # Check cross-compiling FreeBSD binaries. + env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + + # Check cross-compiling NetBSD binaries. + env GOOS=netbsd GOARCH=amd64 go build -v ./... + env GOOS=netbsd GOARCH=arm64 go build -v ./... + + echo "=> go build (plugin)" + # Make sure that plugin buildmode works since we save the R15 register (#254) + go build -buildmode=plugin ./examples/libc + + echo "=> go mod vendor" + mkdir /tmp/vendoring + cd /tmp/vendoring + go mod init foo + echo 'package main' > main.go + echo 'import (' >> main.go + echo ' _ "github.com/ebitengine/purego"' >> main.go + echo ')' >> main.go + echo 'func main() {}' >> main.go + go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE + go mod tidy + go mod vendor + go build -v . + + cd $GITHUB_WORKSPACE + echo "=> go test CGO_ENABLED=0" + env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... + + echo "=> go test CGO_ENABLED=1" + env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... + + echo "=> go test CGO_ENABLED=0 w/o optimization" + env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... + + echo "=> go test CGO_ENABLED=1 w/o optimization" + env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... + + if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then + echo "=> go test race" + go test -race -shuffle=on -v -count=10 ./... + fi - name: Run in netbsd if: matrix.os == 'NetBSD' uses: vmactions/netbsd-vm@v1 @@ -248,4 +246,4 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - <<: *shared_run + run: *shared_run From d6490545f4c6f3545c073724d85eb8d3b40a0541 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:08:30 -0500 Subject: [PATCH 42/59] fix spacing --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6396f280..1ba924fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -160,7 +160,7 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin run: &shared_run | - # FreeBSD & NetBSD tests run within QEMU on Ubuntu. + # FreeBSD & NetBSD tests run within QEMU on Ubuntu. # vmactions/freebsd-vm only supports a single "step" where it # brings down the VM at the end of the step, so all # the commands to run need to be put into this single block. From 7b5d581938b84154c57a78d789fe17f37e09995d Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:10:56 -0500 Subject: [PATCH 43/59] try separate test script --- .github/scripts/bsd_tests.sh | 74 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 78 +----------------------------------- 2 files changed, 76 insertions(+), 76 deletions(-) create mode 100755 .github/scripts/bsd_tests.sh diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh new file mode 100755 index 00000000..946b5e4d --- /dev/null +++ b/.github/scripts/bsd_tests.sh @@ -0,0 +1,74 @@ +# FreeBSD & NetBSD tests run within QEMU on Ubuntu. +# vmactions/freebsd-vm only supports a single "step" where it +# brings down the VM at the end of the step, so all +# the commands to run need to be put into this single block. + +echo "Running tests on $(uname -a) at $PWD" + +# verify Go is available +go version + +echo "=> go build" +go build -v ./... +# Compile without optimization to check potential stack overflow. +# The option '-gcflags=all=-N -l' is often used at Visual Studio Code. +# See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. +go build "-gcflags=all=-N -l" -v ./... + +# Check cross-compiling Windows binaries. +env GOOS=windows GOARCH=386 go build -v ./... +env GOOS=windows GOARCH=amd64 go build -v ./... +env GOOS=windows GOARCH=arm go build -v ./... +env GOOS=windows GOARCH=arm64 go build -v ./... + +# Check cross-compiling macOS binaries. +env GOOS=darwin GOARCH=amd64 go build -v ./... +env GOOS=darwin GOARCH=arm64 go build -v ./... + +# Check cross-compiling Linux binaries. +env GOOS=linux GOARCH=amd64 go build -v ./... +env GOOS=linux GOARCH=arm64 go build -v ./... + +# Check cross-compiling FreeBSD binaries. +env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... +env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... + +# Check cross-compiling NetBSD binaries. +env GOOS=netbsd GOARCH=amd64 go build -v ./... +env GOOS=netbsd GOARCH=arm64 go build -v ./... + +echo "=> go build (plugin)" +# Make sure that plugin buildmode works since we save the R15 register (#254) +go build -buildmode=plugin ./examples/libc + +echo "=> go mod vendor" +mkdir /tmp/vendoring +cd /tmp/vendoring +go mod init foo +echo 'package main' > main.go +echo 'import (' >> main.go +echo ' _ "github.com/ebitengine/purego"' >> main.go +echo ')' >> main.go +echo 'func main() {}' >> main.go +go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE +go mod tidy +go mod vendor +go build -v . + +cd $GITHUB_WORKSPACE +echo "=> go test CGO_ENABLED=0" +env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... + +echo "=> go test CGO_ENABLED=1" +env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... + +echo "=> go test CGO_ENABLED=0 w/o optimization" +env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... + +echo "=> go test CGO_ENABLED=1 w/o optimization" +env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... + +if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then + echo "=> go test race" + go test -race -shuffle=on -v -count=10 ./... +fi \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ba924fb..c0cfba50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,81 +159,7 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - run: &shared_run | - # FreeBSD & NetBSD tests run within QEMU on Ubuntu. - # vmactions/freebsd-vm only supports a single "step" where it - # brings down the VM at the end of the step, so all - # the commands to run need to be put into this single block. - - echo "Running tests on $(uname -a) at $PWD" - - # verify Go is available - go version - - echo "=> go build" - go build -v ./... - # Compile without optimization to check potential stack overflow. - # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. - # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120. - go build "-gcflags=all=-N -l" -v ./... - - # Check cross-compiling Windows binaries. - env GOOS=windows GOARCH=386 go build -v ./... - env GOOS=windows GOARCH=amd64 go build -v ./... - env GOOS=windows GOARCH=arm go build -v ./... - env GOOS=windows GOARCH=arm64 go build -v ./... - - # Check cross-compiling macOS binaries. - env GOOS=darwin GOARCH=amd64 go build -v ./... - env GOOS=darwin GOARCH=arm64 go build -v ./... - - # Check cross-compiling Linux binaries. - env GOOS=linux GOARCH=amd64 go build -v ./... - env GOOS=linux GOARCH=arm64 go build -v ./... - - # Check cross-compiling FreeBSD binaries. - env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... - - # Check cross-compiling NetBSD binaries. - env GOOS=netbsd GOARCH=amd64 go build -v ./... - env GOOS=netbsd GOARCH=arm64 go build -v ./... - - echo "=> go build (plugin)" - # Make sure that plugin buildmode works since we save the R15 register (#254) - go build -buildmode=plugin ./examples/libc - - echo "=> go mod vendor" - mkdir /tmp/vendoring - cd /tmp/vendoring - go mod init foo - echo 'package main' > main.go - echo 'import (' >> main.go - echo ' _ "github.com/ebitengine/purego"' >> main.go - echo ')' >> main.go - echo 'func main() {}' >> main.go - go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE - go mod tidy - go mod vendor - go build -v . - - cd $GITHUB_WORKSPACE - echo "=> go test CGO_ENABLED=0" - env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=1" - env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... - - echo "=> go test CGO_ENABLED=0 w/o optimization" - env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... - - echo "=> go test CGO_ENABLED=1 w/o optimization" - env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... - - if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then - echo "=> go test race" - go test -race -shuffle=on -v -count=10 ./... - fi + run: ./.github/scripts/setup.sh - name: Run in netbsd if: matrix.os == 'NetBSD' uses: vmactions/netbsd-vm@v1 @@ -246,4 +172,4 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - run: *shared_run + run: ./.github/scripts/setup.sh From 25f17fcd8d698451d15a195f7d15e0a5a96714df Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:27:25 -0500 Subject: [PATCH 44/59] fix misspelling --- .github/scripts/bsd_tests.sh | 2 ++ .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index 946b5e4d..64e19e15 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # FreeBSD & NetBSD tests run within QEMU on Ubuntu. # vmactions/freebsd-vm only supports a single "step" where it # brings down the VM at the end of the step, so all diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0cfba50..3cb67b4d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,7 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - run: ./.github/scripts/setup.sh + run: ./.github/scripts/bsd_tests.sh - name: Run in netbsd if: matrix.os == 'NetBSD' uses: vmactions/netbsd-vm@v1 @@ -172,4 +172,4 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - run: ./.github/scripts/setup.sh + run: ./.github/scripts/bsd_tests.sh From 2a6247cad581a50e5d43c14672a8dfcf31020a1b Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:32:33 -0500 Subject: [PATCH 45/59] ls to debug --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3cb67b4d..c19cba70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -172,4 +172,6 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - run: ./.github/scripts/bsd_tests.sh + run: | + ls -a + ./.github/scripts/bsd_tests.sh From 3b596674e812ee38e0f740f20f1c57d89fbeab03 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:40:33 -0500 Subject: [PATCH 46/59] ensure it is executable and then bash directly --- .github/workflows/test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c19cba70..a8bf1727 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,9 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - run: ./.github/scripts/bsd_tests.sh + + chmod +x .github/scripts/setup.sh + run: bash .github/scripts/bsd_tests.sh - name: Run in netbsd if: matrix.os == 'NetBSD' uses: vmactions/netbsd-vm@v1 @@ -172,6 +174,6 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - run: | - ls -a - ./.github/scripts/bsd_tests.sh + + chmod +x .github/scripts/setup.sh + run: bash .github/scripts/bsd_tests.sh From 75cbcfc2622f2053d3adecaea75b064cc798e2c5 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:43:04 -0500 Subject: [PATCH 47/59] newline and license --- .github/scripts/bsd_tests.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index 64e19e15..cf79629a 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -1,5 +1,8 @@ #!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2025 The Ebitengine Authors + # FreeBSD & NetBSD tests run within QEMU on Ubuntu. # vmactions/freebsd-vm only supports a single "step" where it # brings down the VM at the end of the step, so all @@ -73,4 +76,4 @@ env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then echo "=> go test race" go test -race -shuffle=on -v -count=10 ./... -fi \ No newline at end of file +fi From b0aba4386a81c6d9cc977184ed5ed5dfcafe4875 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:45:05 -0500 Subject: [PATCH 48/59] use "go version" for retrieving version --- .github/scripts/bsd_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index cf79629a..6bbc34bf 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -73,7 +73,7 @@ env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... echo "=> go test CGO_ENABLED=1 w/o optimization" env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... -if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then +if [ -z "$(go version | grep '^1.1')" ]; then echo "=> go test race" go test -race -shuffle=on -v -count=10 ./... fi From e7e4a0ec50b24b12913abb1f180b211ff145677f Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:45:38 -0500 Subject: [PATCH 49/59] fix misspelling --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8bf1727..40636acb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -160,7 +160,7 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - chmod +x .github/scripts/setup.sh + chmod +x .github/scripts/bsd_tests.sh run: bash .github/scripts/bsd_tests.sh - name: Run in netbsd if: matrix.os == 'NetBSD' @@ -175,5 +175,5 @@ jobs: ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - chmod +x .github/scripts/setup.sh + chmod +x .github/scripts/bsd_tests.sh run: bash .github/scripts/bsd_tests.sh From 5fda5966bf93416e117df53c4d2b44f4ce250730 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 10:53:05 -0500 Subject: [PATCH 50/59] don't run on version that aren't downloadable --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40636acb..f271765a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -163,7 +163,8 @@ jobs: chmod +x .github/scripts/bsd_tests.sh run: bash .github/scripts/bsd_tests.sh - name: Run in netbsd - if: matrix.os == 'NetBSD' + # there are no prebuilt download links for these versions of Go for NetBSD + if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') uses: vmactions/netbsd-vm@v1 with: usesh: true From 9616e789b5e906970647ff4a0ae8ba05cd677248 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 11:00:39 -0500 Subject: [PATCH 51/59] ls everything --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f271765a..85003333 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -175,6 +175,6 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - + ls -a -R chmod +x .github/scripts/bsd_tests.sh run: bash .github/scripts/bsd_tests.sh From f6b5e0a5620f1f86c9e41369aea43c52acd257fd Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 11:03:35 -0500 Subject: [PATCH 52/59] ls for freebsd --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85003333..973b6fad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,7 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - + ls -a -R chmod +x .github/scripts/bsd_tests.sh run: bash .github/scripts/bsd_tests.sh - name: Run in netbsd From d7c63f14e725058f2f696d7dc2de5a3e864e6e33 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 11:33:59 -0500 Subject: [PATCH 53/59] $GITHUB_WORKSPACE/ --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 973b6fad..1816d777 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -160,8 +160,8 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin ls -a -R - chmod +x .github/scripts/bsd_tests.sh - run: bash .github/scripts/bsd_tests.sh + chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') @@ -176,5 +176,5 @@ jobs: ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ ls -a -R - chmod +x .github/scripts/bsd_tests.sh - run: bash .github/scripts/bsd_tests.sh + chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh From a5d18b054705783459b4e175b1ece32c71fa9a6a Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 11:37:32 -0500 Subject: [PATCH 54/59] remove bash --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1816d777..2f61f346 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -161,7 +161,7 @@ jobs: ln -s /usr/local/go/bin/go /usr/local/bin ls -a -R chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') @@ -177,4 +177,4 @@ jobs: export PATH=$PATH:/usr/local/go/bin/ ls -a -R chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh From d0a90a95142146b1f3d5ddba19d9ee5ef73fe5b2 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 11:41:33 -0500 Subject: [PATCH 55/59] ls inside "run:" --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f61f346..6e4b92c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -161,7 +161,9 @@ jobs: ln -s /usr/local/go/bin/go /usr/local/bin ls -a -R chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: | + ls -a -R + $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') @@ -175,6 +177,5 @@ jobs: rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin export PATH=$PATH:/usr/local/go/bin/ - ls -a -R chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh From f2e19f36f69011949cbe9c0debc73fa9771d8ab7 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 14:12:30 -0500 Subject: [PATCH 56/59] updates for freebsd --- .github/scripts/bsd_tests.sh | 2 +- .github/workflows/test.yml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index 6bbc34bf..fb1c51e7 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 The Ebitengine Authors diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e4b92c5..f660bb2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,11 +159,8 @@ jobs: fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - ls -a -R chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: | - ls -a -R - $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') From 961e360613d555d10907fffd8a409c09365c237c Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 14:23:33 -0500 Subject: [PATCH 57/59] try bash again --- .github/scripts/bsd_tests.sh | 4 +++- .github/workflows/test.yml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index fb1c51e7..c889d59f 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 The Ebitengine Authors @@ -10,6 +10,8 @@ echo "Running tests on $(uname -a) at $PWD" +export PATH=$PATH:/usr/local/go/bin/ + # verify Go is available go version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f660bb2b..ab184a5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -156,6 +156,7 @@ jobs: with: usesh: true prepare: | + pkg install bash fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin @@ -173,6 +174,5 @@ jobs: mkdir /usr/local rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin - export PATH=$PATH:/usr/local/go/bin/ chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh From 19e4a72ce4bc32dc2f157812a35d83052a478b30 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 14:27:49 -0500 Subject: [PATCH 58/59] yes install bash --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab184a5c..528e8eb5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -156,12 +156,12 @@ jobs: with: usesh: true prepare: | - pkg install bash + pkg install --yes bash fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') From 74c6bf60aef0ff152f2aa15e52480281f14c0d1a Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Sat, 8 Mar 2025 14:33:20 -0500 Subject: [PATCH 59/59] sh --- .github/scripts/bsd_tests.sh | 4 ++-- .github/workflows/test.yml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/scripts/bsd_tests.sh b/.github/scripts/bsd_tests.sh index c889d59f..08ddc41a 100755 --- a/.github/scripts/bsd_tests.sh +++ b/.github/scripts/bsd_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 The Ebitengine Authors @@ -10,7 +10,7 @@ echo "Running tests on $(uname -a) at $PWD" -export PATH=$PATH:/usr/local/go/bin/ +PATH=$PATH:/usr/local/go/bin/ # verify Go is available go version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 528e8eb5..2759fd99 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -156,12 +156,11 @@ jobs: with: usesh: true prepare: | - pkg install --yes bash fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - run: bash $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh + run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh - name: Run in netbsd # there are no prebuilt download links for these versions of Go for NetBSD if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.')