From 616db85c615d9cf00a1c3b85e59cf6401fed915b Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Sat, 28 Oct 2017 02:38:31 -0500 Subject: Let the environment variable NIMBLE_DIR overrides nimblepath in cfg file (#6542) * Let the environment variable NIMBLE_DIR overrides nimblepath in cfg file If the length of NIMBLE_DIR is larger than zero, the nimblepath will be set to $NIMBLE_DIR/pkgs --- compiler/commands.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index bae1fda38..71de28e09 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -343,7 +343,9 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; # keep the old name for compat if pass in {passCmd2, passPP} and not options.gNoNimblePath: expectArg(switch, arg, pass, info) - let path = processPath(arg, info, notRelativeToProj=true) + var path = processPath(arg, info, notRelativeToProj=true) + let nimbleDir = getEnv("NIMBLE_DIR") + if nimbleDir.len > 0 and pass == passPP: path = nimbleDir / "pkgs" nimblePath(path, info) of "nonimblepath", "nobabelpath": expectNoArg(switch, arg, pass, info) -- cgit 1.4.1-2-gfad0 From 49320add23a3df1112727f280f4bf5346221f7f9 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sat, 18 Nov 2017 14:46:19 +0100 Subject: Do not include date in binaries (#6581) and do not claim copyright for 2018 in order to make nim package builds reproducible. See https://reproducible-builds.org/ for why this is good. --- compiler/cgen.nim | 7 ++++--- compiler/commands.nim | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/commands.nim') diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 2a979e8c5..07c2824d0 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -896,14 +896,15 @@ proc addIntTypes(result: var Rope) {.inline.} = platform.CPU[targetCPU].intSize.rope]) proc getCopyright(cfile: Cfile): Rope = + const copyrightYear = "2017" if optCompileOnly in gGlobalOptions: result = ("/* Generated by Nim Compiler v$1 */$N" & - "/* (c) " & CompileDate.substr(0, 3) & " Andreas Rumpf */$N" & + "/* (c) " & copyrightYear & " Andreas Rumpf */$N" & "/* The generated code is subject to the original license. */$N") % [rope(VersionAsString)] else: result = ("/* Generated by Nim Compiler v$1 */$N" & - "/* (c) " & CompileDate.substr(0, 3) & " Andreas Rumpf */$N" & + "/* (c) " & copyrightYear & " Andreas Rumpf */$N" & "/* The generated code is subject to the original license. */$N" & "/* Compiled for: $2, $3, $4 */$N" & "/* Command for C compiler:$n $5 */$N") % @@ -1292,7 +1293,7 @@ proc myOpen(graph: ModuleGraph; module: PSym; cache: IdentCache): PPassContext = proc writeHeader(m: BModule) = var result = ("/* Generated by Nim Compiler v$1 */$N" & - "/* (c) " & CompileDate.substr(0, 3) & " Andreas Rumpf */$N" & + "/* (c) 2017 Andreas Rumpf */$N" & "/* The generated code is subject to the original license. */$N") % [rope(VersionAsString)] diff --git a/compiler/commands.nim b/compiler/commands.nim index 71de28e09..11a66cf55 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -53,8 +53,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; # implementation const - HelpMessage = "Nim Compiler Version $1 (" & CompileDate & ") [$2: $3]\n" & - "Copyright (c) 2006-" & CompileDate.substr(0, 3) & " by Andreas Rumpf\n" + HelpMessage = "Nim Compiler Version $1 [$2: $3]\n" & + "Copyright (c) 2006-2017 by Andreas Rumpf\n" const Usage = slurp"../doc/basicopt.txt".replace("//", "") -- cgit 1.4.1-2-gfad0 From c7ba4d91a34882e94969595ba70763f9f642423c Mon Sep 17 00:00:00 2001 From: Charlie Barto Date: Wed, 6 Dec 2017 03:56:44 -0500 Subject: add dynlibOverrideAll switch (#6873) --- compiler/commands.nim | 3 +++ compiler/options.nim | 3 ++- doc/advopt.txt | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index 11a66cf55..de474c6e6 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -654,6 +654,9 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; gListFullPaths = true of "dynliboverride": dynlibOverride(switch, arg, pass, info) + of "dynliboverrideall": + expectNoArg(switch, arg, pass, info) + gDynlibOverrideAll = true of "cs": # only supported for compatibility. Does nothing. expectArg(switch, arg, pass, info) diff --git a/compiler/options.nim b/compiler/options.nim index eec9ce448..8c4fe485e 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -145,6 +145,7 @@ var gNoNimblePath* = false gExperimentalMode*: bool newDestructors*: bool + gDynlibOverrideAll*: bool proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools} proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc @@ -427,7 +428,7 @@ proc inclDynlibOverride*(lib: string) = gDllOverrides[lib.canonDynlibName] = "true" proc isDynlibOverride*(lib: string): bool = - result = gDllOverrides.hasKey(lib.canonDynlibName) + result = gDynlibOverrideAll or gDllOverrides.hasKey(lib.canonDynlibName) proc binaryStrSearch*(x: openArray[string], y: string): int = var a = 0 diff --git a/doc/advopt.txt b/doc/advopt.txt index 60fd081b8..ab10d65ba 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -79,6 +79,7 @@ Advanced options: symbol matching is fuzzy so that --dynlibOverride:lua matches dynlib: "liblua.so.3" + --dynlibOverrideAll makes the dynlib pragma have no effect --listCmd list the commands used to execute external programs --parallelBuild:0|1|... perform a parallel build value = number of processors (0 for auto-detect) -- cgit 1.4.1-2-gfad0 From da90657317e8a57bae80ebd2d637a972d3b438ab Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 21 Dec 2017 17:14:31 +0100 Subject: make the new --genDeps feature optional since it makes compilations slower --- compiler/commands.nim | 2 +- compiler/main.nim | 3 ++- doc/advopt.txt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/commands.nim') diff --git a/compiler/commands.nim b/compiler/commands.nim index de474c6e6..386d7bda8 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -611,7 +611,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "skipparentcfg": expectNoArg(switch, arg, pass, info) incl(gGlobalOptions, optSkipParentConfigFiles) - of "genscript": + of "genscript", "gendeps": expectNoArg(switch, arg, pass, info) incl(gGlobalOptions, optGenScript) of "colors": processOnOffSwitchG({optUseColors}, arg, pass, info) diff --git a/compiler/main.nim b/compiler/main.nim index db03f0e4d..08fc4b138 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -80,7 +80,8 @@ proc commandCompileToC(graph: ModuleGraph; cache: IdentCache) = let proj = changeFileExt(gProjectFull, "") extccomp.callCCompiler(proj) extccomp.writeJsonBuildInstructions(proj) - writeDepsFile(graph, toGeneratedFile(proj, "")) + if optGenScript in gGlobalOptions: + writeDepsFile(graph, toGeneratedFile(proj, "")) proc commandJsonScript(graph: ModuleGraph; cache: IdentCache) = let proj = changeFileExt(gProjectFull, "") diff --git a/doc/advopt.txt b/doc/advopt.txt index ab10d65ba..a1210118e 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -37,6 +37,7 @@ Advanced options: --noMain do not generate a main procedure --genScript generate a compile script (in the 'nimcache' subdirectory named 'compile_$project$scriptext') + --genDeps generate a '.deps' file containing the dependencies --os:SYMBOL set the target operating system (cross-compilation) --cpu:SYMBOL set the target processor (cross-compilation) --debuginfo enables debug information -- cgit 1.4.1-2-gfad0 From 51c45c72014381ebca7fce83559d48f28557b9de Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 7 Jan 2018 12:21:42 +0100 Subject: symbol files: introduce more switches for debugging --- compiler/ccgmerge.nim | 2 +- compiler/cgen.nim | 1 - compiler/commands.nim | 9 +++++++-- compiler/main.nim | 2 +- compiler/options.nim | 10 ++++++++-- compiler/rodread.nim | 7 +++---- 6 files changed, 20 insertions(+), 11 deletions(-) (limited to 'compiler/commands.nim') 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) -- cgit 1.4.1-2-gfad0