all: NetBSD: fix failing tests (#433)
Applied several missing build tags to NetBSD files which fixes the segmentation fault observed in #304 Closes #349
- commit
- 2a9cea4a86dd602ca79702f3e19a0184ce6eb4ed
- author
- George Adams · · 2026-03-06 13:59 UTC
- committer
- GitHub · · 2026-03-06 13:59 UTC
- parent
- 5110604
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
8 files · +15 -18
M .github/scripts/bsd_tests.sh +5 -3
| @@ -43,9 +43,11 @@ env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/in | |||
| 43 | 43 | env GOOS=netbsd GOARCH=amd64 go build -v ./... | |
| 44 | 44 | env GOOS=netbsd GOARCH=arm64 go build -v ./... | |
| 45 | 45 | ||
| 46 | - | echo "=> go build (plugin)" | |
| 47 | - | # Make sure that plugin buildmode works since we save the R15 register (#254) | |
| 48 | - | go build -buildmode=plugin ./examples/libc | |
| 46 | + | if [ "$(uname)" = "FreeBSD" ]; then | |
| 47 | + | echo "=> go build (plugin)" | |
| 48 | + | # Make sure that plugin buildmode works since we save the R15 register (#254) | |
| 49 | + | go build -buildmode=plugin ./examples/libc | |
| 50 | + | fi | |
| 49 | 51 | ||
| 50 | 52 | echo "=> go mod vendor" | |
| 51 | 53 | mkdir /tmp/vendoring | |
| @@ -43,9 +43,11 @@ env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/in | |||||
| 43 | env GOOS=netbsd GOARCH=amd64 go build -v ./... | 43 | env GOOS=netbsd GOARCH=amd64 go build -v ./... | ||
| 44 | env GOOS=netbsd GOARCH=arm64 go build -v ./... | 44 | env GOOS=netbsd GOARCH=arm64 go build -v ./... | ||
| 45 | 45 | ||||
| 46 | - | echo "=> go build (plugin)" | 46 | + | if [ "$(uname)" = "FreeBSD" ]; then |
| 47 | - | # Make sure that plugin buildmode works since we save the R15 register (#254) | 47 | + | echo "=> go build (plugin)" |
| 48 | - | go build -buildmode=plugin ./examples/libc | 48 | + | # Make sure that plugin buildmode works since we save the R15 register (#254) |
| 49 | + | go build -buildmode=plugin ./examples/libc | |||
| 50 | + | fi | |||
| 49 | 51 | ||||
| 50 | echo "=> go mod vendor" | 52 | echo "=> go mod vendor" | ||
| 51 | mkdir /tmp/vendoring | 53 | mkdir /tmp/vendoring | ||
M .github/workflows/test.yml +2 -10
| @@ -251,16 +251,8 @@ jobs: | |||
| 251 | 251 | bsd: | |
| 252 | 252 | strategy: | |
| 253 | 253 | matrix: | |
| 254 | - | os: ['FreeBSD'] # TODO: Add 'NetBSD' again (#304) | |
| 255 | - | go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.12', '1.24.13', '1.25.7', '1.26.0'] | |
| 256 | - | exclude: | |
| 257 | - | # there are no prebuilt download links for these versions of Go for NetBSD | |
| 258 | - | - os: NetBSD | |
| 259 | - | go: '1.18.10' | |
| 260 | - | - os: NetBSD | |
| 261 | - | go: '1.19.13' | |
| 262 | - | - os: NetBSD | |
| 263 | - | go: '1.20.14' | |
| 254 | + | os: ['FreeBSD', 'NetBSD'] | |
| 255 | + | go: ['1.25.8', '1.26.1'] | |
| 264 | 256 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | |
| 265 | 257 | runs-on: ubuntu-22.04 | |
| 266 | 258 | defaults: | |
| @@ -251,16 +251,8 @@ jobs: | |||||
| 251 | bsd: | 251 | bsd: | ||
| 252 | strategy: | 252 | strategy: | ||
| 253 | matrix: | 253 | matrix: | ||
| 254 | - | os: ['FreeBSD'] # TODO: Add 'NetBSD' again (#304) | 254 | + | os: ['FreeBSD', 'NetBSD'] |
| 255 | - | go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.12', '1.24.13', '1.25.7', '1.26.0'] | 255 | + | go: ['1.25.8', '1.26.1'] |
| 256 | - | exclude: | |||
| 257 | - | # there are no prebuilt download links for these versions of Go for NetBSD | |||
| 258 | - | - os: NetBSD | |||
| 259 | - | go: '1.18.10' | |||
| 260 | - | - os: NetBSD | |||
| 261 | - | go: '1.19.13' | |||
| 262 | - | - os: NetBSD | |||
| 263 | - | go: '1.20.14' | |||
| 264 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | 256 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | ||
| 265 | runs-on: ubuntu-22.04 | 257 | runs-on: ubuntu-22.04 | ||
| 266 | defaults: | 258 | defaults: | ||
M README.md +1 -0
| @@ -43,6 +43,7 @@ Tier 2 platforms are supported by PureGo on a best-effort basis. Critical bugs o | |||
| 43 | 43 | - **Android**: 386<sup>1</sup>, arm<sup>1</sup> | |
| 44 | 44 | - **FreeBSD**: amd64<sup>2</sup>, arm64<sup>2</sup> | |
| 45 | 45 | - **Linux**: 386, arm, loong64, ppc64le, riscv64, s390x<sup>1</sup> | |
| 46 | + | - **NetBSD**: amd64<sup>2</sup>, arm64<sup>2</sup> | |
| 46 | 47 | - **Windows**: 386<sup>3</sup>, arm<sup>3,4</sup> | |
| 47 | 48 | ||
| 48 | 49 | #### Support Notes | |
| @@ -43,6 +43,7 @@ Tier 2 platforms are supported by PureGo on a best-effort basis. Critical bugs o | |||||
| 43 | - **Android**: 386<sup>1</sup>, arm<sup>1</sup> | 43 | - **Android**: 386<sup>1</sup>, arm<sup>1</sup> | ||
| 44 | - **FreeBSD**: amd64<sup>2</sup>, arm64<sup>2</sup> | 44 | - **FreeBSD**: amd64<sup>2</sup>, arm64<sup>2</sup> | ||
| 45 | - **Linux**: 386, arm, loong64, ppc64le, riscv64, s390x<sup>1</sup> | 45 | - **Linux**: 386, arm, loong64, ppc64le, riscv64, s390x<sup>1</sup> | ||
| 46 | + | - **NetBSD**: amd64<sup>2</sup>, arm64<sup>2</sup> | |||
| 46 | - **Windows**: 386<sup>3</sup>, arm<sup>3,4</sup> | 47 | - **Windows**: 386<sup>3</sup>, arm<sup>3,4</sup> | ||
| 47 | 48 | ||||
| 48 | #### Support Notes | 49 | #### Support Notes | ||
M dlfcn_nocgo_netbsd.go +2 -0
| @@ -1,6 +1,8 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2025 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | + | //go:build !cgo | |
| 5 | + | ||
| 4 | 6 | package purego | |
| 5 | 7 | ||
| 6 | 8 | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so" | |
| @@ -1,6 +1,8 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2025 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2025 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | + | //go:build !cgo | |||
| 5 | + | ||||
| 4 | package purego | 6 | package purego | ||
| 5 | 7 | ||||
| 6 | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so" | 8 | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so" | ||
M internal/fakecgo/libcgo_netbsd.go +2 -2
| @@ -15,11 +15,11 @@ var ( | |||
| 15 | 15 | PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) | |
| 16 | 16 | ) | |
| 17 | 17 | ||
| 18 | - | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/compat/linux/arch/m68k/linux_signal.h#L133 | |
| 18 | + | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L225 | |
| 19 | 19 | type stack_t struct { | |
| 20 | 20 | ss_sp uintptr | |
| 21 | - | ss_flags int32 | |
| 22 | 21 | ss_size uintptr | |
| 22 | + | ss_flags int32 | |
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | 25 | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261 | |
| @@ -15,11 +15,11 @@ var ( | |||||
| 15 | PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) | 15 | PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0) | ||
| 16 | ) | 16 | ) | ||
| 17 | 17 | ||||
| 18 | - | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/compat/linux/arch/m68k/linux_signal.h#L133 | 18 | + | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L225 |
| 19 | type stack_t struct { | 19 | type stack_t struct { | ||
| 20 | ss_sp uintptr | 20 | ss_sp uintptr | ||
| 21 | - | ss_flags int32 | |||
| 22 | ss_size uintptr | 21 | ss_size uintptr | ||
| 22 | + | ss_flags int32 | |||
| 23 | } | 23 | } | ||
| 24 | 24 | ||||
| 25 | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261 | 25 | // Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261 | ||
M internal/fakecgo/netbsd.go +1 -1
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | // Use of this source code is governed by a BSD-style | |
| 3 | 3 | // license that can be found in the LICENSE file. | |
| 4 | 4 | ||
| 5 | - | //go:build netbsd | |
| 5 | + | //go:build !cgo && netbsd | |
| 6 | 6 | ||
| 7 | 7 | package fakecgo | |
| 8 | 8 | ||
| @@ -2,7 +2,7 @@ | |||||
| 2 | // Use of this source code is governed by a BSD-style | 2 | // Use of this source code is governed by a BSD-style | ||
| 3 | // license that can be found in the LICENSE file. | 3 | // license that can be found in the LICENSE file. | ||
| 4 | 4 | ||||
| 5 | - | //go:build netbsd | 5 | + | //go:build !cgo && netbsd |
| 6 | 6 | ||||
| 7 | package fakecgo | 7 | package fakecgo | ||
| 8 | 8 | ||||
M internal/fakecgo/trampolines_amd64.s +1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build !cgo && (darwin || linux || freebsd) | |
| 4 | + | //go:build !cgo && (darwin || freebsd || linux || netbsd) | |
| 5 | 5 | ||
| 6 | 6 | /* | |
| 7 | 7 | trampoline for emulating required C functions for cgo in go (see cgo.go) | |
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build !cgo && (darwin || linux || freebsd) | 4 | + | //go:build !cgo && (darwin || freebsd || linux || netbsd) |
| 5 | 5 | ||||
| 6 | /* | 6 | /* | ||
| 7 | trampoline for emulating required C functions for cgo in go (see cgo.go) | 7 | trampoline for emulating required C functions for cgo in go (see cgo.go) | ||
M internal/fakecgo/trampolines_arm64.s +1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build !cgo && (darwin || freebsd || linux) | |
| 4 | + | //go:build !cgo && (darwin || freebsd || linux || netbsd) | |
| 5 | 5 | ||
| 6 | 6 | #include "textflag.h" | |
| 7 | 7 | #include "go_asm.h" | |
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build !cgo && (darwin || freebsd || linux) | 4 | + | //go:build !cgo && (darwin || freebsd || linux || netbsd) |
| 5 | 5 | ||||
| 6 | #include "textflag.h" | 6 | #include "textflag.h" | ||
| 7 | #include "go_asm.h" | 7 | #include "go_asm.h" | ||