弹霄博科

小谈谈一亩三分地



移植 HUSTOJ judge_clinet 到 LoongArch64


发布日期: 2025/03/03
更新日期: 2025/03/03
作者: 小谈谈
分类: 龙芯
标签: 龙芯, 国产化
阅读时间: 2 分钟
字数: 317 字


HUSTOJ 是一款流行的OJ系统,跨平台、易安装、有题库、二次开发门槛低。具有多个分支,我参与移植的是 zhblue/hustoj 张老师维护的分支。

大概记录一下移植的过程。目前该 PR 已经合并到了 master 上,当前实测是支持 C/C++ 判题,后续根据上游支持情况继续适配其他语言。

参考了 [[原]给HUSTOJ用户提供的源码阅读与修改建议](http://www.hustoj.com/?p=11) 中关于 judgeclient 的代码解读,大概把握了判题机的处理思路。

1、关于 LoongArch64 的系统调用寄存器的位置信息。参考了nolibc/arch-loongarch.h

```
// https://github.com/torvalds/linux/blob/master/tools/include/nolibc/arch-loongarch.h
/* Syscalls for LoongArch :
* - stack is 16-byte aligned
* - syscall number is passed in a7
* - arguments are in a0, a1, a2, a3, a4, a5
* - the system call is performed by calling "syscall 0"
* - syscall return comes in a0
* - the arguments are cast to long and assigned into the target
* registers which are then simply passed as registers to the asm code,
* so that we don't have to experience issues with register constraints.
*/
```

这段注释很明确的描述了 LoongArch64 的系统调用寄存器的位置信息。

2、关于 LoongArch64 系统调用号的描述。参考了 hrw/syscalls-table 这个项目,这个项目描述了各个平台的系统调用号信息,并将其组织成了表格。

Link:https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html

3、判题测试(3C6000/S + 128G 内存):

[图片: 20250303224203]
https://static.txisfine.cn/upload/20250303224203.png/pkwatermark

提交 2280,AWT 106.38s

[图片: 20250303224029]
https://static.txisfine.cn/upload/20250303224029.png/pk_watermark

国产加油!信创加油~