From a702524ae456d8272480d460a3c42705be91ea24 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 23 Oct 2011 22:45:52 +0200 Subject: [PATCH] compilation cache: better dependency checking --- compiler/main.nim | 1 + compiler/options.nim | 12 ++++++------ compiler/rodread.nim | 17 ++++++++++++++--- compiler/rodwrite.nim | 10 ++++++++++ todo.txt | 8 +++----- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/compiler/main.nim b/compiler/main.nim index f09ceb997..f8c6860fd 100755 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -171,6 +171,7 @@ proc CommandScan(filename: string) = proc CommandSuggest(filename: string) = msgs.gErrorMax = high(int) # do not stop after first error semanticPasses() + registerPass(rodwrite.rodwritePass()) compileProject(filename) proc WantFile(filename: string) = diff --git a/compiler/options.nim b/compiler/options.nim index 55ed8cb59..891fca8ae 100755 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -27,7 +27,7 @@ type # please make sure we have under 32 options # (for interfacing with C) optProfiler # profiler turned on TOptions* = set[TOption] - TGlobalOption* = enum + TGlobalOption* = enum # **keep binary compatible** gloptNone, optForceFullMake, optBoehmGC, optRefcGC, optDeadCodeElim, optListCmd, optCompileOnly, optNoLinking, optSafeCode, # only allow safe code @@ -51,6 +51,7 @@ type # please make sure we have under 32 options TGlobalOptions* = set[TGlobalOption] TCommands* = enum # Nimrod's commands + # **keep binary compatible** cmdNone, cmdCompileToC, cmdCompileToCpp, cmdCompileToOC, cmdCompileToEcmaScript, cmdCompileToLLVM, cmdInterpret, cmdPretty, cmdDoc, cmdGenDepend, cmdDump, @@ -93,10 +94,10 @@ const DocTexConfig* = "nimdoc.tex.cfg" # additional configuration variables: -var - gConfigVars*: PStringTable - libpath*: string = "" - projectPath*: string = "" +var + gConfigVars* = newStringTable(modeStyleInsensitive) + libpath* = "" + projectPath* = "" projectName* = "" nimcacheDir* = "" gKeepComments*: bool = true # whether the parser needs to keep comments @@ -200,4 +201,3 @@ proc binaryStrSearch*(x: openarray[string], y: string): int = return mid result = - 1 -gConfigVars = newStringTable(modeStyleInsensitive) diff --git a/compiler/rodread.nim b/compiler/rodread.nim index baffac4c4..6da2c9532 100755 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -24,6 +24,8 @@ # - a section containing the compiler options and defines this # module has been compiled with: # OPTIONS:options\n +# GOPTIONS:options\n # global options +# CMD:command\n # DEFINES:defines\n # - FILES( # myfile.inc @@ -106,7 +108,8 @@ const "symbol file for $1 has the wrong version", "file edited since last compilation: $1", "list of conditional symbols changed for: $1", - "list of options changed for: $1", "an include file edited: $1", + "list of options changed for: $1", + "an include file edited: $1", "a module $1 depends on has changed"] type @@ -139,7 +142,7 @@ type PRodReader* = ref TRodReader const - FileVersion* = "1023" # modify this if the rod-format changes! + FileVersion* = "1024" # modify this if the rod-format changes! var rodCompilerprocs*: TStrTable @@ -501,7 +504,15 @@ proc processRodFile(r: PRodReader, crc: TCrc32) = inc(r.pos) # skip ':' r.options = cast[TOptions](int32(decodeVInt(r.s, r.pos))) if options.gOptions != r.options: r.reason = rrOptions - of "DEFINES": + of "GOPTIONS": + inc(r.pos) # skip ':' + var dep = cast[TGlobalOptions](int32(decodeVInt(r.s, r.pos))) + if gGlobalOptions != dep: r.reason = rrOptions + of "CMD": + inc(r.pos) # skip ':' + var dep = cast[TCommands](int32(decodeVInt(r.s, r.pos))) + if gCmd != dep: r.reason = rrOptions + of "DEFINES": inc(r.pos) # skip ':' d = 0 while r.s[r.pos] > '\x0A': diff --git a/compiler/rodwrite.nim b/compiler/rodwrite.nim index faea83d9a..0aa7b3b57 100755 --- a/compiler/rodwrite.nim +++ b/compiler/rodwrite.nim @@ -421,6 +421,16 @@ proc writeRod(w: PRodWriter) = encodeVInt(cast[int32](w.options), options) f.write(options) f.write(rodNL) + + var goptions = "GOPTIONS:" + encodeVInt(cast[int32](gGlobalOptions), goptions) + f.write(goptions) + f.write(rodNL) + + var cmd = "CMD:" + encodeVInt(cast[int32](gCmd), cmd) + f.write(cmd) + f.write(rodNL) f.write("DEFINES:") f.write(w.defines) diff --git a/todo.txt b/todo.txt index 0b39daa51..05f6c2f1f 100755 --- a/todo.txt +++ b/todo.txt @@ -29,8 +29,6 @@ incremental compilation - test G, A, B example from the documentation - test init sections -- fix remaining bugs - version 0.9.0 ============= @@ -66,9 +64,9 @@ Bugs result = forward(x) - bug: DLL generation is broken -- bug: stress testing basic method example (eval) without ``-d:relase`` leaks - memory; good way to figure out how a fixed amount of stack can hold - an arbitrary number of GC roots! +- bug: stress testing basic method example (eval example) + without ``-d:relase`` leaks memory; good way to figure out how a + fixed amount of stack can hold an arbitrary number of GC roots! version 0.9.XX