From 5f5f2126d69478fa116a0c746a4871e5f42a4084 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 15 Apr 2023 04:52:35 +0800 Subject: [PATCH] fixes #18146; fixes #19372; disable tlsEmulation on windows; static link pthreads with mingw (#21668) * fixes #18146; disable tlsEmulation on windows; static link libwinthreads DLL * whatever --- compiler/nim.cfg | 1 - config/nim.cfg | 2 +- lib/std/typedthreads.nim | 4 ++++ tests/config.nims | 2 -- tests/ic/config.nims | 2 -- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/nim.cfg b/compiler/nim.cfg index b9c8fdc0848e3..5e70c2975e2d1 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -14,7 +14,6 @@ threads:off @if windows: cincludes: "$lib/wrappers/libffi/common" - tlsEmulation:off @end define:useStdoutAsStdmsg diff --git a/config/nim.cfg b/config/nim.cfg index ef93ec99e4e5a..ad6129c6dab23 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -179,7 +179,7 @@ nimblepath="$home/.nimble/pkgs/" # Configuration for the GNU C/C++ compiler: @if windows: #gcc.path = r"$nim\dist\mingw\bin" - @if gcc or tcc: + @if tcc: tlsEmulation:on @end @end diff --git a/lib/std/typedthreads.nim b/lib/std/typedthreads.nim index 8359ca353a63e..6cc5dd9e0a8dc 100644 --- a/lib/std/typedthreads.nim +++ b/lib/std/typedthreads.nim @@ -34,6 +34,10 @@ ## ## deinitLock(L) + +when defined(windows) and defined(gcc) and (not compileOption("tlsEmulation")): + {.passl: "-Wl,-Bstatic -lpthread -Wl,-Bdynamic".} + import std/private/[threadtypes] export Thread diff --git a/tests/config.nims b/tests/config.nims index 4bcd671433d2e..3772648e6158f 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -40,8 +40,6 @@ switch("define", "nimPreviewDotLikeOps") switch("define", "nimPreviewJsonutilsHoleyEnum") switch("define", "nimPreviewHashRef") switch("define", "nimPreviewRangeDefault") -when defined(windows): - switch("tlsEmulation", "off") switch("warningAserror", "UnnamedBreak") switch("legacy", "verboseTypeMismatch") diff --git a/tests/ic/config.nims b/tests/ic/config.nims index a522efb0dbfc6..a622ec309169c 100644 --- a/tests/ic/config.nims +++ b/tests/ic/config.nims @@ -1,3 +1 @@ -when defined(windows): - --tlsEmulation:off --mm:refc