You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: sp_int.c MIPS assembly fails to build on MIPS Release 6 ('$hi' cannot be clobbered) #11953
The SP math MIPS assembly in wolfcrypt/src/sp_int.c (the WOLFSSL_SP_MIPS64 and WOLFSSL_SP_MIPS blocks) multiplies with multu/dmultu, reads the result with mflo/mfhi, and lists $hi/$lo as clobbers. MIPS Release 6 removed these instructions and the hi/lo registers, so the build fails for any r6 CPU (mips32r6, mips64r6, I6400, P6600, ...).
configure selects WOLFSSL_SP_MIPS64/WOLFSSL_SP_MIPS from the host triplet alone (*mips64* / *mips*), so this happens with the default options; the only workaround is --disable-asm.
Suggested fix: only build the MIPS/MIPS64 assembly when the compiler's __mips_isa_rev is undefined or less than 6, and use the existing generic C code otherwise. I tested this locally on master with --enable-all. The r6 builds then succeed, with GCC emitting the r6 multiply instructions (mulu/muhu, dmulu/dmuhu). wolfcrypt/test/testwolfcrypt passes under qemu-user on mips64r6el n32 (-cpu I6400) and mips32r6el (-cpu mips32r6-generic). A pre-r6 mips64el build still uses the assembly and also passes. I'm not able to sign the contributor agreement, so I'm reporting this as an issue as described in CONTRIBUTING.md rather than opening a PR.
This report was prepared with the help of an AI assistant (Claude); I reviewed and tested it.
Reproduction steps
Get a MIPS r6 cross toolchain, e.g. Bootlin's mips64r6el-n32 glibc or mips32r6el glibc toolchain.
./configure --host=mips64el-linux-gnu CC=<r6 toolchain gcc> (or --host=mipsel-linux-gnu for MIPS32 r6); --enable-all also fails.
make
Relevant log output
wolfcrypt/src/sp_int.c:4217:5: error: the register '$hi' cannot be clobbered in'asm'for the current target
4217 | __asm__ __volatile__ ( \
| ^~~~~~~
wolfcrypt/src/sp_int.c:18081:13: note: in expansion of macro 'SP_ASM_MUL_ADD'
MIPS32 r6:
wolfcrypt/src/sp_int.c:4418:5: error: the register '%hi' cannot be clobbered in'asm'for the current target
Thanks Sean! I tested PR #11966 (83f0f88) with GCC (Bootlin toolchains, as used by Buildroot), --enable-all --disable-shared, running wolfcrypt/test/testwolfcrypt under qemu-user:
mips64r6el, n32 ABI (WOLFSSL_SP_MIPS64, qemu -cpu I6400): builds; sp_int.o uses dmulu/dmuhu, no dmultu/mflo/mfhi; all tests pass.
Activity
SparkiDev commentedon Nov 3, 2026
Hi @yegorich
I've update sp_int.c in PR: #11966
Let me know if this works for you.
Thanks,
Sean
yegorich commentedon Nov 3, 2026
Thanks Sean! I tested PR #11966 (83f0f88) with GCC (Bootlin toolchains, as used by Buildroot),
--enable-all --disable-shared, runningwolfcrypt/test/testwolfcryptunder qemu-user:WOLFSSL_SP_MIPS64, qemu-cpu I6400): builds;sp_int.ousesdmulu/dmuhu, nodmultu/mflo/mfhi; all tests pass.WOLFSSL_SP_MIPS, qemu-cpu mips32r6-generic): builds; usesmulu/muhu; all tests pass.-cpu 5KEf, regression check): code unchanged (dmultu/mflo/mfhi); all tests pass.So it works for me. Once it's in a release, Buildroot can enable the assembly on R6 again.
SparkiDev commentedon Nov 4, 2026
Thanks @yegorich,
I'll try to get the PR merged as quickly as possible!
Sean