1
1
name : Build
2
2
3
3
on :
4
+ workflow_dispatch :
4
5
push :
5
6
branches :
6
7
- master
7
8
pull_request :
8
9
branches :
9
10
- master
10
11
12
+ env :
13
+ submodule_paths : |
14
+ binutils
15
+ dejagnu
16
+ gcc
17
+ gdb
18
+ glibc
19
+ llvm
20
+ musl
21
+ newlib
22
+ pk
23
+ qemu
24
+ spike
25
+ uclibc-ng
26
+ .git/modules
27
+
11
28
jobs :
29
+ submodule_cache :
30
+ name : Initialize submodule cache
31
+ runs-on : ubuntu-latest
32
+ outputs :
33
+ key : ${{ steps.keygen.outputs.smcache_key }}
34
+ steps :
35
+ - uses : actions/checkout@v4
36
+
37
+ - name : Remove unneeded frameworks to recover disk space
38
+ run : sudo ./.github/cleanup-rootfs.sh
39
+
40
+ - name : Generate submodule cache key
41
+ id : keygen
42
+ run : echo "smcache_key=smcache-$(printf $(git submodule | sha1sum))" >> $GITHUB_OUTPUT
43
+
44
+ - name : Setup submodule cache
45
+ id : smcache
46
+ uses : actions/cache@v4
47
+ with :
48
+ path : ${{ env.submodule_paths }}
49
+ key : ${{ steps.keygen.outputs.smcache_key }}
50
+
51
+ - name : Checkout required submodules
52
+ if : steps.smcache.outputs.cache-hit != 'true'
53
+ run : git submodule update --init -j $(nproc) --depth 1 $(echo ${submodule_paths} | sed '$d' | tr '\n' ' ')
54
+
55
+ - name : Storage size optimization
56
+ if : steps.smcache.outputs.cache-hit != 'true'
57
+ run : |
58
+ git submodule foreach 'git maintenance run'
59
+
12
60
build :
13
61
runs-on : ${{ matrix.os }}
62
+ needs : [submodule_cache]
63
+ env :
64
+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
14
65
strategy :
15
66
matrix :
16
67
os : [ubuntu-22.04, ubuntu-24.04]
@@ -23,47 +74,46 @@ jobs:
23
74
- mode : uclibc
24
75
compiler : llvm
25
76
steps :
26
- - name : Remove unneeded frameworks to recover disk space
27
- run : |
28
- echo "-- Before --"
29
- df -h
30
- sudo rm -rf /usr/share/dotnet
31
- sudo rm -rf /usr/local/lib/android
32
- echo "-- After --"
33
- df -h
34
-
35
77
- uses : actions/checkout@v4
36
78
79
+ - name : Remove unneeded frameworks to recover disk space
80
+ run : sudo ./.github/cleanup-rootfs.sh
81
+
37
82
- name : install dependencies
38
83
run : sudo ./.github/setup-apt.sh
39
84
85
+ - name : Load submodule cache
86
+ uses : actions/cache/restore@v4
87
+ with :
88
+ path : ${{ env.submodule_paths }}
89
+ key : ${{ env.smcache_key }}
90
+
40
91
- name : build toolchain
41
92
run : |
42
93
TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n"))
43
- BUILD_TOOLCHAIN="./configure --prefix=/opt /riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]}"
94
+ BUILD_TOOLCHAIN="./configure --prefix=/mnt /riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]}"
44
95
if [ "${{ matrix.compiler }}" == "llvm" ]; then # build toolchain with llvm
45
96
$BUILD_TOOLCHAIN --enable-llvm
46
97
else
47
98
$BUILD_TOOLCHAIN
48
99
fi
49
- sudo make -j $(nproc) ${{ matrix.mode }}
100
+ sudo mkdir /mnt/riscv
101
+ sudo chown runner:runner /mnt/riscv
102
+ make -j $(nproc) ${{ matrix.mode }}
103
+
104
+ - name : tarball build
105
+ run : |
106
+ du -s -h /mnt/riscv
107
+ ./.github/dedup-dir.sh /mnt/riscv/
108
+ XZ_OPT="-e -T0" tar cJvf riscv.tar.xz -C /mnt/ riscv/
50
109
51
110
- name : make report
52
111
if : |
53
112
matrix.os == 'ubuntu-24.04'
54
113
&& (matrix.mode == 'linux' || matrix.mode == 'newlib')
55
114
&& matrix.compiler == 'gcc'
56
115
run : |
57
- sudo make report-${{ matrix.mode }} -j $(nproc)
58
-
59
- - name : recover space
60
- run : |
61
- sudo du -hs / 2> /dev/null || true
62
- sudo rm -rf binutils dejagnu gcc gdb glibc llvm musl newlib pk qemu spike uclibc-ng || true
63
- sudo du -hs / 2> /dev/null || true
64
-
65
- - name : tarball build
66
- run : tar czvf riscv.tar.gz -C /opt/ riscv/
116
+ make report-${{ matrix.mode }} -j $(nproc)
67
117
68
118
- name : generate prebuilt toolchain name
69
119
id : toolchain-name-generator
@@ -84,35 +134,40 @@ jobs:
84
134
- uses : actions/upload-artifact@v4
85
135
with :
86
136
name : ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}
87
- path : riscv.tar.gz
137
+ path : riscv.tar.xz
88
138
89
139
test-sim :
90
140
runs-on : ${{ matrix.os }}
141
+ needs : [submodule_cache]
142
+ env :
143
+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
91
144
strategy :
92
145
matrix :
93
146
os : [ubuntu-24.04]
94
147
mode : [newlib]
95
148
target : [rv64gc-lp64d]
96
149
sim : [spike]
97
150
steps :
98
- - name : Remove unneeded frameworks to recover disk space
99
- run : |
100
- echo "-- Before --"
101
- df -h
102
- sudo rm -rf /usr/share/dotnet
103
- sudo rm -rf /usr/local/lib/android
104
- echo "-- After --"
105
- df -h
106
-
107
151
- uses : actions/checkout@v4
108
152
153
+ - name : Remove unneeded frameworks to recover disk space
154
+ run : sudo ./.github/cleanup-rootfs.sh
155
+
109
156
- name : install dependencies
110
157
run : sudo ./.github/setup-apt.sh
111
158
159
+ - name : Load submodule cache
160
+ uses : actions/cache/restore@v4
161
+ with :
162
+ path : ${{ env.submodule_paths }}
163
+ key : ${{ env.smcache_key }}
164
+
112
165
- name : build toolchain
113
166
run : |
114
167
TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n"))
115
- ./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --with-sim=${{ matrix.sim }}
168
+ ./configure --prefix=/mnt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --with-sim=${{ matrix.sim }}
169
+ sudo mkdir /mnt/riscv
170
+ sudo chown runner:runner /mnt/riscv
116
171
make -j $(nproc) ${{ matrix.mode }}
117
172
118
173
- name : make report
@@ -121,38 +176,46 @@ jobs:
121
176
build-multilib :
122
177
if : ${{ false }} # Disable until multilib errors are triaged
123
178
runs-on : ${{ matrix.os }}
179
+ needs : [submodule_cache]
180
+ env :
181
+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
124
182
strategy :
125
183
matrix :
126
184
os : [ubuntu-24.04]
127
185
mode : [newlib, linux]
128
186
target : [rv64gc-lp64d]
129
187
steps :
130
- - name : Remove unneeded frameworks to recover disk space
131
- run : |
132
- echo "-- Before --"
133
- df -h
134
- sudo rm -rf /usr/share/dotnet
135
- sudo rm -rf /usr/local/lib/android
136
- echo "-- After --"
137
- df -h
138
-
139
188
- uses : actions/checkout@v4
140
189
190
+ - name : Remove unneeded frameworks to recover disk space
191
+ run : sudo ./.github/cleanup-rootfs.sh
192
+
141
193
- name : install dependencies
142
194
run : sudo ./.github/setup-apt.sh
143
195
196
+ - name : Load submodule cache
197
+ uses : actions/cache/restore@v4
198
+ with :
199
+ path : ${{ env.submodule_paths }}
200
+ key : ${{ env.smcache_key }}
201
+
144
202
- name : build toolchain
145
203
run : |
146
204
TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n"))
147
- ./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --enable-multilib
148
- sudo make -j $(nproc) ${{ matrix.mode }}
205
+ ./configure --prefix=/mnt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --enable-multilib
206
+ sudo mkdir /mnt/riscv
207
+ sudo chown runner:runner /mnt/riscv
208
+ make -j $(nproc) ${{ matrix.mode }}
149
209
150
- - name : make report
210
+ - name : tarball build
151
211
run : |
152
- sudo make report-${{ matrix.mode }} -j $(nproc)
212
+ du -s -h /mnt/riscv
213
+ ./.github/dedup-dir.sh /mnt/riscv/
214
+ XZ_OPT="-e -T0" tar cJvf riscv.tar.xz -C /mnt/ riscv/
153
215
154
- - name : tarball build
155
- run : tar czvf riscv.tar.gz -C /opt/ riscv/
216
+ - name : make report
217
+ run : |
218
+ make report-${{ matrix.mode }} -j $(nproc)
156
219
157
220
- name : generate prebuilt toolchain name
158
221
id : toolchain-name-generator
@@ -173,4 +236,4 @@ jobs:
173
236
- uses : actions/upload-artifact@v4
174
237
with :
175
238
name : ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }}
176
- path : riscv.tar.gz
239
+ path : riscv.tar.xz
0 commit comments