This is my first few hours working with Nim. On my Debian machine with Linux 5.7, the following Nim file compiles successfully:
import rlocks
var x: RLock
x.initRLock()
echo $tryAcquire(x) # prints out "true"
but the following fails to compile:
import rlocks
var x: RLock
x.initRLock()
What is going on here? I'd expect that the second file also compiles but prints/does nothing at runtime.
$ nim --threads:on compile running.nim
Hint: used config file '/home/user/nim-1.2.6-linux_x64/nim-1.2.6/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: running [Processing]
Hint: rlocks [Processing]
CC: stdlib_locks.nim
CC: stdlib_sharedlist.nim
CC: stdlib_system.nim
CC: stdlib_rlocks.nim
/home/user/.cache/nim/running_d/stdlib_rlocks.nim.c: In function ‘SysLockType_Reentrant__COVWxdEUwuYKuSPC6Cp9c5A’:
/home/user/.cache/nim/running_d/stdlib_rlocks.nim.c:28:11: error: ‘PTHREAD_MUTEX_RECURSIVE’ undeclared (first use in this function)
result = PTHREAD_MUTEX_RECURSIVE;
^~~~~~~~~~~~~~~~~~~~~~~
/home/user/.cache/nim/running_d/stdlib_rlocks.nim.c:28:11: note: each undeclared identifier is reported only once for each function it appears in
Error: execution of an external compiler program 'gcc -c -w -pthread -I'/home/user/nim-1.2.6-linux_x64/nim-1.2.6/lib' -I'/home/user/nim-1.2.6-linux_x64/nim-1.2.6/bin' -o /home/user/.cache/nim/running_d/stdlib_rlocks.nim.c.o /home/user/.cache/nim/running_d/stdlib_rlocks.nim.c' failed with exit code: 1
$ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ldd --version
ldd (Debian GLIBC 2.28-10) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
$ nim --version
Nim Compiler Version 1.2.6 [Linux: amd64]
Compiled at 2020-07-29
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
$ uname --all
Linux user 5.7.0-3-amd64 #1 SMP Debian 5.7.17-1 (2020-08-23) x86_64 GNU/Linux