我正在尝试在Alpine上编译Box86,这是一个使用musl libc实现而不是glibc的Linux发行版。完成46%时,编译将停止,并显示以下错误:
/home/newbyte/box86/src/emu/x86syscall.c:124:11: error: '__NR_gettimeofday' undeclared here (not in a function); did you mean 'gettimeofday'?
124 | { 78, __NR_gettimeofday, 2 },
| ^~~~~~~~~~~~~~~~~
| gettimeofday
/home/newbyte/box86/src/emu/x86syscall.c:210:12: error: '__NR_clock_gettime' undeclared here (not in a function); did you mean 'clock_gettime'?
210 | { 265, __NR_clock_gettime, 2 },
| ^~~~~~~~~~~~~~~~~~
| clock_gettime
/home/newbyte/box86/src/emu/x86syscall.c:211:12: error: '__NR_clock_getres' undeclared here (not in a function); did you mean 'clock_getres'?
211 | { 266, __NR_clock_getres, 2 },
| ^~~~~~~~~~~~~~~~~
| clock_getres自然,我的第一反应是查找这些名称并找出它们的用途,以便找到合适的替代品,但我没有这么做,这就引出了我的问题:这些__NR_-prefixed符号是什么,它们是做什么的?
发布于 2020-10-01 01:19:21
您似乎正在使用MUSL1.2.0或更高版本进行编译,它甚至在32位目标上也有64位time_t。这意味着32位系统调用(gettimeofday、clock_gettime、clock_getres)与musl对struct timeval和struct timespec的定义不兼容。为了防止意外调用那些类型错误的系统调用,相应的系统调用常量在此环境中不可用。
发布于 2020-09-30 01:53:00
以__NR_开头的标识符是定义系统调用号的常量的不可移植的、特定于Linux内核的名称。用户空间程序应该使用的可移植名称应以SYS_开头。
GNU libc允许不可移植的名称从内核的头文件传递到<sys/syscall.h>中;听起来像是musl libc不能。
https://stackoverflow.com/questions/64123402
复制相似问题