merge BuildMode into SuccessX, remove code duplication w drnim, add useful info to successx, add gc to compilesettings (#18252)
* merge BuildMode into SuccessX, add more info * refactor duplicated with drnim * fixup * address comment
This commit is contained in:
parent
065243dc59
commit
e1e8af535e
10 changed files with 64 additions and 66 deletions
|
|
@ -65,7 +65,7 @@ type
|
||||||
warnFileChanged = "FileChanged",
|
warnFileChanged = "FileChanged",
|
||||||
warnUser = "User",
|
warnUser = "User",
|
||||||
|
|
||||||
hintSuccess = "Success", hintSuccessX = "SuccessX", hintBuildMode = "BuildMode",
|
hintSuccess = "Success", hintSuccessX = "SuccessX",
|
||||||
hintCC = "CC",
|
hintCC = "CC",
|
||||||
hintLineTooLong = "LineTooLong", hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
|
hintLineTooLong = "LineTooLong", hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
|
||||||
hintXCannotRaiseY = "XCannotRaiseY", hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
|
hintXCannotRaiseY = "XCannotRaiseY", hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
|
||||||
|
|
@ -145,8 +145,7 @@ const
|
||||||
warnUser: "$1",
|
warnUser: "$1",
|
||||||
hintSuccess: "operation successful: $#",
|
hintSuccess: "operation successful: $#",
|
||||||
# keep in sync with `testament.isSuccess`
|
# keep in sync with `testament.isSuccess`
|
||||||
hintSuccessX: "$loc lines; ${sec}s; $mem; proj: $project; out: $output",
|
hintSuccessX: "$build\n$loc lines; ${sec}s; $mem; proj: $project; out: $output",
|
||||||
hintBuildMode: "$1",
|
|
||||||
hintCC: "CC: $1",
|
hintCC: "CC: $1",
|
||||||
hintLineTooLong: "line too long",
|
hintLineTooLong: "line too long",
|
||||||
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
||||||
|
|
@ -200,7 +199,7 @@ proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
|
||||||
result[1] = result[2] - {warnProveField, warnProveIndex,
|
result[1] = result[2] - {warnProveField, warnProveIndex,
|
||||||
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,
|
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,
|
||||||
hintSource, hintGlobalVar, hintGCStats, hintMsgOrigin, hintPerformance}
|
hintSource, hintGlobalVar, hintGCStats, hintMsgOrigin, hintPerformance}
|
||||||
result[0] = result[1] - {hintSuccessX, hintBuildMode, hintSuccess, hintConf,
|
result[0] = result[1] - {hintSuccessX, hintSuccess, hintConf,
|
||||||
hintProcessing, hintPattern, hintExecuting, hintLinking, hintCC}
|
hintProcessing, hintPattern, hintExecuting, hintLinking, hintCC}
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,14 @@ when not defined(nimcore):
|
||||||
{.error: "nimcore MUST be defined for Nim's core tooling".}
|
{.error: "nimcore MUST be defined for Nim's core tooling".}
|
||||||
|
|
||||||
import
|
import
|
||||||
llstream, strutils, os, ast, lexer, syntaxes, options, msgs,
|
std/[strutils, os, times, tables, sha1, with, json],
|
||||||
condsyms, times,
|
llstream, ast, lexer, syntaxes, options, msgs,
|
||||||
|
condsyms,
|
||||||
sem, idents, passes, extccomp,
|
sem, idents, passes, extccomp,
|
||||||
cgen, json, nversion,
|
cgen, nversion,
|
||||||
platform, nimconf, passaux, depends, vm,
|
platform, nimconf, passaux, depends, vm,
|
||||||
modules,
|
modules,
|
||||||
modulegraphs, tables, lineinfos, pathutils, vmprofiler, std/[sha1, with]
|
modulegraphs, lineinfos, pathutils, vmprofiler
|
||||||
|
|
||||||
import ic / [cbackend, integrity, navigator]
|
import ic / [cbackend, integrity, navigator]
|
||||||
from ic / ic import rodViewer
|
from ic / ic import rodViewer
|
||||||
|
|
@ -387,38 +388,9 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
rawMessage(conf, errGenerated, "invalid command: " & conf.command)
|
rawMessage(conf, errGenerated, "invalid command: " & conf.command)
|
||||||
|
|
||||||
if conf.errorCounter == 0 and conf.cmd notin {cmdTcc, cmdDump, cmdNop}:
|
if conf.errorCounter == 0 and conf.cmd notin {cmdTcc, cmdDump, cmdNop}:
|
||||||
# D20210419T170230:here
|
|
||||||
let mem =
|
|
||||||
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
|
||||||
else: formatSize(getTotalMem()) & " totmem"
|
|
||||||
let loc = $conf.linesCompiled
|
|
||||||
let build = if isDefined(conf, "danger"): "Dangerous Release build"
|
|
||||||
elif isDefined(conf, "release"): "Release build"
|
|
||||||
else: "***SLOW, DEBUG BUILD***; -d:release makes code run faster."
|
|
||||||
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
|
|
||||||
let project = if conf.filenameOption == foAbs: $conf.projectFull else: $conf.projectName
|
|
||||||
# xxx honor conf.filenameOption more accurately
|
|
||||||
var output: string
|
|
||||||
if optCompileOnly in conf.globalOptions and conf.cmd != cmdJsonscript:
|
|
||||||
output = $conf.jsonBuildFile
|
|
||||||
elif conf.outFile.isEmpty and conf.cmd notin {cmdJsonscript} + cmdDocLike + cmdBackends:
|
|
||||||
# for some cmd we expect a valid absOutFile
|
|
||||||
output = "unknownOutput"
|
|
||||||
else:
|
|
||||||
output = $conf.absOutFile
|
|
||||||
if conf.filenameOption != foAbs: output = output.AbsoluteFile.extractFilename
|
|
||||||
# xxx honor filenameOption more accurately
|
|
||||||
if optProfileVM in conf.globalOptions:
|
if optProfileVM in conf.globalOptions:
|
||||||
echo conf.dump(conf.vmProfileData)
|
echo conf.dump(conf.vmProfileData)
|
||||||
rawMessage(conf, hintSuccessX, [
|
genSuccessX(conf)
|
||||||
"loc", loc,
|
|
||||||
"sec", sec,
|
|
||||||
"mem", mem,
|
|
||||||
"project", project,
|
|
||||||
"output", output,
|
|
||||||
])
|
|
||||||
if conf.cmd in cmdBackends:
|
|
||||||
rawMessage(conf, hintBuildMode, build)
|
|
||||||
|
|
||||||
when PrintRopeCacheStats:
|
when PrintRopeCacheStats:
|
||||||
echo "rope cache stats: "
|
echo "rope cache stats: "
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,9 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import
|
import
|
||||||
options, strutils, os, tables, ropes, terminal, macros,
|
std/[strutils, os, tables, terminal, macros, times],
|
||||||
lineinfos, pathutils
|
std/private/miscdollars,
|
||||||
import std/private/miscdollars
|
options, ropes, lineinfos, pathutils, strutils2
|
||||||
import strutils2
|
|
||||||
|
|
||||||
type InstantiationInfo* = typeof(instantiationInfo())
|
type InstantiationInfo* = typeof(instantiationInfo())
|
||||||
template instLoc*(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
template instLoc*(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
||||||
|
|
@ -656,3 +655,39 @@ proc uniqueModuleName*(conf: ConfigRef; fid: FileIndex): string =
|
||||||
# We mangle upper letters and digits too so that there cannot
|
# We mangle upper letters and digits too so that there cannot
|
||||||
# be clashes with our special meanings of 'Z' and 'O'
|
# be clashes with our special meanings of 'Z' and 'O'
|
||||||
result.addInt ord(c)
|
result.addInt ord(c)
|
||||||
|
|
||||||
|
proc genSuccessX*(conf: ConfigRef) =
|
||||||
|
let mem =
|
||||||
|
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
||||||
|
else: formatSize(getTotalMem()) & " totmem"
|
||||||
|
let loc = $conf.linesCompiled
|
||||||
|
var build = ""
|
||||||
|
if conf.cmd in cmdBackends:
|
||||||
|
build.add "gc: $#; " % $conf.selectedGC
|
||||||
|
if optThreads in conf.globalOptions: build.add "threads: on; "
|
||||||
|
build.add "opt: "
|
||||||
|
if optOptimizeSpeed in conf.options: build.add "speed"
|
||||||
|
elif optOptimizeSize in conf.options: build.add "size"
|
||||||
|
else: build.add "none (DEBUG BUILD, `-d:release` generates faster code)"
|
||||||
|
# pending https://github.com/timotheecour/Nim/issues/752, point to optimization.html
|
||||||
|
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
|
||||||
|
let project = if conf.filenameOption == foAbs: $conf.projectFull else: $conf.projectName
|
||||||
|
# xxx honor conf.filenameOption more accurately
|
||||||
|
var output: string
|
||||||
|
if optCompileOnly in conf.globalOptions and conf.cmd != cmdJsonscript:
|
||||||
|
output = $conf.jsonBuildFile
|
||||||
|
elif conf.outFile.isEmpty and conf.cmd notin {cmdJsonscript} + cmdDocLike + cmdBackends:
|
||||||
|
# for some cmd we expect a valid absOutFile
|
||||||
|
output = "unknownOutput"
|
||||||
|
else:
|
||||||
|
output = $conf.absOutFile
|
||||||
|
if conf.filenameOption != foAbs: output = output.AbsoluteFile.extractFilename
|
||||||
|
# xxx honor filenameOption more accurately
|
||||||
|
rawMessage(conf, hintSuccessX, [
|
||||||
|
"build", build,
|
||||||
|
"loc", loc,
|
||||||
|
"sec", sec,
|
||||||
|
"mem", mem,
|
||||||
|
"project", project,
|
||||||
|
"output", output,
|
||||||
|
])
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,17 @@ const
|
||||||
type
|
type
|
||||||
TStringSeq* = seq[string]
|
TStringSeq* = seq[string]
|
||||||
TGCMode* = enum # the selected GC
|
TGCMode* = enum # the selected GC
|
||||||
gcUnselected, gcNone, gcBoehm, gcRegions, gcArc, gcOrc,
|
gcUnselected = "unselected"
|
||||||
gcMarkAndSweep, gcHooks, gcRefc, gcV2, gcGo
|
gcNone = "none"
|
||||||
|
gcBoehm = "boehm"
|
||||||
|
gcRegions = "regions"
|
||||||
|
gcArc = "arc"
|
||||||
|
gcOrc = "orc"
|
||||||
|
gcMarkAndSweep = "markAndSweep"
|
||||||
|
gcHooks = "hooks"
|
||||||
|
gcRefc = "refc"
|
||||||
|
gcV2 = "v2"
|
||||||
|
gcGo = "go"
|
||||||
# gcRefc and the GCs that follow it use a write barrier,
|
# gcRefc and the GCs that follow it use a write barrier,
|
||||||
# as far as usesWriteBarrier() is concerned
|
# as far as usesWriteBarrier() is concerned
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ when defined(nimHasInvariant):
|
||||||
of ccompilerPath: result = conf.cCompilerPath
|
of ccompilerPath: result = conf.cCompilerPath
|
||||||
of backend: result = $conf.backend
|
of backend: result = $conf.backend
|
||||||
of libPath: result = conf.libpath.string
|
of libPath: result = conf.libpath.string
|
||||||
|
of gc: result = $conf.selectedGC
|
||||||
|
|
||||||
proc querySettingSeqImpl(conf: ConfigRef, switch: BiggestInt): seq[string] =
|
proc querySettingSeqImpl(conf: ConfigRef, switch: BiggestInt): seq[string] =
|
||||||
template copySeq(field: untyped): untyped =
|
template copySeq(field: untyped): untyped =
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ Source The source line that triggered a diagnostic
|
||||||
message.
|
message.
|
||||||
StackTrace
|
StackTrace
|
||||||
Success, SuccessX Successful compilation of a library or a binary.
|
Success, SuccessX Successful compilation of a library or a binary.
|
||||||
BuildMode Kind of build: debug, release, danger
|
|
||||||
User
|
User
|
||||||
UserRaw
|
UserRaw
|
||||||
XDeclaredButNotUsed Unused symbols in the code.
|
XDeclaredButNotUsed Unused symbols in the code.
|
||||||
|
|
|
||||||
|
|
@ -1205,24 +1205,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
registerPass graph, semPass
|
registerPass graph, semPass
|
||||||
compileProject(graph)
|
compileProject(graph)
|
||||||
if conf.errorCounter == 0:
|
if conf.errorCounter == 0:
|
||||||
# xxx deduplicate with D20210419T170230
|
genSuccessX(graph.config)
|
||||||
let mem =
|
|
||||||
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
|
||||||
else: formatSize(getTotalMem()) & " totmem"
|
|
||||||
let loc = $conf.linesCompiled
|
|
||||||
let build = if isDefined(conf, "danger"): "Dangerous Release build"
|
|
||||||
elif isDefined(conf, "release"): "Release build"
|
|
||||||
else: "***SLOW, DEBUG BUILD***; -d:release makes code run faster."
|
|
||||||
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
|
|
||||||
let project = if conf.filenameOption == foAbs: $conf.projectFull else: $conf.projectName
|
|
||||||
rawMessage(conf, hintSuccessX, [
|
|
||||||
"loc", loc,
|
|
||||||
"sec", sec,
|
|
||||||
"mem", mem,
|
|
||||||
"project", project,
|
|
||||||
"output", ""
|
|
||||||
])
|
|
||||||
rawMessage(conf, hintBuildMode, build)
|
|
||||||
|
|
||||||
proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
|
proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
|
||||||
var p = parseopt.initOptParser(cmd)
|
var p = parseopt.initOptParser(cmd)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ type
|
||||||
backend ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
|
backend ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
|
||||||
## and `nim js` would imply backend=js
|
## and `nim js` would imply backend=js
|
||||||
libPath ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
|
libPath ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
|
||||||
|
gc ## gc selected
|
||||||
|
|
||||||
MultipleValueSetting* {.pure.} = enum ## \
|
MultipleValueSetting* {.pure.} = enum ## \
|
||||||
## settings resulting in a seq of string values
|
## settings resulting in a seq of string values
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,7 @@ proc isSuccess(input: string): bool =
|
||||||
# that may appear in user config (eg: `--filenames`).
|
# that may appear in user config (eg: `--filenames`).
|
||||||
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
|
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
|
||||||
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
|
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
|
||||||
input.startsWith("Hint: ") and
|
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
||||||
(input.endsWith("[SuccessX]") or input.endsWith("[BuildMode]"))
|
|
||||||
|
|
||||||
proc getFileDir(filename: string): string =
|
proc getFileDir(filename: string): string =
|
||||||
result = filename.splitFile().dir
|
result = filename.splitFile().dir
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ proc isDots(a: string): bool =
|
||||||
a.startsWith(".") and a.strip(chars = {'.'}) == ""
|
a.startsWith(".") and a.strip(chars = {'.'}) == ""
|
||||||
|
|
||||||
const
|
const
|
||||||
defaultHintsOff = "--hint:successx:off --hint:buildmode:off --hint:exec:off --hint:link:off --hint:cc:off --hint:conf:off --hint:processing:off --hint:QuitCalled:off"
|
defaultHintsOff = "--hint:successx:off --hint:exec:off --hint:link:off --hint:cc:off --hint:conf:off --hint:processing:off --hint:QuitCalled:off"
|
||||||
# useful when you want to turn only some hints on, and some common ones off.
|
# useful when you want to turn only some hints on, and some common ones off.
|
||||||
# pending https://github.com/timotheecour/Nim/issues/453, simplify to: `--hints:off`
|
# pending https://github.com/timotheecour/Nim/issues/453, simplify to: `--hints:off`
|
||||||
nim = getCurrentCompilerExe()
|
nim = getCurrentCompilerExe()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue