Skip to content

Commit 1be76e4

Browse files
authored
ci: add Linux cross-compile build (#12428)
1 parent b772394 commit 1be76e4

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build on Linux using cross-compiler
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
6+
jobs:
7+
ubuntu-latest-riscv64-cpu-cross:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Setup Riscv
13+
run: |
14+
sudo dpkg --add-architecture riscv64
15+
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
16+
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
17+
sudo apt-get clean
18+
sudo apt-get update
19+
sudo apt-get install -y --no-install-recommends \
20+
build-essential \
21+
gcc-14-riscv64-linux-gnu \
22+
g++-14-riscv64-linux-gnu
23+
24+
- name: Build
25+
run: |
26+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
27+
-DGGML_OPENMP=OFF \
28+
-DLLAMA_BUILD_EXAMPLES=ON \
29+
-DLLAMA_BUILD_TESTS=OFF \
30+
-DCMAKE_SYSTEM_NAME=Linux \
31+
-DCMAKE_SYSTEM_PROCESSOR=riscv64 \
32+
-DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
33+
-DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
34+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
35+
-DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
36+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
37+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
38+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
39+
40+
cmake --build build --config Release -j $(nproc)
41+
42+
ubuntu-latest-riscv64-vulkan-cross:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Setup Riscv
51+
run: |
52+
sudo dpkg --add-architecture riscv64
53+
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
54+
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
55+
sudo apt-get clean
56+
sudo apt-get update
57+
sudo apt-get install -y --no-install-recommends \
58+
build-essential \
59+
glslc \
60+
gcc-14-riscv64-linux-gnu \
61+
g++-14-riscv64-linux-gnu \
62+
libvulkan-dev:riscv64
63+
64+
- name: Build
65+
run: |
66+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
67+
-DGGML_VULKAN=ON \
68+
-DGGML_OPENMP=OFF \
69+
-DLLAMA_BUILD_EXAMPLES=ON \
70+
-DLLAMA_BUILD_TESTS=OFF \
71+
-DCMAKE_SYSTEM_NAME=Linux \
72+
-DCMAKE_SYSTEM_PROCESSOR=riscv64 \
73+
-DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
74+
-DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14 \
75+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
76+
-DCMAKE_FIND_ROOT_PATH=/usr/lib/riscv64-linux-gnu \
77+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
78+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
79+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
80+
81+
cmake --build build --config Release -j $(nproc)
82+
83+
ubuntu-latest-arm64-vulkan-cross:
84+
runs-on: ubuntu-latest
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
91+
- name: Setup Arm64
92+
run: |
93+
sudo dpkg --add-architecture arm64
94+
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
95+
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
96+
sudo apt-get clean
97+
sudo apt-get update
98+
sudo apt-get install -y --no-install-recommends \
99+
build-essential \
100+
glslc \
101+
crossbuild-essential-arm64 \
102+
libvulkan-dev:arm64
103+
104+
- name: Build
105+
run: |
106+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
107+
-DGGML_VULKAN=ON \
108+
-DGGML_OPENMP=OFF \
109+
-DLLAMA_BUILD_EXAMPLES=ON \
110+
-DLLAMA_BUILD_TESTS=OFF \
111+
-DCMAKE_SYSTEM_NAME=Linux \
112+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
113+
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
114+
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
115+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
116+
-DCMAKE_FIND_ROOT_PATH=/usr/lib/aarch64-linux-gnu \
117+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
118+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
119+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
120+
121+
cmake --build build --config Release -j $(nproc)

.github/workflows/build.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
push:
1111
branches:
1212
- master
13-
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
13+
paths: ['.github/workflows/build.yml', '.github/workflows/build-linux-cross.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
1414
pull_request:
1515
types: [opened, synchronize, reopened]
1616
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
@@ -606,6 +606,9 @@ jobs:
606606
-DGGML_SYCL_F16=ON
607607
cmake --build build --config Release -j $(nproc)
608608
609+
build-linux-cross:
610+
uses: ./.github/workflows/build-linux-cross.yml
611+
609612
macOS-latest-cmake-ios:
610613
runs-on: macos-latest
611614

0 commit comments

Comments
 (0)