From 721534119000c2bd53cc72b531726a6104381222 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 5 Jun 2019 08:02:54 +0200 Subject: make fullpaths the default in error messages and stack traces for mor… (#11385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * make fullpaths the default in error messages and stack traces for more convenient development * split up -d:release into -d:release and -d:danger flags * workaround a Nim config parser bug * fixes an old nim config parser bug * make megatest green again * make nimpretty tests work again * make nimsuggest green --- changelog.md | 4 +++- compiler/lambdalifting.nim | 4 +--- compiler/main.nim | 3 ++- compiler/nimconf.nim | 6 +++--- compiler/options.nim | 7 ++++--- compiler/vm.nim | 2 +- config/nim.cfg | 23 ++++++++++++++++------- koch.nim | 6 +++--- lib/pure/collections/tableimpl.nim | 2 +- lib/pure/collections/tables.nim | 2 +- nimpretty/nimpretty.nim.cfg | 1 + nimsuggest/nimsuggest.nim.cfg | 1 + testament/categories.nim | 3 ++- tests/overflw/toverflw.nim | 2 +- tests/vm/tcompiletimerange.nim | 2 +- 15 files changed, 41 insertions(+), 27 deletions(-) diff --git a/changelog.md b/changelog.md index e16211a3d..f75958a73 100644 --- a/changelog.md +++ b/changelog.md @@ -277,7 +277,9 @@ proc enumToString*(enums: openArray[enum]): string = hot code reloading events in the code. - The compiler nows supports a ``--expandMacro:macroNameHere`` switch for easy introspection into what a macro expands into. - +- The `-d:release` switch now does not disable runtime checks anymore. + For a release build that also disables runtime checks + use `-d:release -d:danger` or simply `-d:danger`. ### Bugfixes diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 6f0f8e0a5..e2d1a143f 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -480,9 +480,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = if n.typ != nil: detectCapturedVars(n[namePos], owner, c) of nkReturnStmt: - if n[0].kind in {nkAsgn, nkFastAsgn}: - detectCapturedVars(n[0].sons[1], owner, c) - else: assert n[0].kind == nkEmpty + detectCapturedVars(n[0], owner, c) else: for i in 0..= 0: pc = savedPC - 1 savedPC = -1 if tos != savedFrame: diff --git a/config/nim.cfg b/config/nim.cfg index db0336f89..89906a47d 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -52,7 +52,7 @@ path="$lib/pure" @end @end -@if release or quick: +@if danger or quick: obj_checks:off field_checks:off range_checks:off @@ -69,10 +69,19 @@ path="$lib/pure" @end @end -@if release: +@if release or danger: + stacktrace:off + linetrace:off + debugger:off + line_dir:off opt:speed @end +@if false: # not danger: # this does not work yet. + clang.options.always %= "${clang.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error" + gcc.options.always %= "${gcc.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error" +@end + @if unix and mingw: # Cross compile for Windows from Linux/OSX using MinGW os = windows @@ -200,13 +209,13 @@ clang.objc.options.linker = "-lobjc -lgnustep-base" gcc.options.speed = "-O3 -fno-strict-aliasing" gcc.options.size = "-Os" @if windows: - gcc.options.debug = "-g3 -O0 -gdwarf-3" + gcc.options.debug = "-g3 -Og -gdwarf-3" @else: - gcc.options.debug = "-g3 -O0" + gcc.options.debug = "-g3 -Og" @end gcc.cpp.options.speed = "-O3 -fno-strict-aliasing" gcc.cpp.options.size = "-Os" -gcc.cpp.options.debug = "-g3 -O0" +gcc.cpp.options.debug = "-g3 -Og" #passl = "-pg" # Configuration for the LLVM GCC compiler: @@ -224,13 +233,13 @@ clang.options.size = "-Os" @if windows: clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc" - @if not release: + @if not release and not safety and not danger: clang_cl.options.linker = "/Z7" clang_cl.cpp.options.linker = "/Z7" @end clang.options.debug = "-g -gcodeview" clang.cpp.options.debug = "-g -gcodeview" - @if not release: + @if not release and not safety and not danger: clang.options.linker = "-g" clang.cpp.options.linker = "-g" @end diff --git a/koch.nim b/koch.nim index 8313d0866..1832a49b9 100644 --- a/koch.nim +++ b/koch.nim @@ -165,7 +165,7 @@ proc buildNimble(latest: bool) = nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release") proc bundleNimsuggest() = - nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release") + nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release -d:danger") proc buildVccTool() = nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim") @@ -286,7 +286,7 @@ proc boot(args: string) = var finalDest = "bin" / "nim".exe # default to use the 'c' command: let useCpp = getEnv("NIM_COMPILE_TO_CPP", "false") == "true" - let smartNimcache = (if "release" in args: "nimcache/r_" else: "nimcache/d_") & + let smartNimcache = (if "release" in args or "danger" in args: "nimcache/r_" else: "nimcache/d_") & hostOs & "_" & hostCpu let nimStart = findStartNim() @@ -463,7 +463,7 @@ proc runCI(cmd: string) = when defined(posix): # appveyor (on windows) didn't run this kochExecFold("Boot", "boot") # boot without -d:nimHasLibFFI to make sure this still works - kochExecFold("Boot in release mode", "boot -d:release") + kochExecFold("Boot in release mode", "boot -d:release -d:danger") ## build nimble early on to enable remainder to depend on it if needed kochExecFold("Build Nimble", "nimble") diff --git a/lib/pure/collections/tableimpl.nim b/lib/pure/collections/tableimpl.nim index 4f9610db3..ad9445c91 100644 --- a/lib/pure/collections/tableimpl.nim +++ b/lib/pure/collections/tableimpl.nim @@ -149,7 +149,7 @@ template dollarImpl(): untyped {.dirty.} = result.addQuoted(val) result.add("}") -template equalsImpl(s, t: typed): typed = +template equalsImpl(s, t: typed) = if s.counter == t.counter: # different insertion orders mean different 'data' seqs, so we have # to use the slow route here: diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 84284edb3..bf1f3c692 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -1252,7 +1252,7 @@ proc enlarge[A, B](t: var OrderedTable[A, B]) = rawInsert(t, t.data, n[h].key, n[h].val, n[h].hcode, j) h = nxt -template forAllOrderedPairs(yieldStmt: untyped): typed {.dirty.} = +template forAllOrderedPairs(yieldStmt: untyped) {.dirty.} = var h = t.first while h >= 0: var nxt = t.data[h].next diff --git a/nimpretty/nimpretty.nim.cfg b/nimpretty/nimpretty.nim.cfg index 5fafa6d2a..9eb185370 100644 --- a/nimpretty/nimpretty.nim.cfg +++ b/nimpretty/nimpretty.nim.cfg @@ -1,2 +1,3 @@ --define: nimpretty --define: nimpretty2 +-define: nimOldCaseObjects diff --git a/nimsuggest/nimsuggest.nim.cfg b/nimsuggest/nimsuggest.nim.cfg index 394449740..302c30965 100644 --- a/nimsuggest/nimsuggest.nim.cfg +++ b/nimsuggest/nimsuggest.nim.cfg @@ -22,3 +22,4 @@ define:nimcore #define:noDocgen --path:"$nim" --threads:on +--define:nimOldCaseObjects diff --git a/testament/categories.nim b/testament/categories.nim index c5769347a..4fddeb554 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -647,7 +647,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = writeFile("megatest.nim", megatest) - let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "megatest.nim"] + let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", + "--listFullPaths:off", "--excessiveStackTrace:off", "megatest.nim"] proc onStdout(line: string) = echo line var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "") if exitCode != 0: diff --git a/tests/overflw/toverflw.nim b/tests/overflw/toverflw.nim index aef597e6c..d96231900 100644 --- a/tests/overflw/toverflw.nim +++ b/tests/overflw/toverflw.nim @@ -1,6 +1,6 @@ discard """ output: "ok" - cmd: "nim $target -d:release $options $file" + cmd: "nim $target --overflowChecks:off $options $file" """ # Tests nim's ability to detect overflows diff --git a/tests/vm/tcompiletimerange.nim b/tests/vm/tcompiletimerange.nim index fd809985e..f2eb1b75b 100644 --- a/tests/vm/tcompiletimerange.nim +++ b/tests/vm/tcompiletimerange.nim @@ -4,7 +4,7 @@ const rangesGCHoldEnabled = not defined(rangesDisableGCHold) type # A view into immutable array - Range* {.shallow.} [T] = object + Range*[T] {.shallow.} = object when rangesGCHoldEnabled: gcHold: seq[T] start: ptr T -- cgit 1.4.1-2-gfad0