diff --git a/lib/system/threads.nim b/lib/system/threads.nim index 8041b8a8f4..754d071811 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -256,8 +256,9 @@ when emulatedThreadVars: # we preallocate a fixed size for thread local storage, so that no heap # allocations are needed. Currently less than 7K are used on a 64bit machine. # We use ``float`` for proper alignment: +const nimTlsSize {.intdefine.} = 8000 type - ThreadLocalStorage = array[0..1_000, float] + ThreadLocalStorage = array[0..(nimTlsSize div sizeof(float)), float] PGcThread = ptr GcThread GcThread {.pure, inheritable.} = object @@ -323,7 +324,11 @@ when not defined(useNimRtl): when emulatedThreadVars: if nimThreadVarsSize() > sizeof(ThreadLocalStorage): - echo "too large thread local storage size requested" + echo "too large thread local storage size requested ", + "(", nimThreadVarsSize(), "/", sizeof(ThreadLocalStorage), "). ", + "Use -d:\"nimTlsSize=", nimThreadVarsSize(), + "\" to preallocate sufficient storage." + quit 1 when hasSharedHeap and not defined(boehmgc) and not defined(gogc) and not defined(nogc):