The _cas code in atomic.nim for tcc of windows is disabled.
elif defined(tcc) and not defined(windows):
when defined(amd64):
{.emit:"""
static int __tcc_cas(int *ptr, int oldVal, int newVal)
{
unsigned char ret;
__asm__ __volatile__ (
" lock\n"
" cmpxchgq %2,%1\n"
" sete %0\n"
: "=q" (ret), "=m" (*ptr)
: "r" (newVal), "m" (*ptr), "a" (oldVal)
: "memory");
if (ret)
return 0;
else
return 1;
}
""".}
else:
assert sizeof(int) == 4
{.emit:"""
static int __tcc_cas(int *ptr, int oldVal, int newVal)
{
unsigned char ret;
__asm__ __volatile__ (
" lock\n"
" cmpxchgl %2,%1\n"
" sete %0\n"
: "=q" (ret), "=m" (*ptr)
: "r" (newVal), "m" (*ptr), "a" (oldVal)
: "memory");
if (ret)
return 0;
else
return 1;
}
""".}
proc tcc_cas(p: ptr int; oldValue, newValue: int): bool
{.importc: "__tcc_cas", nodecl.}
The code seems fine, is there any potential problem with the code in windows?
TinyC on Windows works well.
The TinyC compile speed and code optimization is not as good as vc, but it is so small, the total size of tcc compiler and header/lib file is no more than 2M.
It can compile the nim compiler successfully!
I've been trying to enable tcc in parallel when I noticed #7750 and this thread. I have made some minor changes and most of the Nim test cases pass on Windows. There are 22 failing tests (results here, download locally and load to use the filters) and surely one issue with threading.
This test case hangs forever. So does my console text editor snip once you run it so I think there's still some issues to work out.
No doubt tcc only supports Nim's C backend but is super small, fast and might be worth consideration as the starter compiler to try Nim out.