Exception handling for the C backend used setjmp()/longjmp()
unconditionally. However, on POSIX systems, these functions save and
restore the signal mask, adding considerable overhead to exception
handling, even where no exceptions are involved. The compiler and
library now try to use either _setjmp()/_longjmp() or
sigsetjmp()/siglongjmp() where possible, marked by the defines
"nimRawSetjmp" and "nimSigSetjmp", respectively. The define
"nimStdSetjmp" can be used to revert to setjmp()/longjmp() instead.
When a C variable or macro is imported via an {.importc.} var or
let statement, but no definition is needed and the variable does
not have an initializer part, then there is also no need to generate
an #include for the associated header until and unless the variable
is actually used. The header is already generated upon use, but
unnecessarily also when the variable is defined.
This is an issue with the posix module in particular, where a lot
of unnecessary header files are being included because relevant
constants are defined via importc vars, and those header files
may not even be available on a given system.
This patch omits the generation of the #include directive for those
definitions where they aren't needed.
A staticExec() invocation that generated more than the internal
buffer size worth of output blocked because the compiler waited
for the process to terminate before reading the output.
The compiler hangs were caused by the interaction of tyError and the instantiation caches.
For procs, the cache wasn't able to find previously compiled proc featuring tyError in the signature.
For types, the unresolved type parameters leading to tyError were not replaced everywhere leading
to endless replaceTypeVarsT recursion for cyclic types.
The fix is still not perfect, because the handling of tyError in other places in the compiler doesn't seem
to be complete and the first test case now results in internal error (still, much better than a hang blocking
your IDE).
Variable declarations using a type class will be subject to type inference similar to the one
already present in type coercions and the return type inference.