hustOJ 添加 golang 支持
hustOJ 支持Go1.7.1是否为docker环境不重要,此处所有内容均为docker中执行,普通主机手动安装则更加如此 建议在docker中执行,因为OJ为严控恶意权限,judge_client做了很多特殊指令 hustOJ 虽然有部分代码涉及到了golang 本次支持的是go 1.7.1 关键改动都在core组件里面的judge_client 系统修改
文件 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-updates main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-backports main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security jessie/updates main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security jessie/updates main contrib non-free 安装 golang apt-get install golang-1.7.1 改动点:
在数组里面增加 186 信号,baidu说,此信号实际对应值是:186 gettid 如果不增加,golang编译的程序会被judge_client fork 出的parent监控并停止。 int LANG_GOV[256]={0,1,9,11,13,14,56,59,131,158,186,202,204,228,231,0};
在 void copy_go_runtime(char *work_dir) { char envbuff[1024] = {0}; copy_shell_runtime(work_dir); execute_cmd("/bin/mkdir %s/usr",work_dir); execute_cmd("/bin/mkdir %s/usr/lib",work_dir); execute_cmd("/bin/mkdir %s/usr/bin",work_dir); // execute_cmd("/bin/cp /usr/lib/go-1.7/bin/go %s/usr/bin/",work_dir); putenv((char *)"GOROOT=/usr/lib/go-1.7"); sprintf(envbuff,"GOPATH=%s",work_dir); putenv(envbuff); }
// 此处为方便,直接写死了go-1.7的绝对位置 // 主要judge_client在执行真正的程序前,会先执行很多环境准备 // 甚至包括chroot指令 // 最终导致环境混乱 const char *CP_GO[] = { "/usr/lib/go-1.7/bin/go","build","-o","Main","Main.go",NULL };
int main(int argc,char **argv) { // init_parameters // init mysql // get_solution_info // compile // 根据逻辑相关部分新增如下函数 // copy_go_runtime
cd /home/judge/src/core/judge_client/ make
可以用go源码提交一份其它语言的程序到题目中,此程序会被存储到数据库, 登录数据库,修改其语言为go mysql -udebian-sys-maint -paaabbb > use jol; > update solution set language=17 where solution_id = 1008; > commit;
然后手动执行 judge_client /home/judge/src/core/judge_client/judge_client 1008 1 /home/judge/ debug 如果,最后输出 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |