I'm trying to compile Box86 on Alpine Linux, a Linux distribution which uses the musl libc implementation rather than glibc. At 46% completion, the compilation halts with the following errors:
/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
Naturally, my first instinct was to look these names up and figure out what they are for so that I can find a suitable replacement, but I had little luck doing so, which leads me to my question: What are these __NR_
-prefixed symbols, and what do they do?
You seem to be compiling using musl 1.2.0 or later, which has a 64-bit
time_t
even on 32-bit targets. This means that the 32-bit system calls (gettimeofday
,clock_gettime
,clock_getres
) are not compatible with musl's definition ofstruct timeval
andstruct timespec
. To protect from accidentally calling those system calls with the wrong types, the corresponding system call constants are not available in this environment.