make fullpaths the default in error messages and stack traces for mor… (#11385)

* 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
This commit is contained in:
Andreas Rumpf
2019-06-05 08:02:54 +02:00
committed by GitHub
parent fc4f0808c4
commit 7215341190
15 changed files with 41 additions and 27 deletions

View File

@@ -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

View File

@@ -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..<n.len:
detectCapturedVars(n[i], owner, c)

View File

@@ -363,7 +363,8 @@ proc mainCommand*(graph: ModuleGraph) =
rawMessage(conf, hintSuccessX, [$conf.linesCompiled,
formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3),
usedMem,
if isDefined(conf, "release"): "Release Build"
if isDefined(conf, "danger"): "Dangerous Release Build"
elif isDefined(conf, "release"): "Release Build"
else: "Debug Build"])
when PrintRopeCacheStats:

View File

@@ -28,7 +28,7 @@ proc parseAtom(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
result = parseExpr(L, tok, config)
if tok.tokType == tkParRi: ppGetTok(L, tok)
else: lexMessage(L, errGenerated, "expected closing ')'")
elif tok.ident.id == ord(wNot):
elif tok.tokType == tkNot:
ppGetTok(L, tok)
result = not parseAtom(L, tok, config)
else:
@@ -37,14 +37,14 @@ proc parseAtom(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
proc parseAndExpr(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
result = parseAtom(L, tok, config)
while tok.ident.id == ord(wAnd):
while tok.tokType == tkAnd:
ppGetTok(L, tok) # skip "and"
var b = parseAtom(L, tok, config)
result = result and b
proc parseExpr(L: var TLexer, tok: var TToken; config: ConfigRef): bool =
result = parseAndExpr(L, tok, config)
while tok.ident.id == ord(wOr):
while tok.tokType == tkOr:
ppGetTok(L, tok) # skip "or"
var b = parseAndExpr(L, tok, config)
result = result or b

View File

@@ -276,7 +276,8 @@ const
optBoundsCheck, optOverflowCheck, optAssert, optWarns,
optHints, optStackTrace, optLineTrace,
optTrMacros, optNilCheck, optMoveCheck}
DefaultGlobalOptions* = {optThreadAnalysis}
DefaultGlobalOptions* = {optThreadAnalysis,
optExcessiveStackTrace, optListFullPaths}
proc getSrcTimestamp(): DateTime =
try:
@@ -312,7 +313,7 @@ proc newConfigRef*(): ConfigRef =
macrosToExpand: newStringTable(modeStyleInsensitive),
m: initMsgConfig(),
evalExpr: "",
cppDefines: initSet[string](),
cppDefines: initHashSet[string](),
headerFile: "", features: {}, foreignPackageNotes: {hintProcessing, warnUnknownMagic,
hintQuitCalled, hintExecuting},
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
@@ -540,7 +541,7 @@ proc getNimcacheDir*(conf: ConfigRef): AbsoluteDir =
conf.projectPath / genSubDir
else:
AbsoluteDir(getOsCacheDir() / splitFile(conf.projectName).name &
(if isDefined(conf, "release"): "_r" else: "_d"))
(if isDefined(conf, "release") or isDefined(conf, "danger"): "_r" else: "_d"))
proc pathSubs*(conf: ConfigRef; p, config: string): string =
let home = removeTrailingDirSep(os.getHomeDir())

View File

@@ -1189,7 +1189,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
of opcFinallyEnd:
# The control flow may not resume at the next instruction since we may be
# raising an exception or performing a cleanup.
if not savedPC < 0:
if savedPC >= 0:
pc = savedPC - 1
savedPC = -1
if tos != savedFrame:

View File

@@ -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

View File

@@ -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")

View File

@@ -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:

View File

@@ -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

View File

@@ -1,2 +1,3 @@
--define: nimpretty
--define: nimpretty2
-define: nimOldCaseObjects

View File

@@ -22,3 +22,4 @@ define:nimcore
#define:noDocgen
--path:"$nim"
--threads:on
--define:nimOldCaseObjects

View File

@@ -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:

View File

@@ -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

View File

@@ -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