1

我正在尝试在 Alpine Linux 上编译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_前缀的符号是什么,以及他们在做什么?

4

2 回答 2

1

您似乎正在使用 musl 1.2.0 或更高版本进行编译,time_t即使在 32 位目标上也有 64 位。这意味着 32 位系统调用 ( gettimeofday, clock_gettime, ) 与 musl 的andclock_getres定义不兼容。为了防止意外调用具有错误类型的系统调用,相应的系统调用常量在此环境中不可用。struct timevalstruct timespec

于 2020-09-30T17:19:20.757 回答
0

以 开头的标识符__NR_是定义系统调用号的常量的不可移植的、Linux 内核特定的名称。用户空间程序应该使用的可移植名称,SYS_而不是开始。

GNU libc 允许不可移植的名称从内核的头文件传递到<sys/syscall.h>; 听起来 musl libc 没有。__NR_尝试在SYS_整个文件中进行搜索和替换更改。

于 2020-09-29T17:52:59.893 回答