From 0832b85059536339c4ed304a026b5197ee937d52 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 4 Jan 2026 16:35:41 -0800 Subject: [PATCH] fix build (by avoiding purego) on 32-bit GOARCH builds This makes those architectures effectively always build in "nodynamic" mode without having to set the build tag. Likewise, it disables dynamic mode (and use of "purego") on FreeBSD and OpenBSD where it wasn't compiling. Signed-off-by: Brad Fitzpatrick --- .github/workflows/test.yml | 51 ++++++++++++++++++++++++++++++++++++++ decode_dynamic.go | 2 +- go.mod | 2 +- purego_other.go | 2 +- purego_unix.go | 2 +- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1bd504d..f7d7341 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,3 +38,54 @@ jobs: dir - name: Test run: go test -v -bench=. -benchtime=1x + + # Test that we can at least cross-compile the package & tests on a variety + # of other platforms. + cross-build: + runs-on: ubuntu-latest + strategy: + fail-fast: false # don't abort the entire matrix if one element fails + matrix: + include: + # Note: {linux,windows,darwin}/amd64 is not in this matrix, because those + # are tested more exhaustively in the 'test' job above. + - goos: linux + goarch: "386" # quoted for yaml + - goos: linux + goarch: mips + - goos: linux + goarch: mipsle + - goos: linux + goarch: loong64 + - goos: linux + goarch: arm + goarm: "5" + - goos: linux + goarch: arm + goarm: "7" + # Windows + - goos: windows + goarch: arm64 + # BSDs + - goos: freebsd + goarch: amd64 + - goos: openbsd + goarch: amd64 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: build + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + GOARM: ${{ matrix.goarm }} + CGO_ENABLED: "0" + run: | + go install ./... + go test --exec=true ./... + diff --git a/decode_dynamic.go b/decode_dynamic.go index bb06020..b08931f 100644 --- a/decode_dynamic.go +++ b/decode_dynamic.go @@ -1,4 +1,4 @@ -//go:build (unix || darwin || windows) && !nodynamic +//go:build (linux || darwin || windows) && !(nodynamic || arm || 386 || mips || mipsle) package heic diff --git a/go.mod b/go.mod index c4cfcf8..1834c5a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gen2brain/heic -go 1.23 +go 1.25 require ( github.com/ebitengine/purego v0.9.1 diff --git a/purego_other.go b/purego_other.go index fe1403c..1460246 100644 --- a/purego_other.go +++ b/purego_other.go @@ -1,4 +1,4 @@ -//go:build (!unix && !darwin && !windows) || nodynamic +//go:build (!linux && !darwin && !windows) || android || nodynamic || arm || 386 || mips || mipsle package heic diff --git a/purego_unix.go b/purego_unix.go index 3188f96..1aa0180 100644 --- a/purego_unix.go +++ b/purego_unix.go @@ -1,4 +1,4 @@ -//go:build unix && !darwin && !nodynamic +//go:build linux && !android && !darwin && !(nodynamic || arm || 386 || mips || mipsle) package heic