diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-01-07 12:21:42 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-01-07 12:21:42 +0100 |
commit | 51c45c72014381ebca7fce83559d48f28557b9de (patch) | |
tree | 86c87c86301436778c36a2626c1a3a76fc131739 /compiler | |
parent | 08af53032b731fb999cb24c198c8723977316938 (diff) | |
download | Nim-51c45c72014381ebca7fce83559d48f28557b9de.tar.gz |
symbol files: introduce more switches for debugging
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgmerge.nim | 2 | ||||
-rw-r--r-- | compiler/cgen.nim | 1 | ||||
-rw-r--r-- | compiler/commands.nim | 9 | ||||
-rw-r--r-- | compiler/main.nim | 2 | ||||
-rw-r--r-- | compiler/options.nim | 10 | ||||
-rw-r--r-- | compiler/rodread.nim | 7 |
6 files changed, 20 insertions, 11 deletions
diff --git a/compiler/ccgmerge.nim b/compiler/ccgmerge.nim index 58a03ecd2..f667be70f 100644 --- a/compiler/ccgmerge.nim +++ b/compiler/ccgmerge.nim @@ -96,7 +96,7 @@ proc writeIntSet(a: IntSet, s: var string) = s.add('}') proc genMergeInfo*(m: BModule): Rope = - if optSymbolFiles notin gGlobalOptions: return nil + if not compilationCachePresent: return nil var s = "/*\tNIM_merge_INFO:" s.add(tnl) s.add("typeCache:{") diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 5ea7f84e6..630426cfd 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1336,7 +1336,6 @@ proc getCFile(m: BModule): string = proc myOpenCached(graph: ModuleGraph; module: PSym, rd: PRodReader): PPassContext = injectG(graph.config) - assert optSymbolFiles in gGlobalOptions var m = newModule(g, module) readMergeInfo(getCFile(m), m) result = m diff --git a/compiler/commands.nim b/compiler/commands.nim index 386d7bda8..2d9f76959 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -261,7 +261,7 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool = of "assertions", "a": result = contains(gOptions, optAssert) of "deadcodeelim": result = contains(gGlobalOptions, optDeadCodeElim) of "run", "r": result = contains(gGlobalOptions, optRun) - of "symbolfiles": result = contains(gGlobalOptions, optSymbolFiles) + of "symbolfiles": result = gSymbolFiles != disabledSf of "genscript": result = contains(gGlobalOptions, optGenScript) of "threads": result = contains(gGlobalOptions, optThreads) of "taintmode": result = contains(gGlobalOptions, optTaintMode) @@ -598,7 +598,12 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; expectNoArg(switch, arg, pass, info) helpOnError(pass) of "symbolfiles": - processOnOffSwitchG({optSymbolFiles}, arg, pass, info) + case arg.normalize + of "on": gSymbolFiles = enabledSf + of "off": gSymbolFiles = disabledSf + of "writeonly": gSymbolFiles = writeOnlySf + of "readonly": gSymbolFiles = readOnlySf + else: localError(info, errOnOrOffExpectedButXFound, arg) of "skipcfg": expectNoArg(switch, arg, pass, info) incl(gGlobalOptions, optSkipConfigFile) diff --git a/compiler/main.nim b/compiler/main.nim index 08fc4b138..9bf8bb7c0 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -21,7 +21,7 @@ import from magicsys import systemModule, resetSysTypes proc rodPass = - if optSymbolFiles in gGlobalOptions: + if gSymbolFiles in {enabledSf, writeOnlySf}: registerPass(rodwritePass) proc codegenPass = diff --git a/compiler/options.nim b/compiler/options.nim index 8c4fe485e..0732e4989 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -48,7 +48,6 @@ type # please make sure we have under 32 options optGenScript, # generate a script file to compile the *.c files optGenMapping, # generate a mapping file optRun, # run the compiled project - optSymbolFiles, # use symbol files for speeding up compilation optCaasEnabled # compiler-as-a-service is running optSkipConfigFile, # skip the general config file optSkipProjConfigFile, # skip the project's config file @@ -147,12 +146,19 @@ var newDestructors*: bool gDynlibOverrideAll*: bool +type + SymbolFilesOption* = enum + disabledSf, enabledSf, writeOnlySf, readOnlySf + +var gSymbolFiles*: SymbolFilesOption + proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools} proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc template preciseStack*(): bool = gPreciseStack template compilationCachePresent*: untyped = - {optCaasEnabled, optSymbolFiles} * gGlobalOptions != {} + gSymbolFiles in {enabledSf, writeOnlySf} +# {optCaasEnabled, optSymbolFiles} * gGlobalOptions != {} template optPreserveOrigSource*: untyped = optEmbedOrigSrc in gGlobalOptions diff --git a/compiler/rodread.nim b/compiler/rodread.nim index 83765c1b7..dfa8fc52b 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -861,12 +861,11 @@ proc loadMethods(r: PRodReader) = if r.s[r.pos] == ' ': inc(r.pos) proc getHash*(fileIdx: int32): SecureHash = - internalAssert fileIdx >= 0 and fileIdx < gMods.len - - if gMods[fileIdx].hashDone: + if fileIdx <% gMods.len and gMods[fileIdx].hashDone: return gMods[fileIdx].hash result = secureHashFile(fileIdx.toFullPath) + if fileIdx >= gMods.len: setLen(gMods, fileIdx+1) gMods[fileIdx].hash = result template growCache*(cache, pos) = @@ -912,7 +911,7 @@ proc checkDep(fileIdx: int32; cache: IdentCache): TReasonForRecompile = proc handleSymbolFile*(module: PSym; cache: IdentCache): PRodReader = let fileIdx = module.fileIdx - if optSymbolFiles notin gGlobalOptions: + if gSymbolFiles in {disabledSf, writeOnlySf}: module.id = getID() return nil idgen.loadMaxIds(options.gProjectPath / options.gProjectName) |