From e49c095356754818b01677f47182a29f7e4d3ad1 Mon Sep 17 00:00:00 2001 From: jinboson Date: Mon, 13 Jan 2025 17:08:11 +0800 Subject: [PATCH] Add qemu test for LoongArch (#3833) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * LoongArch: fix build error with gcc14 With CFLAGS=-Werror, gcc14 outputs errors like below: In file included from ./codec/common/inc/loongson_intrinsics.h:63, from codec/common/loongarch/mc_horver_lsx.c:46: In function ‘__lsx_vilvl_h’, inlined from ‘McHorVer22WidthEq4_lsx’ at codec/common/loongarch/mc_horver_lsx.c:521:5, inlined from ‘McHorVer22WidthEq9_lsx’ at codec/common/loongarch/mc_horver_lsx.c:646:3: /usr/lib/gcc-cross/loongarch64-linux-gnu/14/include/lsxintrin.h:1916:19: warning: ‘dst6’ may be used uninitialized [-Wmaybe-uninitialized] 1916 | return (__m128i)__builtin_lsx_vilvl_h ((v8i16)_1, (v8i16)_2); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ codec/common/loongarch/mc_horver_lsx.c: In function ‘McHorVer22WidthEq9_lsx’: codec/common/loongarch/mc_horver_lsx.c:486:47: note: ‘dst6’ was declared here 486 | __m128i dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; | ^~~~ Note: errors are truncated because too long. * Run the unit tests on loongarch using qemu-loongarch64-static --- .github/workflows/build.yaml | 12 ++++++++++++ codec/common/loongarch/mc_horver_lsx.c | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9e03b0c3d4..12fee104c2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -108,6 +108,18 @@ jobs: - run: CFLAGS=-Werror make -j$(nproc) ARCH=aarch64 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ - run: qemu-aarch64 -L /usr/aarch64-linux-gnu/ ./codec_unittest + linux-cross-loongarch64: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v3 + - run: sudo apt-get update -qq + - run: sudo apt-get install -qq gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu qemu-user-static + - run: loongarch64-linux-gnu-g++-14 --version + - run: make gmp-bootstrap + - run: make gtest-bootstrap + - run: CFLAGS=-Werror make -j$(nproc) ARCH=loongarch64 CC=loongarch64-linux-gnu-gcc-14 CXX=loongarch64-linux-gnu-g++-14 + - run: qemu-loongarch64-static -L /usr/loongarch64-linux-gnu/ ./codec_unittest + macos-cross-arm64: runs-on: macos-latest steps: diff --git a/codec/common/loongarch/mc_horver_lsx.c b/codec/common/loongarch/mc_horver_lsx.c index a69d5f657f..6fdcb27046 100644 --- a/codec/common/loongarch/mc_horver_lsx.c +++ b/codec/common/loongarch/mc_horver_lsx.c @@ -483,7 +483,7 @@ void McHorVer22WidthEq4_lsx(const uint8_t *pSrc, int32_t iSrcStride, uint8_t *pD uint8_t *psrc = (uint8_t*)pSrc - 2; __m128i src0, src1, src2, src3, src4, src5; __m128i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, out0_l, out0_h; - __m128i dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + __m128i dst0, dst1, dst2, dst3, dst4={0}, dst5={0}, dst6={0}, dst7={0}; v8i16 mask1 = {3, 4, 5, 6, 7, 8, 9, 10}; for (int i = 0; i < iHeight; i++) { DUP4_ARG2(__lsx_vldx, @@ -565,7 +565,7 @@ void McHorVer22WidthEq5_lsx(const uint8_t *pSrc, int32_t iSrcStride, uint8_t *pD uint8_t *psrc = (uint8_t*)pSrc - 2; __m128i src0, src1, src2, src3, src4, src5; __m128i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, out0_l, out0_h; - __m128i dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + __m128i dst0, dst1, dst2, dst3, dst4={0}, dst5={0}, dst6={0}, dst7={0}; v8i16 mask1 = {3, 4, 5, 6, 7, 8, 9, 10}; for (int i = 0; i < iHeight; i++) { DUP4_ARG2(__lsx_vldx,