From bca98f0120b311c5367ba65ee44dfd8013da5124 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 10:12:02 +0800 Subject: [PATCH 01/17] default threads on --- config/nim.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/nim.cfg b/config/nim.cfg index 59d7f48d29e3b..8723987cd3b60 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -16,6 +16,8 @@ cc = gcc hint[LineTooLong]=off #hint[XDeclaredButNotUsed]=off +threads:on + # Examples of how to setup a cross-compiler: # Cross-compiling for Raspberry Pi. From ca6510a12f053db94713b63bc18a74563ff80eae Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 10:18:52 +0800 Subject: [PATCH 02/17] make rst gcsafe --- lib/packages/docutils/rst.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index a04eb696fb384..7919537673f4d 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -2822,7 +2822,7 @@ type DirFlag = enum hasArg, hasOptions, argIsFile, argIsWord DirFlags = set[DirFlag] - SectionParser = proc (p: var RstParser): PRstNode {.nimcall.} + SectionParser = proc (p: var RstParser): PRstNode {.nimcall, gcsafe.} proc parseDirective(p: var RstParser, k: RstNodeKind, flags: DirFlags): PRstNode = ## Parses arguments and options for a directive block. @@ -2869,7 +2869,7 @@ proc indFollows(p: RstParser): bool = result = currentTok(p).kind == tkIndent and currentTok(p).ival > currInd(p) proc parseBlockContent(p: var RstParser, father: var PRstNode, - contentParser: SectionParser): bool = + contentParser: SectionParser): bool {.gcsafe.} = ## parse the final content part of explicit markup blocks (directives, ## footnotes, etc). Returns true if succeeded. if currentTok(p).kind != tkIndent or indFollows(p): @@ -3123,7 +3123,7 @@ proc prefix(ftnType: FootnoteType): string = of fnAutoSymbol: result = "footnotesym-" of fnCitation: result = "citation-" -proc parseFootnote(p: var RstParser): PRstNode = +proc parseFootnote(p: var RstParser): PRstNode {.gcsafe.} = ## Parses footnotes and citations, always returns 2 sons: ## ## 1) footnote label, always containing rnInner with 1 or more sons From da7fd67f88eee72e411e92f485ea5456869d93ed Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 11:12:51 +0800 Subject: [PATCH 03/17] ignore threads option for nimscript --- compiler/commands.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/commands.nim b/compiler/commands.nim index c4df46bc2b50b..8e79a4477bfeb 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -717,7 +717,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "linedir": processOnOffSwitch(conf, {optLineDir}, arg, pass, info) of "assertions", "a": processOnOffSwitch(conf, {optAssert}, arg, pass, info) of "threads": - if conf.backend == backendJs: discard + if conf.backend == backendJs or conf.cmd == cmdNimscript: discard else: processOnOffSwitchG(conf, {optThreads}, arg, pass, info) #if optThreads in conf.globalOptions: conf.setNote(warnGcUnsafe) of "tlsemulation": processOnOffSwitchG(conf, {optTlsEmulation}, arg, pass, info) From b57e5c04abb79f9b1b31a0a70aeb65e13da6af46 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 14:49:20 +0800 Subject: [PATCH 04/17] threads off --- tests/stdlib/ttasks.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stdlib/ttasks.nim b/tests/stdlib/ttasks.nim index 75fed9f9bd515..e90823aba387d 100644 --- a/tests/stdlib/ttasks.nim +++ b/tests/stdlib/ttasks.nim @@ -1,6 +1,6 @@ discard """ targets: "c cpp" - matrix: "--gc:orc" + matrix: "--gc:orc --threads:off" """ import std/[tasks, strformat] From 5b9bc087d4feabb3cda7beed6b6c015a13347885 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 14:55:55 +0800 Subject: [PATCH 05/17] use createShared for threads --- tests/destructor/trecursive.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/destructor/trecursive.nim b/tests/destructor/trecursive.nim index 17a40e5a991da..e7afa6ba9733c 100644 --- a/tests/destructor/trecursive.nim +++ b/tests/destructor/trecursive.nim @@ -47,7 +47,7 @@ proc `=destroy`(x: var MyObject) = proc `=`(x: var MyObject, y: MyObject) {.error.} proc newMyObject(i: int): MyObject = - result.p = create(int) + result.p = createShared(int) result.p[] = i proc test: seq[MyObject] = From 01e6693242498fba8d32a9a2c1bc50bad5e8a95f Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 15:00:46 +0800 Subject: [PATCH 06/17] test without threads --- tests/system/tgcnone.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/tgcnone.nim b/tests/system/tgcnone.nim index 700176d5f80d3..47c6c601451a7 100644 --- a/tests/system/tgcnone.nim +++ b/tests/system/tgcnone.nim @@ -1,5 +1,5 @@ discard """ - matrix: "--gc:none -d:useMalloc" + matrix: "--gc:none -d:useMalloc --threads:off" """ # bug #15617 let x = 4 From 5e502f483cab2098dadf49e4369988a2c40944f9 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 15:59:35 +0800 Subject: [PATCH 07/17] avr threds off --- tests/manyloc/standalone2/tavr.nim.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/manyloc/standalone2/tavr.nim.cfg b/tests/manyloc/standalone2/tavr.nim.cfg index e5291969dd3d6..2a31618d03dfb 100644 --- a/tests/manyloc/standalone2/tavr.nim.cfg +++ b/tests/manyloc/standalone2/tavr.nim.cfg @@ -2,3 +2,4 @@ --cpu:avr --os:standalone --compileOnly +--threads:off From 528ed2b85509c09af3febbfd54d90ba2a7c91725 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 16:05:11 +0800 Subject: [PATCH 08/17] avr threads off --- tests/avr/thello.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avr/thello.nim b/tests/avr/thello.nim index a0191815cfc6c..7ebaeae5fd098 100644 --- a/tests/avr/thello.nim +++ b/tests/avr/thello.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim c --compileOnly --os:standalone --exceptions:quirky -d:noSignalHandler -d:danger $file" + cmd: "nim c --compileOnly --os:standalone --exceptions:quirky -d:noSignalHandler -d:danger --threads:off $file" action: "compile" """ From 96b763cc3ca284f3841e0ca4875bbb032b7760c8 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 16:05:24 +0800 Subject: [PATCH 09/17] async threads off --- tests/niminaction/Chapter7/Tweeter/src/tweeter.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/niminaction/Chapter7/Tweeter/src/tweeter.nim b/tests/niminaction/Chapter7/Tweeter/src/tweeter.nim index fe39278fb7e63..2fac949b9caa9 100644 --- a/tests/niminaction/Chapter7/Tweeter/src/tweeter.nim +++ b/tests/niminaction/Chapter7/Tweeter/src/tweeter.nim @@ -1,5 +1,6 @@ discard """ action: compile +matrix: "--threads:off" """ import asyncdispatch, times From 05cf4691c74fd36d2a939e87ccd39d121a641e2f Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 18:11:02 +0800 Subject: [PATCH 10/17] threads off --- testament/categories.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testament/categories.nim b/testament/categories.nim index 46cc3b2109083..5780e5d9aa242 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -94,12 +94,12 @@ proc dllTests(r: var TResults, cat: Category, options: string) = # dummy compile result: var c = initResults() - runBasicDLLTest c, r, cat, options - runBasicDLLTest c, r, cat, options & " -d:release" + runBasicDLLTest c, r, cat, options & " --threads:off" + runBasicDLLTest c, r, cat, options & " -d:release --threads:off" when not defined(windows): # still cannot find a recent Windows version of boehm.dll: - runBasicDLLTest c, r, cat, options & " --gc:boehm" - runBasicDLLTest c, r, cat, options & " -d:release --gc:boehm" + runBasicDLLTest c, r, cat, options & " --gc:boehm --threads:off" + runBasicDLLTest c, r, cat, options & " -d:release --gc:boehm --threads:off" # ------------------------------ GC tests ------------------------------------- From 4f02a798564b81e2158457feec904cb53e921507 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 19:32:42 +0800 Subject: [PATCH 11/17] fix ci --- testament/categories.nim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/testament/categories.nim b/testament/categories.nim index 5780e5d9aa242..2fdbaaa5ab256 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -53,16 +53,16 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = else: "" - var test1 = makeTest("lib/nimrtl.nim", options & " --outdir:tests/dll", cat) + var test1 = makeTest("lib/nimrtl.nim", options & " --threads:off --outdir:tests/dll", cat) test1.spec.action = actionCompile testSpec c, test1 - var test2 = makeTest("tests/dll/server.nim", options & " --threads:on" & rpath, cat) + var test2 = makeTest("tests/dll/server.nim", options & rpath, cat) test2.spec.action = actionCompile testSpec c, test2 - var test3 = makeTest("lib/nimhcr.nim", options & " --outdir:tests/dll" & rpath, cat) + var test3 = makeTest("lib/nimhcr.nim", options & " --threads:off --outdir:tests/dll" & rpath, cat) test3.spec.action = actionCompile testSpec c, test3 - var test4 = makeTest("tests/dll/visibility.nim", options & " --app:lib" & rpath, cat) + var test4 = makeTest("tests/dll/visibility.nim", options & " --threads:off --app:lib" & rpath, cat) test4.spec.action = actionCompile testSpec c, test4 @@ -76,14 +76,14 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: "")) defer: putEnv(libpathenv, libpath) - testSpec r, makeTest("tests/dll/client.nim", options & " --threads:on" & rpath, cat) - testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & rpath, cat) - testSpec r, makeTest("tests/dll/visibility.nim", options & rpath, cat) + testSpec r, makeTest("tests/dll/client.nim", options & rpath, cat) + testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & " --threads:off" & rpath, cat) + testSpec r, makeTest("tests/dll/visibility.nim", options & " --threads:off" & rpath, cat) if "boehm" notin options: # force build required - see the comments in the .nim file for more details var hcri = makeTest("tests/dll/nimhcr_integration.nim", - options & " --forceBuild --hotCodeReloading:on" & rpath, cat) + options & " --threads:off --forceBuild --hotCodeReloading:on" & rpath, cat) let nimcache = nimcacheDir(hcri.name, hcri.options, getTestSpecTarget()) let cmd = prepareTestCmd(hcri.spec.getCmd, hcri.name, hcri.options, nimcache, getTestSpecTarget()) @@ -94,12 +94,12 @@ proc dllTests(r: var TResults, cat: Category, options: string) = # dummy compile result: var c = initResults() - runBasicDLLTest c, r, cat, options & " --threads:off" - runBasicDLLTest c, r, cat, options & " -d:release --threads:off" + runBasicDLLTest c, r, cat, options + runBasicDLLTest c, r, cat, options when not defined(windows): # still cannot find a recent Windows version of boehm.dll: - runBasicDLLTest c, r, cat, options & " --gc:boehm --threads:off" - runBasicDLLTest c, r, cat, options & " -d:release --gc:boehm --threads:off" + runBasicDLLTest c, r, cat, options & " --gc:boehm" + runBasicDLLTest c, r, cat, options & " -d:release --gc:boehm" # ------------------------------ GC tests ------------------------------------- From 9c26e631fbe49de1b43d2f6a8ea7fe8a656b2193 Mon Sep 17 00:00:00 2001 From: flywind Date: Wed, 12 Jan 2022 21:40:09 +0800 Subject: [PATCH 12/17] restore option --- testament/categories.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testament/categories.nim b/testament/categories.nim index 2fdbaaa5ab256..0d7d1d0e1d32e 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -56,7 +56,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = var test1 = makeTest("lib/nimrtl.nim", options & " --threads:off --outdir:tests/dll", cat) test1.spec.action = actionCompile testSpec c, test1 - var test2 = makeTest("tests/dll/server.nim", options & rpath, cat) + var test2 = makeTest("tests/dll/server.nim", options & " --threads:on" & rpath, cat) test2.spec.action = actionCompile testSpec c, test2 var test3 = makeTest("lib/nimhcr.nim", options & " --threads:off --outdir:tests/dll" & rpath, cat) @@ -76,7 +76,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: "")) defer: putEnv(libpathenv, libpath) - testSpec r, makeTest("tests/dll/client.nim", options & rpath, cat) + testSpec r, makeTest("tests/dll/client.nim", options & " --threads:on" & rpath, cat) testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & " --threads:off" & rpath, cat) testSpec r, makeTest("tests/dll/visibility.nim", options & " --threads:off" & rpath, cat) @@ -95,7 +95,7 @@ proc dllTests(r: var TResults, cat: Category, options: string) = var c = initResults() runBasicDLLTest c, r, cat, options - runBasicDLLTest c, r, cat, options + runBasicDLLTest c, r, cat, options & " -d:release" when not defined(windows): # still cannot find a recent Windows version of boehm.dll: runBasicDLLTest c, r, cat, options & " --gc:boehm" From 57472ea56b3b38df6deb38bb802f4150d7e3eeed Mon Sep 17 00:00:00 2001 From: flywind Date: Thu, 13 Jan 2022 12:06:54 +0800 Subject: [PATCH 13/17] make CI pleased --- testament/categories.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/categories.nim b/testament/categories.nim index 0d7d1d0e1d32e..caaaecfd7d913 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -53,7 +53,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = else: "" - var test1 = makeTest("lib/nimrtl.nim", options & " --threads:off --outdir:tests/dll", cat) + var test1 = makeTest("lib/nimrtl.nim", options & " --outdir:tests/dll", cat) test1.spec.action = actionCompile testSpec c, test1 var test2 = makeTest("tests/dll/server.nim", options & " --threads:on" & rpath, cat) From 8f0308999de98296696c703b165e5ca315336b15 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+xflywind@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:45:54 +0800 Subject: [PATCH 14/17] fix ic tests --- tests/ic/config.nims | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/ic/config.nims diff --git a/tests/ic/config.nims b/tests/ic/config.nims new file mode 100644 index 0000000000000..e69de29bb2d1d From 7235c80283832de5e759a855770b3c3b2914e510 Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Tue, 5 Jul 2022 10:58:15 +0800 Subject: [PATCH 15/17] Update config.nims --- tests/ic/config.nims | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ic/config.nims b/tests/ic/config.nims index e69de29bb2d1d..76b29a6aad4b6 100644 --- a/tests/ic/config.nims +++ b/tests/ic/config.nims @@ -0,0 +1,2 @@ +when defined(windows): + --threads:off From a329e0607bd50eed9a87acb70aee31913c6521bf Mon Sep 17 00:00:00 2001 From: xflywind <43030857+xflywind@users.noreply.github.com> Date: Tue, 5 Jul 2022 17:51:31 +0800 Subject: [PATCH 16/17] add changelog --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 98655eaa3a714..70514ea32b3f7 100644 --- a/changelog.md +++ b/changelog.md @@ -26,6 +26,8 @@ becomes an alias for `addr`. - The `gc:v2` option is removed. +- The `threads:on` option becomes default. + ## Standard library additions and changes [//]: # "Changes:" From 5ef646fc335433d1bbb9418128c4694978c3a4d7 Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Tue, 5 Jul 2022 18:05:22 +0800 Subject: [PATCH 17/17] Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 70514ea32b3f7..c35a403e6f68d 100644 --- a/changelog.md +++ b/changelog.md @@ -26,7 +26,7 @@ becomes an alias for `addr`. - The `gc:v2` option is removed. -- The `threads:on` option becomes default. +- The `threads:on` option becomes the default. ## Standard library additions and changes