From 97259a5ab37892bedca64b14ffc6e0b7d25dd789 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:16:54 +0800 Subject: [PATCH] fixes #19713; Revert "Remove tlsEmulation enabled from Windows + GCC config" (#19119) (#20327) * Revert "Remove tlsEmulation enabled from Windows + GCC config (#19119) [backport:1.6]" This reverts commit 77b696c2c92b5f478526290c5e184a4c41060f7b. * increase nimTlsSize to 48000 * enable for windows * fixes tests * fixes tlsEmulation:on --- compiler/nim.cfg | 1 + compiler/ropes.nim | 8 ++++++-- config/nim.cfg | 3 +++ tests/config.nims | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/nim.cfg b/compiler/nim.cfg index 7ed70fb5f2a3f..853a657b391e5 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -11,6 +11,7 @@ define:nimPreviewSlimSystem @if windows: cincludes: "$lib/wrappers/libffi/common" + tlsEmulation:off @end define:useStdoutAsStdmsg diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 3a2fbe44e2739..b84cfad527ed4 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -86,8 +86,12 @@ proc newRope(data: string = ""): Rope = result.L = -data.len result.data = data -var - cache {.threadvar.} : array[0..2048*2 - 1, Rope] +when compileOption("tlsEmulation"): # fixme: be careful if you want to make ropes support multiple threads + var + cache: array[0..2048*2 - 1, Rope] +else: + var + cache {.threadvar.} : array[0..2048*2 - 1, Rope] proc resetRopeCache* = for i in low(cache)..high(cache): diff --git a/config/nim.cfg b/config/nim.cfg index fd2642391b646..55b7a41c15c4c 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -169,6 +169,9 @@ nimblepath="$home/.nimble/pkgs/" # Configuration for the GNU C/C++ compiler: @if windows: #gcc.path = r"$nim\dist\mingw\bin" + @if gcc or tcc: + tlsEmulation:on + @end @end gcc.maxerrorsimpl = "-fmax-errors=3" diff --git a/tests/config.nims b/tests/config.nims index 894c4bea0adc1..5195ebcafbc0e 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -40,3 +40,5 @@ switch("define", "nimPreviewFloatRoundtrip") switch("define", "nimPreviewDotLikeOps") switch("define", "nimPreviewJsonutilsHoleyEnum") switch("define", "nimPreviewHashRef") +when defined(windows): + switch("tlsEmulation", "off")