Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in unsupported architectures #22

Merged
merged 12 commits into from
Mar 27, 2025
42 changes: 37 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
branches: [ '*' ]

jobs:
build:
runs-on: ubuntu-latest
supported:
strategy:
matrix:
go: [ '1.21', '1.22' ]
name: Go ${{ matrix.go }} test
runner: [ 'ubuntu-latest', 'ubuntu-24.04-arm' ]
runs-on: ${{ matrix.runner }}
name: Go ${{ matrix.go }} ${{ matrix.runner }} supported test
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
Expand All @@ -23,11 +24,42 @@ jobs:
uses: actions/checkout@v3

- name: Get dependencies
run: |
go get -v -t -d ./...
run: go get -v -t -d ./...

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

unsupported:
strategy:
matrix:
go: [ '1.21', '1.22' ]
runs-on: ubuntu-latest
name: Go ${{ matrix.go }} unsupported test
steps:
- name: Update package index
run: sudo apt-get update

- name: install qemu
run: sudo apt install --yes qemu-user-static

- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Get dependencies
run: go get -v -t -d ./...

- name: Build
run: GOARCH=riscv64 go build -v ./...

- name: Test
run: |
GOARCH=riscv64 go test -v ./... -c -o test.riscv64
qemu-riscv64-static test.riscv64 -test.v
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Prysmatic Labs
Copyright (c) 2022-2025 Prysmatic Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 1 addition & 3 deletions hash.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
MIT License

# Copyright (c) 2021 Prysmatic Labs
# Copyright (c) 2021-2025 Prysmatic Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,8 +28,6 @@ import (
"unsafe"
)

func _hash(digests *byte, p [][32]byte, count uint32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make space for an empty implementation in the hash_unsupported. Otherwise there would be two declarations of this function.


// Hash hashes the chunks two at the time and outputs the digests on the first
// argument. It does check for lengths on the inputs.
func Hash(digests [][32]byte, chunks [][32]byte) error {
Expand Down
4 changes: 3 additions & 1 deletion hash_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
MIT License

Copyright (c) 2021 Prysmatic Labs
Copyright (c) 2021-2025 Prysmatic Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -34,3 +34,5 @@ var hasAVX512 = cpuid.CPU.Supports(cpuid.AVX512F, cpuid.AVX512VL)
var hasAVX2 = cpuid.CPU.Supports(cpuid.AVX2, cpuid.BMI2)
var hasShani = cpuid.CPU.Supports(cpuid.SHA, cpuid.AVX)
var supportedCPU = hasAVX2 || hasShani || hasAVX512

func _hash(digests *byte, p [][32]byte, count uint32)
4 changes: 3 additions & 1 deletion hash_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
MIT License

Copyright (c) 2021 Prysmatic Labs
Copyright (c) 2021-2025 Prysmatic Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -32,3 +32,5 @@ import (

var hasShani = cpuid.CPU.Supports(cpuid.SHA2)
var supportedCPU = true

func _hash(digests *byte, p [][32]byte, count uint32)
30 changes: 30 additions & 0 deletions hash_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:build !amd64 && !arm64

/*
MIT License

Copyright (c) 2025 Prysmatic Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package gohashtree

var supportedCPU = false

func _hash(digests *byte, p [][32]byte, count uint32) {}
Loading