@@ -178,3 +178,99 @@ jobs:
178
178
'"
179
179
180
180
181
+ linux_loongarch64_qemu :
182
+ # To enable this workflow on a fork, comment out:
183
+ if : github.repository == 'numpy/numpy'
184
+ runs-on : ubuntu-24.04
185
+ continue-on-error : true
186
+ strategy :
187
+ fail-fast : false
188
+ matrix :
189
+ BUILD_PROP :
190
+ - [
191
+ " loongarch64" ,
192
+ " loongarch64-linux-gnu" ,
193
+ " cnclarechen/numpy-loong64-debian:v1" ,
194
+ " -Dallow-noblas=true" ,
195
+ " test_kind or test_multiarray or test_simd or test_umath or test_ufunc" ,
196
+ " loong64"
197
+ ]
198
+ env :
199
+ TOOLCHAIN_NAME : ${{ matrix.BUILD_PROP[1] }}
200
+ DOCKER_CONTAINER : ${{ matrix.BUILD_PROP[2] }}
201
+ MESON_OPTIONS : ${{ matrix.BUILD_PROP[3] }}
202
+ RUNTIME_TEST_FILTER : ${{ matrix.BUILD_PROP[4] }}
203
+ ARCH : ${{ matrix.BUILD_PROP[5] }}
204
+ TERM : xterm-256color
205
+
206
+ name : " ${{ matrix.BUILD_PROP[0] }}"
207
+ steps :
208
+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
209
+ with :
210
+ submodules : recursive
211
+ fetch-tags : true
212
+
213
+ - name : Initialize binfmt_misc for qemu-user-static
214
+ run : |
215
+ docker run --rm --privileged loongcr.lcpu.dev/multiarch/archlinux --reset -p yes
216
+
217
+ - name : Install GCC cross-compilers
218
+ run : |
219
+ sudo apt update
220
+ sudo apt install -y ninja-build gcc-14-${TOOLCHAIN_NAME} g++-14-${TOOLCHAIN_NAME} gfortran-14-${TOOLCHAIN_NAME}
221
+
222
+ - name : Cache docker container
223
+ uses : actions/cache@v4.1.2
224
+ id : container-cache
225
+ with :
226
+ path : ~/docker_${{ matrix.BUILD_PROP[1] }}
227
+ key : container-${{ runner.os }}-${{ matrix.BUILD_PROP[1] }}-${{ matrix.BUILD_PROP[2] }}-${{ hashFiles('requirements/build_requirements.txt') }}
228
+
229
+ - name : Creates new container
230
+ if : steps.container-cache.outputs.cache-hit != 'true'
231
+ run : |
232
+ docker run --platform=linux/${ARCH} --name the_container --interactive \
233
+ -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
234
+ mkdir -p /lib64 && ln -s /host/lib64/ld-* /lib64/ &&
235
+ ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
236
+ ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
237
+ ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
238
+ rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc-14 /usr/bin/gcc &&
239
+ rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++-14 /usr/bin/g++ &&
240
+ rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran-14 /usr/bin/gfortran &&
241
+ rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
242
+ rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
243
+ rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
244
+ rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
245
+ rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
246
+ git config --global --add safe.directory /numpy &&
247
+ python -m pip install --break-system-packages -r /numpy/requirements/build_requirements.txt &&
248
+ python -m pip install --break-system-packages pytest pytest-xdist hypothesis typing_extensions
249
+ "
250
+ docker commit the_container the_container
251
+ mkdir -p "~/docker_${TOOLCHAIN_NAME}"
252
+ docker save -o "~/docker_${TOOLCHAIN_NAME}/the_container.tar" the_container
253
+
254
+ - name : Load container from cache
255
+ if : steps.container-cache.outputs.cache-hit == 'true'
256
+ run : docker load -i "~/docker_${TOOLCHAIN_NAME}/the_container.tar"
257
+
258
+ - name : Meson Build
259
+ run : |
260
+ docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
261
+ -v $(pwd):/numpy -v /:/host the_container \
262
+ /bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
263
+ cd /numpy/ && CXXFLAGS=\"-DHWY_COMPILE_ONLY_SCALAR\" spin build --clean -- ${MESON_OPTIONS}
264
+ '"
265
+
266
+ - name : Meson Log
267
+ if : always()
268
+ run : ' cat build/meson-logs/meson-log.txt'
269
+
270
+ - name : Run Tests
271
+ run : |
272
+ docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
273
+ -v $(pwd):/numpy -v /:/host the_container \
274
+ /bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
275
+ cd /numpy && spin test -- -k \"${RUNTIME_TEST_FILTER}\"
276
+ '"
0 commit comments