Skip to content

Commit 475fefc

Browse files
ruboclaude
andauthored
feat: add win-arm64 support and store native libraries in LFS (#12)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9dbcc64 commit 475fefc

12 files changed

Lines changed: 223 additions & 136 deletions

File tree

‎.gitattributes‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
* text=auto eol=lf
2+
src/Nethermind.Crypto.Bls/runtimes/**/*.dll filter=lfs diff=lfs merge=lfs -text
3+
src/Nethermind.Crypto.Bls/runtimes/**/*.dylib filter=lfs diff=lfs merge=lfs -text
4+
src/Nethermind.Crypto.Bls/runtimes/**/*.so filter=lfs diff=lfs merge=lfs -text

‎.github/workflows/build-blst.yml‎

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Build blst
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: blst repo ref
8+
required: true
9+
default: master
10+
type: string
11+
create-pr:
12+
description: Create a pull request
13+
default: false
14+
type: boolean
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
env:
21+
RETENTION: 7
22+
23+
jobs:
24+
build-linux:
25+
name: Linux build
26+
strategy:
27+
matrix:
28+
arch: [arm64, x64]
29+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
30+
container:
31+
image: ubuntu:22.04
32+
options: --platform ${{ matrix.arch == 'arm64' && 'linux/arm64' || 'linux/amd64' }}
33+
steps:
34+
- name: Check out blst repository
35+
uses: actions/checkout@v7
36+
with:
37+
repository: supranational/blst
38+
ref: ${{ inputs.ref }}
39+
40+
- name: Install dependencies
41+
env:
42+
DEBIAN_FRONTEND: noninteractive
43+
run: |
44+
apt-get update
45+
apt-get install -y --no-install-recommends build-essential
46+
47+
- name: Build
48+
run: |
49+
sh ./build.sh -shared -D__BLST_PORTABLE__
50+
strip libblst.so
51+
52+
- name: Upload artifact
53+
uses: actions/upload-artifact@v7
54+
with:
55+
name: linux-${{ matrix.arch }}
56+
path: libblst.so
57+
retention-days: ${{ env.RETENTION }}
58+
if-no-files-found: error
59+
60+
build-macos:
61+
name: macOS build
62+
strategy:
63+
matrix:
64+
arch: [arm64, x64]
65+
runs-on: ${{ matrix.arch == 'arm64' && 'macos-latest' || 'macos-26-intel' }}
66+
steps:
67+
- name: Check out blst repository
68+
uses: actions/checkout@v7
69+
with:
70+
repository: supranational/blst
71+
ref: ${{ inputs.ref }}
72+
73+
- name: Build
74+
run: |
75+
./build.sh -shared -D__BLST_PORTABLE__
76+
strip -x libblst.dylib
77+
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v7
80+
with:
81+
name: osx-${{ matrix.arch }}
82+
path: libblst.dylib
83+
retention-days: ${{ env.RETENTION }}
84+
if-no-files-found: error
85+
86+
build-windows:
87+
name: Windows build
88+
strategy:
89+
matrix:
90+
arch: [arm64, x64]
91+
runs-on: ${{ matrix.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
92+
steps:
93+
- name: Check out blst repository
94+
uses: actions/checkout@v7
95+
with:
96+
repository: supranational/blst
97+
ref: ${{ inputs.ref }}
98+
99+
# build.bat picks the assembly flavor from the cl banner, so the toolchain must match the target
100+
- name: Set up PATH
101+
uses: ilammy/msvc-dev-cmd@v1
102+
with:
103+
arch: ${{ matrix.arch }}
104+
105+
# -arm64x is intentionally not used: it links with /noentry, which skips DllMain and thus
106+
# the runtime CPU feature detection (e.g., SHA-2 extensions on arm64)
107+
- name: Build
108+
shell: pwsh
109+
run: ./build.bat -shared -D__BLST_PORTABLE__
110+
111+
- name: Verify machine type
112+
shell: pwsh
113+
run: |
114+
$machine = dumpbin /headers blst.dll | Select-String 'machine \('
115+
Write-Output $machine
116+
if ($machine -notmatch '${{ matrix.arch == 'arm64' && 'ARM64' || 'x64' }}\)') { throw 'Unexpected machine type' }
117+
118+
- name: Upload artifact
119+
uses: actions/upload-artifact@v7
120+
with:
121+
name: win-${{ matrix.arch }}
122+
path: blst.dll
123+
retention-days: ${{ env.RETENTION }}
124+
if-no-files-found: error
125+
126+
create-pr:
127+
name: Create a pull request
128+
needs: [build-linux, build-macos, build-windows]
129+
if: inputs.create-pr
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Check out repository
133+
uses: actions/checkout@v7
134+
with:
135+
lfs: true
136+
137+
- name: Download artifacts
138+
uses: actions/download-artifact@v8
139+
with:
140+
path: src/Nethermind.Crypto.Bls/runtimes
141+
142+
- name: Move artifacts
143+
working-directory: src/Nethermind.Crypto.Bls/runtimes
144+
run: |
145+
mv -f linux-arm64/libblst.so linux-arm64/native/libblst.so
146+
mv -f linux-x64/libblst.so linux-x64/native/libblst.so
147+
mv -f osx-arm64/libblst.dylib osx-arm64/native/libblst.dylib
148+
mv -f osx-x64/libblst.dylib osx-x64/native/libblst.dylib
149+
mv -f win-arm64/blst.dll win-arm64/native/blst.dll
150+
mv -f win-x64/blst.dll win-x64/native/blst.dll
151+
152+
- name: Create a pull request
153+
env:
154+
GH_TOKEN: ${{ github.token }}
155+
REF: ${{ inputs.ref }}
156+
run: |
157+
head_branch=feature/blst-build-$GITHUB_RUN_NUMBER-$GITHUB_RUN_ATTEMPT
158+
title="chore(deps): update blst binaries to ${REF#v}"
159+
git config user.name "github-actions[bot]"
160+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
161+
git checkout -b $head_branch
162+
git add -A
163+
git commit -am "Update blst binaries"
164+
git push origin $head_branch
165+
gh pr create -B $GITHUB_REF_NAME -H $head_branch -t "$title" -b "Built from blst $REF."

0 commit comments

Comments
 (0)