Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/build-syso.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build syso files

on:
workflow_dispatch: # Manual trigger
push:
paths:
- 'src/**'

jobs:
build-syso:
name: Build ${{ matrix.settings.name }}
runs-on: ${{ matrix.settings.runner }}
strategy:
fail-fast: false
matrix:
settings:
- name: Linux x86
runner: ubuntu-latest
syso_name: hashtree_linux_amd64.syso
- name: macOS arm64
runner: macos-latest
syso_name: hashtree_darwin_arm64.syso
- name: Linux arm64
runner: ubuntu-latest
cc: aarch64-linux-gnu-gcc
cross_pkg: gcc-aarch64-linux-gnu
syso_name: hashtree_linux_arm64.syso
- name: Windows x86
runner: windows-latest
syso_name: hashtree_windows_amd64.syso
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'

- name: Install cross-compiler
if: ${{ matrix.settings.cross_pkg }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.settings.cross_pkg }}

- name: Build (cross-compile)
if: ${{ matrix.settings.cc }}
shell: bash
run: |
CC=${{ matrix.settings.cc }} make go_bindings
mv -f hashtree.syso ${{ matrix.settings.syso_name }}

- name: Build (native)
if: ${{ !matrix.settings.cc }}
shell: bash
run: |
make go_bindings
mv -f hashtree.syso ${{ matrix.settings.syso_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.syso_name }}
path: ${{ matrix.settings.syso_name }}

commit-syso:
name: Commit syso files
needs: build-syso
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Move syso files to root
run: |
for dir in artifacts/*/; do
mv "$dir"/*.syso .
done
ls -la *.syso

- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add *.syso
git diff --staged --quiet || git commit -m "Update syso files"
git push
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ jobs:
- name: MacOS arm64
target: aarch64-apple-darwin
runner: macos-latest
- name: MacOS x86
target: x86_64-apple-darwin
runner: macos-15-intel
generic_only: true
- name: Linux x86
target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
Expand Down Expand Up @@ -86,8 +90,11 @@ jobs:
if: ${{ matrix.settings.cc != '' }}
run: CC=${{ matrix.settings.cc }} make go_bindings
- name: Build
if: ${{ !matrix.settings.cc }}
if: ${{ !matrix.settings.cc && !matrix.settings.generic_only }}
run: make go_bindings
- name: Build (generic only)
if: ${{ matrix.settings.generic_only }}
run: go build .
- name: Run tests
run: go test .
- name: Run benchmarks
Expand Down
4 changes: 2 additions & 2 deletions bindings_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build amd64
// +build amd64
//go:build amd64 && !darwin
// +build amd64,!darwin

package hashtree

Expand Down
8 changes: 8 additions & 0 deletions bindings_darwin_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build darwin && amd64

package hashtree

// supportedCPU is false on darwin/amd64 because there is no native
// assembly implementation. The generic Go implementation will be used.
var supportedCPU = false

File renamed without changes.
7 changes: 7 additions & 0 deletions wrapper_darwin_amd64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build darwin,amd64

// Stub implementation - should never be called since supportedCPU = false
// on darwin/amd64. The generic Go implementation is used instead.
TEXT ·HashtreeHash(SB), 0, $0-24
INT $3 // Trigger breakpoint/crash if ever called
RET
Loading