forked from ggml-org/whisper.cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
1466 lines (1284 loc) · 67 KB
/
Copy pathbuild.yml
File metadata and controls
1466 lines (1284 loc) · 67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: AMD Build & Release
# ──────────────────────────────────────────────────────────────────────────────
# Triggers
# ──────────────────────────────────────────────────────────────────────────────
on:
schedule:
- cron: '0 2 * * 1' # Weekly – every Monday at 02:00 UTC
workflow_dispatch:
inputs:
create_release:
description: 'Create GitHub Release'
required: true
type: boolean
default: false
pre_release_tag:
description: 'Pre-release tag name (optional, overrides auto-tag)'
required: false
type: string
run_type:
description: 'Workflow scope'
required: true
type: choice
options:
- full-ci # all jobs
- release-only # release-producing jobs only
default: full-ci
gfx_targets:
description: 'ROCm GPU targets (comma-separated)'
required: false
type: string
default: 'gfx1151,gfx1150,gfx120X,gfx110X'
rocm_version:
description: 'ROCm version (e.g. 7.12.0)'
required: false
type: string
default: '7.12.0'
push:
tags:
- 'v*'
pull_request:
branches:
- master
- main
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: write
# ──────────────────────────────────────────────────────────────────────────────
# Shared environment
# ──────────────────────────────────────────────────────────────────────────────
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GFX_TARGETS: ${{ github.event.inputs.gfx_targets || 'gfx1151,gfx1150,gfx120X,gfx110X' }}
ROCM_VERSION: ${{ github.event.inputs.rocm_version || '7.12.0' }}
FLEXML_URL: "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0-win.zip"
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
jobs:
# ════════════════════════════════════════════════════════════════════════════════
# 0. Determine release tag
# ════════════════════════════════════════════════════════════════════════════════
determine-tag:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.name }}
version: ${{ steps.tag.outputs.version }}
should_release: ${{ steps.tag.outputs.should_release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine tag and version
id: tag
shell: bash
run: |
BUILD_NUMBER=$(git rev-list --count HEAD)
SHORT_HASH=$(git rev-parse --short=7 HEAD)
CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
SHOULD_RELEASE="false"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
# Triggered by sync.yml pushing a vX.Y.Z tag — this is the primary release path
TAG_NAME="${{ github.ref_name }}"
SHOULD_RELEASE="true"
elif [[ -n "$CUSTOM_TAG" ]]; then
TAG_NAME="$CUSTOM_TAG"
SHOULD_RELEASE="true"
elif [[ "${{ github.event.inputs.create_release }}" == "true" ]]; then
TAG_NAME="b${BUILD_NUMBER}"
SHOULD_RELEASE="true"
elif [[ "${{ env.BRANCH_NAME }}" == "main" || "${{ env.BRANCH_NAME }}" == "master" ]]; then
TAG_NAME="b${BUILD_NUMBER}"
SHOULD_RELEASE="false"
else
SAFE=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
TAG_NAME="${SAFE}-b${BUILD_NUMBER}-${SHORT_HASH}"
SHOULD_RELEASE="false"
fi
# Version used in artifact filenames — keep leading 'v' to match lemonade expectations
# e.g. v1.8.4 → v1.8.4, b1234 → b1234
VERSION="${TAG_NAME}"
echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
# ════════════════════════════════════════════════════════════════════════════════
# 1. ROCm matrix (Linux + Windows per GFX target)
# ════════════════════════════════════════════════════════════════════════════════
prepare-rocm-matrix:
runs-on: ubuntu-latest
outputs:
ubuntu_matrix: ${{ steps.m.outputs.ubuntu_matrix }}
windows_matrix: ${{ steps.m.outputs.windows_matrix }}
steps:
- name: Build matrix JSON
id: m
run: |
targets="${{ env.GFX_TARGETS }}"
arr=$(echo "$targets" | tr ',' '\n' | sed 's/^ *//;s/ *$//' | jq -R . | jq -s .)
ubuntu_matrix=$(echo "$arr" | jq -c \
'{gfx_target: ., build: ["Release"], sdl2: ["ON"], arch: ["linux/amd64"]}')
windows_matrix=$(echo "$arr" | jq -c \
'{gfx_target: ., build: ["Release"], sdl2: ["ON"], arch: ["x64"], s2arc: ["x64"], s2ver: ["2.28.5"]}')
echo "ubuntu_matrix=$ubuntu_matrix" >> $GITHUB_OUTPUT
echo "windows_matrix=$windows_matrix" >> $GITHUB_OUTPUT
# ════════════════════════════════════════════════════════════════════════════════
# 2. ROCm — Linux
# ════════════════════════════════════════════════════════════════════════════════
linux-rocm:
runs-on: ubuntu-22.04
needs: [determine-tag, prepare-rocm-matrix]
strategy:
matrix: ${{ fromJson(needs.prepare-rocm-matrix.outputs.ubuntu_matrix) }}
fail-fast: false
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /opt/ghc /usr/local/share/boost \
/usr/share/dotnet /usr/local/.ghcup /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force 2>/dev/null || true
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build curl build-essential libsdl2-dev git patchelf
- name: Download ROCm tarball
run: |
source ci/resolve-rocm-version.sh linux "${{ matrix.gfx_target }}" "${{ env.ROCM_VERSION }}"
echo "DETECTED_ROCM_VERSION=$ROCM_RESOLVED_VERSION" >> $GITHUB_ENV
sudo mkdir -p /opt/rocm
curl -L "$ROCM_TARBALL_URL" | sudo tar --use-compress-program=gzip -xf - -C /opt/rocm --strip-components=1
- name: Set ROCm env
run: |
echo "HIP_PATH=/opt/rocm" >> $GITHUB_ENV
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV
echo "HIP_PLATFORM=amd" >> $GITHUB_ENV
echo "/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH" >> $GITHUB_PATH
- name: Find bitcode path
run: |
BITCODE_PATH=$(find /opt/rocm -type d -name bitcode -print -quit)
[ -z "$BITCODE_PATH" ] && { echo "::error::bitcode dir not found"; exit 1; }
echo "ROCM_BITCODE_PATH=$BITCODE_PATH" >> $GITHUB_ENV
- name: Configure CMake
run: |
source ci/map-gpu-target.sh "${{ matrix.gfx_target }}"
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang \
-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
-DCMAKE_HIP_FLAGS="--rocm-path=/opt/rocm --rocm-device-lib-path=${{ env.ROCM_BITCODE_PATH }}" \
-DCMAKE_PREFIX_PATH=/opt/rocm \
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
-DGPU_TARGETS="$MAPPED_GPU_TARGET" \
-DGGML_HIP=ON \
-DWHISPER_BUILD_SERVER=ON \
-DWHISPER_SDL2=${{ matrix.sdl2 }}
- name: Build
run: |
cmake --build build --config ${{ matrix.build }} -j$(nproc) > build.log 2>&1
exit_code=$?
grep -E "error:|FAILED|Linking|Built target|warning:" build.log || true
if [ $exit_code -ne 0 ]; then
echo "--- Last 100 lines of build log ---"
tail -100 build.log
echo "Build failed with exit code $exit_code"
exit $exit_code
fi
echo "Build succeeded."
- name: Verify build output
run: |
if [ ! -f build/bin/whisper-cli ]; then
echo "::error::whisper-cli not found - build likely truncated"
ls -lh build/bin/ 2>/dev/null || true
exit 1
fi
if [ ! -f build/bin/whisper-server ]; then
echo "::error::whisper-server not found - build likely truncated"
ls -lh build/bin/ 2>/dev/null || true
exit 1
fi
echo "Build output:"; ls -lh build/bin/whisper-cli build/bin/whisper-server
- name: Inspect shared library dependencies
run: |
echo "--- ldd whisper-cli ---"
ldd build/bin/whisper-cli || true
echo "--- ldd whisper-server ---"
ldd build/bin/whisper-server || true
echo "--- missing libs ---"
MISSING_CLI=$(ldd build/bin/whisper-cli 2>/dev/null | grep "not found" || true)
MISSING_SRV=$(ldd build/bin/whisper-server 2>/dev/null | grep "not found" || true)
if [ -z "$MISSING_CLI" ] && [ -z "$MISSING_SRV" ]; then
echo "All dependencies resolved."
else
[ -n "$MISSING_CLI" ] && echo "whisper-cli missing:" && echo "$MISSING_CLI"
[ -n "$MISSING_SRV" ] && echo "whisper-server missing:" && echo "$MISSING_SRV"
fi
echo "--- .so* files in build/bin/ ---"
ls -lh build/bin/*.so* 2>/dev/null || echo "(none)"
- name: Copy ROCm runtime libs
run: |
BIN="build/bin"
mkdir -p "$BIN"
cp -a build/src/libwhisper.so* "$BIN"/ 2>/dev/null || true
cp -a build/ggml/src/libggml.so* "$BIN"/ 2>/dev/null || true
cp -a build/ggml/src/libggml-base.so* "$BIN"/ 2>/dev/null || true
cp -a build/ggml/src/libggml-cpu.so* "$BIN"/ 2>/dev/null || true
cp -a build/ggml/src/ggml-hip/libggml-hip.so* "$BIN"/ 2>/dev/null || true
export LD_LIBRARY_PATH="$PWD/$BIN:/opt/rocm/lib:/opt/rocm/lib/llvm/lib:/opt/rocm/lib/rocm_sysdeps/lib:${LD_LIBRARY_PATH:-}"
ROCM_ROOTS="/opt/rocm/lib /opt/rocm/lib/llvm/lib /opt/rocm/lib/rocm_sysdeps/lib"
for binary in "$BIN"/*; do
[ -f "$binary" ] && [ -x "$binary" ] && file "$binary" | grep -q ELF || continue
ldd "$binary" 2>/dev/null | awk '{print $3}' | grep -E "^/opt/rocm" | while read lib; do
[ -f "$lib" ] || continue
cp -n "$lib" "$BIN/" 2>/dev/null || true
# Also copy the soname symlink if it exists alongside the real file
dir=$(dirname "$lib")
base=$(basename "$lib")
find "$dir" -maxdepth 1 -name "${base%%.*}.so*" -exec cp -Pn {} "$BIN/" \; 2>/dev/null || true
done
done
# Transitive deps: repeat ldd over any newly copied ROCm .so to catch indirect deps
for pass in 1 2; do
for lib in "$BIN"/lib*.so*; do
[ -f "$lib" ] && [ ! -L "$lib" ] || continue
ldd "$lib" 2>/dev/null | awk '{print $3}' | grep -E "^/opt/rocm" | while read dep; do
[ -f "$dep" ] || continue
cp -n "$dep" "$BIN/" 2>/dev/null || true
done
done
done
# Kernel library data dirs (loaded at runtime by path, not via soname)
[ -d /opt/rocm/lib/rocblas/library ] && { mkdir -p "$BIN/rocblas"; cp -r /opt/rocm/lib/rocblas/library "$BIN/rocblas/"; }
[ -d /opt/rocm/lib/hipblaslt/library ] && { mkdir -p "$BIN/hipblaslt"; cp -r /opt/rocm/lib/hipblaslt/library "$BIN/hipblaslt/"; }
- name: Set portable RPATH
run: |
cd build/bin
for f in *.so* whisper-*; do
[ -f "$f" ] && [ ! -L "$f" ] && file "$f" | grep -q ELF && patchelf --set-rpath '$ORIGIN' "$f" 2>/dev/null || true
done
- name: Package
run: |
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-linux-rocm-${{ matrix.gfx_target }}.tar.gz"
STAGE="whisper-${VER}-linux-rocm-${{ matrix.gfx_target }}"
mkdir -p "$STAGE" && cp -r build/bin/* "$STAGE/"
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 3. ROCm — Windows
# ════════════════════════════════════════════════════════════════════════════════
windows-rocm:
runs-on: windows-2022
needs: [determine-tag, prepare-rocm-matrix]
strategy:
matrix: ${{ fromJson(needs.prepare-rocm-matrix.outputs.windows_matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install Ninja
shell: powershell
run: choco install ninja -y
- name: Fetch SDL2 and patch header
if: matrix.sdl2 == 'ON'
shell: powershell
run: |
$url = "https://github.com/libsdl-org/SDL/releases/download/release-${{ matrix.s2ver }}/SDL2-devel-${{ matrix.s2ver }}-VC.zip"
Invoke-WebRequest -Uri $url -OutFile sdl2.zip
7z x sdl2.zip
$cmake = Get-ChildItem -Recurse -Filter "sdl2-config.cmake" | Select-Object -First 1
if ($cmake) { echo "SDL2_DIR=$($cmake.DirectoryName)" >> $env:GITHUB_ENV }
else { Write-Error "sdl2-config.cmake not found"; exit 1 }
$hdr = Get-ChildItem -Recurse -Filter "SDL_endian.h" | Select-Object -First 1
if ($hdr) {
$c = Get-Content $hdr.FullName -Raw
if ($c -match 'extern void _m_prefetch') {
$c = $c -replace 'extern void _m_prefetch\(void \*__P\);','// extern void _m_prefetch(void *__P);'
Set-Content $hdr.FullName $c
}
} else { Write-Error "SDL_endian.h not found"; exit 1 }
- name: Download and extract ROCm tarball
shell: powershell
run: |
$gfx = "${{ matrix.gfx_target }}"
$ver = "${{ env.ROCM_VERSION }}"
$base = switch ($gfx) {
"gfx110X" { "gfx110X-all" }
"gfx120X" { "gfx120X-all" }
"gfx1150" { "gfx1150" }
"gfx1151" { "gfx1151" }
"gfx1152" { "gfx1152" }
default { $gfx }
}
$url = "https://repo.amd.com/rocm/tarball/therock-dist-windows-${base}-${ver}.tar.gz"
Write-Host "ROCm URL: $url"
"DETECTED_ROCM_VERSION=$ver" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
curl.exe -L --retry 3 --retry-delay 5 -o rocm.tar.gz $url
if ($LASTEXITCODE -ne 0) { Write-Error "curl failed with exit code $LASTEXITCODE"; exit 1 }
New-Item -ItemType Directory -Force -Path "C:\opt\rocm" | Out-Null
tar -xzf rocm.tar.gz -C C:\opt\rocm --strip-components=1
- name: Map GPU target
id: gpu
shell: powershell
run: |
$gfx = "${{ matrix.gfx_target }}"
$mapped = switch ($gfx) {
"gfx110X" { "gfx1100;gfx1101;gfx1102" }
"gfx120X" { "gfx1200;gfx1201" }
default { $gfx }
}
Write-Host "Mapped GPU target: $gfx -> $mapped"
"mapped=$mapped" | Out-File $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Configure CMake
shell: powershell
run: |
$env:HIP_PATH = "C:\opt\rocm"
$env:HIP_PLATFORM = "amd"
$env:PATH = "$env:HIP_PATH\bin;$env:HIP_PATH\lib\llvm\bin;$env:PATH"
cmake -S . -B build `
-G "Ninja Multi-Config" `
-DGPU_TARGETS="${{ steps.gpu.outputs.mapped }}" `
-DGGML_HIP=ON `
-DCMAKE_C_COMPILER="$env:HIP_PATH/lib/llvm/bin/amdclang.exe" `
-DCMAKE_CXX_COMPILER="$env:HIP_PATH/lib/llvm/bin/amdclang++.exe" `
-DCMAKE_HIP_COMPILER="$env:HIP_PATH/lib/llvm/bin/amdclang++.exe" `
"-DCMAKE_C_FLAGS='-D__PRFCHWINTRIN_H'" `
"-DCMAKE_CXX_FLAGS='-D__PRFCHWINTRIN_H'" `
"-DCMAKE_HIP_FLAGS=--rocm-path=C:/opt/rocm" `
-DCMAKE_PREFIX_PATH="$env:HIP_PATH" `
-DCMAKE_BUILD_TYPE=${{ matrix.build }} `
-DWHISPER_BUILD_SERVER=ON `
-DWHISPER_SDL2=${{ matrix.sdl2 }}
- name: Build
shell: powershell
run: |
cmake --build build --config ${{ matrix.build }} -j $env:NUMBER_OF_PROCESSORS > build.log 2>&1
$exit = $LASTEXITCODE
# Show only errors and link steps - keeps log under GitHub's line limit
Get-Content build.log | Select-String -Pattern "error:|FAILED|Linking|Built target|warning: " | Write-Host
if ($exit -ne 0) {
Write-Host "--- Last 100 lines of build log ---"
Get-Content build.log -Tail 100
Write-Error "Build failed with exit code $exit"
exit $exit
}
Write-Host "Build succeeded."
- name: Copy ROCm DLLs
shell: powershell
run: |
$bin = "build/bin/${{ matrix.build }}"
$rocBin = "C:\opt\rocm\bin"
@("amdhip64_*.dll","amd_comgr*.dll","libhipblas.dll","rocblas.dll",
"rocsolver.dll","hipblaslt.dll","libhipblaslt.dll","hipblas.dll") | ForEach-Object {
Get-ChildItem $rocBin -Name $_ -ErrorAction SilentlyContinue |
ForEach-Object { Copy-Item (Join-Path $rocBin $_) (Join-Path $bin $_) }
}
$rocLib = Join-Path $rocBin "rocblas\library"
if (Test-Path $rocLib) { Copy-Item $rocLib -Destination (Join-Path $bin "rocblas\library") -Recurse -Force }
$hipLib = Join-Path $rocBin "hipblaslt\library"
if (Test-Path $hipLib) { Copy-Item $hipLib -Destination (Join-Path $bin "hipblaslt\library") -Recurse -Force }
- name: Copy SDL2.dll
if: matrix.sdl2 == 'ON'
shell: powershell
run: copy "$env:SDL2_DIR/../lib/${{ matrix.s2arc }}/SDL2.dll" "build/bin/${{ matrix.build }}"
- name: Verify build output
shell: powershell
run: |
$bin = "build/bin/${{ matrix.build }}"
if (-not (Test-Path "$bin/whisper-cli.exe")) {
Write-Error "whisper-cli.exe not found in $bin - build likely truncated"
Get-ChildItem $bin -ErrorAction SilentlyContinue | Format-Table Name, Length
exit 1
}
if (-not (Test-Path "$bin/whisper-server.exe")) {
Write-Error "whisper-server.exe not found in $bin - build likely truncated"
Get-ChildItem $bin -ErrorAction SilentlyContinue | Format-Table Name, Length
exit 1
}
Write-Host "Build output:"
Get-ChildItem $bin -Filter "*.exe" | Format-Table Name, Length
- name: Package
shell: powershell
run: |
$a = "whisper-${{ needs.determine-tag.outputs.version }}-windows-rocm-${{ matrix.gfx_target }}.zip"
Compress-Archive -Path "build/bin/${{ matrix.build }}/*" -DestinationPath $a -Force
"ARCHIVE=$a" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 4. Vulkan — Linux
# ════════════════════════════════════════════════════════════════════════════════
linux-vulkan:
runs-on: ubuntu-latest
needs: determine-tag
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libsdl2-dev pkg-config libvulkan-dev vulkan-tools
sudo apt-get install -y glslc || sudo apt-get install -y shaderc
- name: Check Vulkan availability
run: |
if ! command -v glslc >/dev/null 2>&1 && ! command -v glslangValidator >/dev/null 2>&1; then
echo "::error::No GLSL compiler found (glslc / shaderc)"; exit 1
fi
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_NATIVE=OFF \
-DGGML_AVX=ON \
-DGGML_AVX2=ON \
-DGGML_FMA=ON \
-DGGML_AVX512=OFF \
-DCMAKE_C_FLAGS="-march=x86-64-v3" \
-DCMAKE_CXX_FLAGS="-march=x86-64-v3" \
-DGGML_VULKAN=ON \
-DWHISPER_BUILD_EXAMPLES=ON \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_SERVER=ON
- name: Build
run: cmake --build build --config Release -j$(nproc)
- name: Validate Vulkan artifacts
run: |
VFILES=$(find build -type f \( -iname "*vulkan*.so*" -o -iname "*vulkan*" \) 2>/dev/null | wc -l)
if [ "$VFILES" -eq 0 ]; then
echo "::warning::No Vulkan-related artifacts found"
else
echo "Vulkan artifacts found: $VFILES file(s)"
fi
- name: Package
run: |
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-linux-vulkan-x86_64.tar.gz"
STAGE="whisper-${VER}-linux-vulkan-x86_64"
mkdir -p "$STAGE"
cp -r build/bin/* "$STAGE/" 2>/dev/null || true
find build -name "*.so*" -exec cp {} "$STAGE/" \; 2>/dev/null || true
# Rewrite the absolute build-tree rpath to $ORIGIN so the relocated musl
# binaries find their sibling .so files (musl doesn't search the exe dir).
if ! command -v patchelf >/dev/null; then sudo apt-get update -qq && sudo apt-get install -y -qq patchelf; fi
for f in "$STAGE"/*; do
[ -f "$f" ] && [ ! -L "$f" ] && file "$f" | grep -q ELF && patchelf --set-rpath '$ORIGIN' "$f" 2>/dev/null || true
done
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 5. Vulkan — Windows
# ════════════════════════════════════════════════════════════════════════════════
windows-vulkan:
runs-on: windows-latest
needs: determine-tag
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Install Vulkan SDK
shell: pwsh
run: |
winget install --id KhronosGroup.VulkanSDK -e --silent --accept-package-agreements --accept-source-agreements
$sdk = Get-ChildItem "C:\VulkanSDK" -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $sdk) { throw "Vulkan SDK not found under C:\VulkanSDK" }
"VULKAN_SDK=$($sdk.FullName)" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
- name: Fetch SDL2
shell: pwsh
run: |
C:/msys64/usr/bin/wget.exe -qO sdl2.zip https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-devel-2.28.5-VC.zip
7z x sdl2.zip
"SDL2_DIR=$env:GITHUB_WORKSPACE/SDL2-2.28.5/cmake" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
- name: Configure CMake
shell: pwsh
run: |
cmake -S . -B ./build -A x64 `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_SHARED_LIBS=ON `
-DGGML_VULKAN=ON `
-DWHISPER_BUILD_SERVER=ON `
-DWHISPER_SDL2=ON `
-DVULKAN_SDK="$env:VULKAN_SDK"
- name: Build
run: cd ./build && msbuild ALL_BUILD.vcxproj -t:build -p:configuration=Release -p:platform=x64
- name: Copy SDL2.dll
shell: pwsh
run: copy "$env:SDL2_DIR/../lib/x64/SDL2.dll" build/bin/Release
- name: Package
shell: pwsh
run: |
$a = "whisper-${{ needs.determine-tag.outputs.version }}-windows-vulkan-x64.zip"
Compress-Archive -Path "build/bin/Release/*" -DestinationPath $a -Force
"ARCHIVE=$a" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 6. NPU (VitisAI / RyzenAI) — Windows only (self-hosted runner)
# ════════════════════════════════════════════════════════════════════════════════
windows-npu:
runs-on: [self-hosted, Windows, stx, rai300_400]
needs: determine-tag
continue-on-error: true # runner may be offline; don't block release
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Install CMake if not available
shell: powershell
run: |
$installed = Get-Command cmake -ErrorAction SilentlyContinue
if (-not $installed) {
$ver = "3.28.1"
$url = "https://github.com/Kitware/CMake/releases/download/v$ver/cmake-$ver-windows-x86_64.msi"
Invoke-WebRequest -Uri $url -OutFile cmake.msi
Start-Process msiexec.exe -ArgumentList "/i cmake.msi /quiet /norestart" -Wait
$p = "C:\Program Files\CMake\bin"
$env:PATH = "$p;$env:PATH"
echo $p >> $env:GITHUB_PATH
cmake --version
if ($LASTEXITCODE -ne 0) { Write-Error "CMake install failed"; exit 1 }
} else { cmake --version }
- name: Download FlexML Runtime
shell: powershell
run: |
Invoke-WebRequest -Uri "${{ env.FLEXML_URL }}" -OutFile flexmlrt.zip
if (-Not (Test-Path "flexmlrt.zip")) { Write-Error "flexmlrt.zip not downloaded"; exit 1 }
if ((Get-Item "flexmlrt.zip").Length -eq 0) { Write-Error "flexmlrt.zip is empty"; exit 1 }
Write-Host "FlexML: $([math]::Round((Get-Item 'flexmlrt.zip').Length/1MB,2)) MB downloaded"
- name: Extract FlexML Runtime
shell: powershell
run: |
tar xvf flexmlrt.zip
if ($LASTEXITCODE -ne 0) { Write-Error "Extraction failed"; exit 1 }
$dirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" }
if (-not $dirs) { Write-Error "No flexmlrt directory found after extraction"; exit 1 }
Write-Host "Extracted: $($dirs.Name)"
- name: Setup FlexML, configure and build
shell: cmd
run: |
cd flexmlrt
call setup.bat
if errorlevel 1 ( echo ERROR: FlexML setup.bat failed! & exit /b 1 )
cd ..
cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON -DWHISPER_BUILD_SERVER=ON
if errorlevel 1 ( echo ERROR: CMake configure failed! & exit /b 1 )
cmake --build build --config Release -j
if errorlevel 1 ( echo ERROR: Build failed! & exit /b 1 )
- name: List build output
shell: powershell
run: |
if (Test-Path "build/bin/Release") {
Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length
} else { Write-Error "build/bin/Release not found"; exit 1 }
- name: Copy FlexML DLLs to build output
shell: powershell
run: |
$copied = 0
if (Test-Path "flexmlrt/bin") {
$d = Get-ChildItem -Path "flexmlrt/bin/*.dll" -ErrorAction SilentlyContinue
if ($d) { Copy-Item "flexmlrt/bin/*.dll" "build/bin/Release/" -Force; $copied += $d.Count }
}
if (Test-Path "flexmlrt/lib") {
$d = Get-ChildItem -Path "flexmlrt/lib/*.dll" -ErrorAction SilentlyContinue
if ($d) { Copy-Item "flexmlrt/lib/*.dll" "build/bin/Release/" -Force; $copied += $d.Count }
}
Write-Host "FlexML DLLs copied: $copied"
- name: Package
shell: powershell
run: |
$a = "whisper-${{ needs.determine-tag.outputs.version }}-windows-npu-x64.zip"
Compress-Archive -Path "build/bin/Release/*" -DestinationPath $a -Force
if (-not (Test-Path $a)) { Write-Error "Package creation failed"; exit 1 }
$mb = [math]::Round((Get-Item $a).Length/1MB,2)
Write-Host "Package: $a ($mb MB)"
"ARCHIVE=$a" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
- name: Build summary
shell: powershell
run: |
Write-Host "NPU build complete. Artifact: $env:ARCHIVE"
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 7. Metal — macOS (arm64)
# ════════════════════════════════════════════════════════════════════════════════
macos-metal:
runs-on: macos-latest
needs: determine-tag
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: brew install cmake ninja
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_MACOSX_RPATH=ON \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_RPATH="@loader_path" \
-DGGML_METAL=ON \
-DWHISPER_BUILD_EXAMPLES=ON \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_SERVER=ON
- name: Build
run: |
cmake --build build --config Release -j$(sysctl -n hw.logicalcpu) > build.log 2>&1
exit_code=$?
grep -E "error:|FAILED|Linking|Built target" build.log || true
if [ $exit_code -ne 0 ]; then
tail -100 build.log
exit $exit_code
fi
echo "Build succeeded."
- name: Verify build output
run: |
if [ ! -f build/bin/whisper-cli ]; then
echo "::error::whisper-cli not found"
ls -lh build/bin/ 2>/dev/null || true
exit 1
fi
if [ ! -f build/bin/whisper-server ]; then
echo "::error::whisper-server not found"
ls -lh build/bin/ 2>/dev/null || true
exit 1
fi
echo "--- build/bin ---"
ls -lh build/bin/
echo "--- macOS dylibs produced by build ---"
find build -name "*.dylib" -print | sort
echo "--- whisper-server dependencies before packaging ---"
otool -L build/bin/whisper-server
- name: Package
run: |
set -euo pipefail
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-darwin-metal-arm64.tar.gz"
STAGE="whisper-${VER}-darwin-metal-arm64"
rm -rf "$STAGE" "$ARCHIVE"
mkdir -p "$STAGE"
cp -R build/bin/* "$STAGE/" 2>/dev/null || true
# whisper-server depends on libwhisper / ggml dylibs that CMake may
# leave under build/src and build/ggml/src rather than build/bin.
# Package all produced dylibs next to the executables so @loader_path
# can resolve them on downstream machines and GitHub macOS runners.
while IFS= read -r lib; do
cp -P "$lib" "$STAGE/"
done < <(find build -name "*.dylib" -print | sort)
# Make dylib lookup portable inside the extracted archive.
for target in "$STAGE"/whisper-* "$STAGE"/*.dylib; do
[ -e "$target" ] || continue
install_name_tool -add_rpath "@loader_path" "$target" 2>/dev/null || true
if [ "${target##*.}" = "dylib" ] && [ ! -L "$target" ]; then
install_name_tool -id "@rpath/$(basename "$target")" "$target" 2>/dev/null || true
fi
while IFS= read -r dep; do
case "$dep" in
"$PWD"/build/*|/Users/runner/work/whisper.cpp-rocm/*)
install_name_tool -change "$dep" "@rpath/$(basename "$dep")" "$target" 2>/dev/null || true
;;
esac
done < <(otool -L "$target" 2>/dev/null | awk 'NR > 1 {print $1}')
done
echo "--- packaged files ---"
find "$STAGE" -maxdepth 1 -type f -o -type l | sort
echo "--- whisper-server dependencies after packaging ---"
otool -L "$STAGE/whisper-server"
otool -l "$STAGE/whisper-server" | grep -A2 LC_RPATH || true
if otool -L "$STAGE/whisper-server" | grep -q "/Users/runner/work/whisper.cpp-rocm"; then
echo "::error::whisper-server still references non-portable build paths"
exit 1
fi
if ! find "$STAGE" -maxdepth 1 \( -type f -o -type l \) -name "libwhisper*.dylib" | grep -q .; then
echo "::error::packaged archive is missing libwhisper dylib"
exit 1
fi
set +e
DYLD_LIBRARY_PATH="$PWD/$STAGE" "$STAGE/whisper-server" --help > whisper-server-smoke.log 2>&1
smoke_status=$?
set -e
cat whisper-server-smoke.log
if grep -q "Library not loaded" whisper-server-smoke.log; then
echo "::error::whisper-server has unresolved dylib dependencies"
exit 1
fi
echo "whisper-server smoke command exited with status ${smoke_status}"
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 8. CPU — Linux
# ════════════════════════════════════════════════════════════════════════════════
linux-cpu:
runs-on: ubuntu-latest
needs: determine-tag
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libsdl2-dev pkg-config
echo "cmake $(cmake --version | head -1)"
echo "gcc $(gcc --version | head -1)"
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_NATIVE=OFF \
-DGGML_AVX=ON \
-DGGML_AVX2=ON \
-DGGML_FMA=ON \
-DGGML_AVX512=OFF \
-DCMAKE_C_FLAGS="-march=x86-64-v3" \
-DCMAKE_CXX_FLAGS="-march=x86-64-v3" \
-DWHISPER_BUILD_EXAMPLES=ON \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_SERVER=ON
- name: Build
run: cmake --build build --config Release -j$(nproc)
- name: List build output
run: |
find build/bin -type f | sort
find build/bin -type f -executable | while read f; do ls -lh "$f"; done
- name: Package
run: |
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-linux-cpu-x86_64.tar.gz"
STAGE="whisper-${VER}-linux-cpu-x86_64"
mkdir -p "$STAGE"
cp -r build/bin/* "$STAGE/" 2>/dev/null || true
find build -name "*.so*" -exec cp {} "$STAGE/" \; 2>/dev/null || true
printf "whisper.cpp CPU build for Linux\nDate: %s\nArch: %s\n" \
"$(date -u +"%Y-%m-%d %H:%M:%S UTC")" "$(uname -m)" > "$STAGE/README.txt"
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════
# 8b. CPU / Vulkan — Linux musl (Alpine)
# Compiled inside an Alpine container so it links musl; libstdc++/libgcc are
# static so the archive is self-contained. arm64 drops the x86-only march/AVX
# flags. Runs on native ARM runners for arm64 (no QEMU).
# ════════════════════════════════════════════════════════════════════════════════
linux-musl-cpu:
runs-on: ${{ matrix.runner }}
needs: determine-tag
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
arch: x86_64
cpu_flags: "-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_AVX512=OFF -DCMAKE_C_FLAGS=-march=x86-64-v3 -DCMAKE_CXX_FLAGS=-march=x86-64-v3"
- runner: ubuntu-24.04-arm
arch: aarch64
cpu_flags: ""
steps:
- uses: actions/checkout@v4
- name: Build (Alpine / musl)
run: |
docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -euxc '
apk add --no-cache build-base cmake git sdl2-dev
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_NATIVE=OFF \
${{ matrix.cpu_flags }} \
-DWHISPER_BUILD_EXAMPLES=ON \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_SERVER=ON \
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \
-DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++"
cmake --build build --config Release -j"$(nproc)"
chmod -R a+rwX build
'
- name: Package
run: |
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-linux-musl-cpu-${{ matrix.arch }}.tar.gz"
STAGE="whisper-${VER}-linux-musl-cpu-${{ matrix.arch }}"
mkdir -p "$STAGE"
cp -r build/bin/* "$STAGE/" 2>/dev/null || true
find build -name "*.so*" -exec cp {} "$STAGE/" \; 2>/dev/null || true
# Rewrite the absolute build-tree rpath to $ORIGIN so the relocated musl
# binaries find their sibling .so files (musl doesn't search the exe dir).
if ! command -v patchelf >/dev/null; then sudo apt-get update -qq && sudo apt-get install -y -qq patchelf; fi
for f in "$STAGE"/*; do
[ -f "$f" ] && [ ! -L "$f" ] && file "$f" | grep -q ELF && patchelf --set-rpath '$ORIGIN' "$f" 2>/dev/null || true
done
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
linux-musl-vulkan:
runs-on: ${{ matrix.runner }}
needs: determine-tag
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
arch: x86_64
cpu_flags: "-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_AVX512=OFF -DCMAKE_C_FLAGS=-march=x86-64-v3 -DCMAKE_CXX_FLAGS=-march=x86-64-v3"
- runner: ubuntu-24.04-arm
arch: aarch64
cpu_flags: ""
steps:
- uses: actions/checkout@v4
- name: Build (Alpine / musl)
run: |
docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -euxc '
apk add --no-cache build-base cmake git sdl2-dev \
vulkan-loader-dev vulkan-headers glslang shaderc spirv-tools spirv-headers
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_NATIVE=OFF \
${{ matrix.cpu_flags }} \
-DGGML_VULKAN=ON \
-DWHISPER_BUILD_EXAMPLES=ON \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_SERVER=ON \
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \
-DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++"
cmake --build build --config Release -j"$(nproc)"
chmod -R a+rwX build
'
- name: Package
run: |
VER="${{ needs.determine-tag.outputs.version }}"
ARCHIVE="whisper-${VER}-linux-musl-vulkan-${{ matrix.arch }}.tar.gz"
STAGE="whisper-${VER}-linux-musl-vulkan-${{ matrix.arch }}"
mkdir -p "$STAGE"
cp -r build/bin/* "$STAGE/" 2>/dev/null || true
find build -name "*.so*" -exec cp {} "$STAGE/" \; 2>/dev/null || true
# Rewrite the absolute build-tree rpath to $ORIGIN so the relocated musl
# binaries find their sibling .so files (musl doesn't search the exe dir).
if ! command -v patchelf >/dev/null; then sudo apt-get update -qq && sudo apt-get install -y -qq patchelf; fi
for f in "$STAGE"/*; do
[ -f "$f" ] && [ ! -L "$f" ] && file "$f" | grep -q ELF && patchelf --set-rpath '$ORIGIN' "$f" 2>/dev/null || true
done
tar -czf "$ARCHIVE" "$STAGE"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
# ════════════════════════════════════════════════════════════════════════════════