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
commit 7215341190
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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. hot code reloading events in the code.
- The compiler nows supports a ``--expandMacro:macroNameHere`` switch - The compiler nows supports a ``--expandMacro:macroNameHere`` switch
for easy introspection into what a macro expands into. 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 ### Bugfixes

View file

@ -480,9 +480,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) =
if n.typ != nil: if n.typ != nil:
detectCapturedVars(n[namePos], owner, c) detectCapturedVars(n[namePos], owner, c)
of nkReturnStmt: of nkReturnStmt:
if n[0].kind in {nkAsgn, nkFastAsgn}: detectCapturedVars(n[0], owner, c)
detectCapturedVars(n[0].sons[1], owner, c)
else: assert n[0].kind == nkEmpty
else: else:
for i in 0..<n.len: for i in 0..<n.len:
detectCapturedVars(n[i], owner, c) detectCapturedVars(n[i], owner, c)

View file

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

View file

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

View file

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

View file

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

View file

@ -52,7 +52,7 @@ path="$lib/pure"
@end @end
@end @end
@if release or quick: @if danger or quick:
obj_checks:off obj_checks:off
field_checks:off field_checks:off
range_checks:off range_checks:off
@ -69,10 +69,19 @@ path="$lib/pure"
@end @end
@end @end
@if release: @if release or danger:
stacktrace:off
linetrace:off
debugger:off
line_dir:off
opt:speed opt:speed
@end @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: @if unix and mingw:
# Cross compile for Windows from Linux/OSX using MinGW # Cross compile for Windows from Linux/OSX using MinGW
os = windows os = windows
@ -200,13 +209,13 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
gcc.options.speed = "-O3 -fno-strict-aliasing" gcc.options.speed = "-O3 -fno-strict-aliasing"
gcc.options.size = "-Os" gcc.options.size = "-Os"
@if windows: @if windows:
gcc.options.debug = "-g3 -O0 -gdwarf-3" gcc.options.debug = "-g3 -Og -gdwarf-3"
@else: @else:
gcc.options.debug = "-g3 -O0" gcc.options.debug = "-g3 -Og"
@end @end
gcc.cpp.options.speed = "-O3 -fno-strict-aliasing" gcc.cpp.options.speed = "-O3 -fno-strict-aliasing"
gcc.cpp.options.size = "-Os" gcc.cpp.options.size = "-Os"
gcc.cpp.options.debug = "-g3 -O0" gcc.cpp.options.debug = "-g3 -Og"
#passl = "-pg" #passl = "-pg"
# Configuration for the LLVM GCC compiler: # Configuration for the LLVM GCC compiler:
@ -224,13 +233,13 @@ clang.options.size = "-Os"
@if windows: @if windows:
clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc" 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.options.linker = "/Z7"
clang_cl.cpp.options.linker = "/Z7" clang_cl.cpp.options.linker = "/Z7"
@end @end
clang.options.debug = "-g -gcodeview" clang.options.debug = "-g -gcodeview"
clang.cpp.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.options.linker = "-g"
clang.cpp.options.linker = "-g" clang.cpp.options.linker = "-g"
@end @end

View file

@ -165,7 +165,7 @@ proc buildNimble(latest: bool) =
nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release") nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release")
proc bundleNimsuggest() = proc bundleNimsuggest() =
nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release") nimCompileFold("Compile nimsuggest", "nimsuggest/nimsuggest.nim", options = "-d:release -d:danger")
proc buildVccTool() = proc buildVccTool() =
nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim") nimCompileFold("Compile Vcc", "tools/vccexe/vccexe.nim")
@ -286,7 +286,7 @@ proc boot(args: string) =
var finalDest = "bin" / "nim".exe var finalDest = "bin" / "nim".exe
# default to use the 'c' command: # default to use the 'c' command:
let useCpp = getEnv("NIM_COMPILE_TO_CPP", "false") == "true" 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 hostOs & "_" & hostCpu
let nimStart = findStartNim() let nimStart = findStartNim()
@ -463,7 +463,7 @@ proc runCI(cmd: string) =
when defined(posix): # appveyor (on windows) didn't run this when defined(posix): # appveyor (on windows) didn't run this
kochExecFold("Boot", "boot") kochExecFold("Boot", "boot")
# boot without -d:nimHasLibFFI to make sure this still works # 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 ## build nimble early on to enable remainder to depend on it if needed
kochExecFold("Build Nimble", "nimble") kochExecFold("Build Nimble", "nimble")

View file

@ -149,7 +149,7 @@ template dollarImpl(): untyped {.dirty.} =
result.addQuoted(val) result.addQuoted(val)
result.add("}") result.add("}")
template equalsImpl(s, t: typed): typed = template equalsImpl(s, t: typed) =
if s.counter == t.counter: if s.counter == t.counter:
# different insertion orders mean different 'data' seqs, so we have # different insertion orders mean different 'data' seqs, so we have
# to use the slow route here: # 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) rawInsert(t, t.data, n[h].key, n[h].val, n[h].hcode, j)
h = nxt h = nxt
template forAllOrderedPairs(yieldStmt: untyped): typed {.dirty.} = template forAllOrderedPairs(yieldStmt: untyped) {.dirty.} =
var h = t.first var h = t.first
while h >= 0: while h >= 0:
var nxt = t.data[h].next var nxt = t.data[h].next

View file

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

View file

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

View file

@ -647,7 +647,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
writeFile("megatest.nim", megatest) 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 proc onStdout(line: string) = echo line
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "") var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
if exitCode != 0: if exitCode != 0:

View file

@ -1,6 +1,6 @@
discard """ discard """
output: "ok" output: "ok"
cmd: "nim $target -d:release $options $file" cmd: "nim $target --overflowChecks:off $options $file"
""" """
# Tests nim's ability to detect overflows # Tests nim's ability to detect overflows

View file

@ -4,7 +4,7 @@ const rangesGCHoldEnabled = not defined(rangesDisableGCHold)
type type
# A view into immutable array # A view into immutable array
Range* {.shallow.} [T] = object Range*[T] {.shallow.} = object
when rangesGCHoldEnabled: when rangesGCHoldEnabled:
gcHold: seq[T] gcHold: seq[T]
start: ptr T start: ptr T