make Nim take roughly 100MB less RAM for bootstrapping via a new compiler switch -d:leanCompiler; useful for the Raberry PI
This commit is contained in:
parent
d5e113c3a6
commit
cb4d810659
8 changed files with 110 additions and 63 deletions
|
|
@ -2030,6 +2030,9 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
let n = lowerings.wrapProcForSpawn(p.module.g.graph, p.module.module, e, e.typ, nil, nil)
|
let n = lowerings.wrapProcForSpawn(p.module.g.graph, p.module.module, e, e.typ, nil, nil)
|
||||||
expr(p, n, d)
|
expr(p, n, d)
|
||||||
of mParallel:
|
of mParallel:
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler built without support for the 'parallel' statement"
|
||||||
|
else:
|
||||||
let n = semparallel.liftParallel(p.module.g.graph, p.module.module, e)
|
let n = semparallel.liftParallel(p.module.g.graph, p.module.module, e)
|
||||||
expr(p, n, d)
|
expr(p, n, d)
|
||||||
of mDeepCopy:
|
of mDeepCopy:
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ import
|
||||||
nversion, nimsets, msgs, std / sha1, bitsets, idents, types,
|
nversion, nimsets, msgs, std / sha1, bitsets, idents, types,
|
||||||
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
|
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
|
||||||
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
|
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
|
||||||
lowerings, semparallel, tables, sets, ndi, lineinfos, pathutils, transf
|
lowerings, tables, sets, ndi, lineinfos, pathutils, transf
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
|
import semparallel
|
||||||
|
|
||||||
import strutils except `%` # collides with ropes.`%`
|
import strutils except `%` # collides with ropes.`%`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,15 @@ when not defined(nimcore):
|
||||||
import
|
import
|
||||||
llstream, strutils, ast, astalgo, lexer, syntaxes, renderer, options, msgs,
|
llstream, strutils, ast, astalgo, lexer, syntaxes, renderer, options, msgs,
|
||||||
os, condsyms, times,
|
os, condsyms, times,
|
||||||
wordrecg, sem, semdata, idents, passes, docgen, extccomp,
|
wordrecg, sem, semdata, idents, passes, extccomp,
|
||||||
cgen, jsgen, json, nversion,
|
cgen, json, nversion,
|
||||||
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
|
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
|
||||||
docgen2, parser, modules, ccgutils, sigmatch, ropes,
|
parser, modules, ccgutils, sigmatch, ropes,
|
||||||
modulegraphs, tables, rod, lineinfos, pathutils
|
modulegraphs, tables, rod, lineinfos, pathutils
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
|
import jsgen, docgen, docgen2
|
||||||
|
|
||||||
from magicsys import resetSysTypes
|
from magicsys import resetSysTypes
|
||||||
|
|
||||||
proc codegenPass(g: ModuleGraph) =
|
proc codegenPass(g: ModuleGraph) =
|
||||||
|
|
@ -57,6 +60,7 @@ proc commandCheck(graph: ModuleGraph) =
|
||||||
semanticPasses(graph) # use an empty backend for semantic checking only
|
semanticPasses(graph) # use an empty backend for semantic checking only
|
||||||
compileProject(graph)
|
compileProject(graph)
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
proc commandDoc2(graph: ModuleGraph; json: bool) =
|
proc commandDoc2(graph: ModuleGraph; json: bool) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.errorMax = high(int) # do not stop after first error
|
||||||
semanticPasses(graph)
|
semanticPasses(graph)
|
||||||
|
|
@ -84,6 +88,7 @@ proc commandJsonScript(graph: ModuleGraph) =
|
||||||
let proj = changeFileExt(graph.config.projectFull, "")
|
let proj = changeFileExt(graph.config.projectFull, "")
|
||||||
extccomp.runJsonBuildInstructions(graph.config, proj)
|
extccomp.runJsonBuildInstructions(graph.config, proj)
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
proc commandCompileToJS(graph: ModuleGraph) =
|
proc commandCompileToJS(graph: ModuleGraph) =
|
||||||
#incl(gGlobalOptions, optSafeCode)
|
#incl(gGlobalOptions, optSafeCode)
|
||||||
setTarget(graph.config.target, osJS, cpuJS)
|
setTarget(graph.config.target, osJS, cpuJS)
|
||||||
|
|
@ -177,27 +182,45 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
else:
|
else:
|
||||||
rawMessage(conf, errGenerated, "'run' command not available; rebuild with -d:tinyc")
|
rawMessage(conf, errGenerated, "'run' command not available; rebuild with -d:tinyc")
|
||||||
of "js", "compiletojs":
|
of "js", "compiletojs":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with JS code generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdCompileToJS
|
conf.cmd = cmdCompileToJS
|
||||||
commandCompileToJS(graph)
|
commandCompileToJS(graph)
|
||||||
of "doc0":
|
of "doc0":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
commandDoc(cache, conf)
|
commandDoc(cache, conf)
|
||||||
of "doc2", "doc":
|
of "doc2", "doc":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
defineSymbol(conf.symbols, "nimdoc")
|
defineSymbol(conf.symbols, "nimdoc")
|
||||||
commandDoc2(graph, false)
|
commandDoc2(graph, false)
|
||||||
of "rst2html":
|
of "rst2html":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdRst2html
|
conf.cmd = cmdRst2html
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
commandRst2Html(cache, conf)
|
commandRst2Html(cache, conf)
|
||||||
of "rst2tex":
|
of "rst2tex":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdRst2tex
|
conf.cmd = cmdRst2tex
|
||||||
loadConfigs(DocTexConfig, cache, conf)
|
loadConfigs(DocTexConfig, cache, conf)
|
||||||
commandRst2TeX(cache, conf)
|
commandRst2TeX(cache, conf)
|
||||||
of "jsondoc0":
|
of "jsondoc0":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
|
|
@ -205,18 +228,27 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
defineSymbol(conf.symbols, "nimdoc")
|
defineSymbol(conf.symbols, "nimdoc")
|
||||||
commandJson(cache, conf)
|
commandJson(cache, conf)
|
||||||
of "jsondoc2", "jsondoc":
|
of "jsondoc2", "jsondoc":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
defineSymbol(conf.symbols, "nimdoc")
|
defineSymbol(conf.symbols, "nimdoc")
|
||||||
commandDoc2(graph, true)
|
commandDoc2(graph, true)
|
||||||
of "ctags":
|
of "ctags":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
defineSymbol(conf.symbols, "nimdoc")
|
defineSymbol(conf.symbols, "nimdoc")
|
||||||
commandTags(cache, conf)
|
commandTags(cache, conf)
|
||||||
of "buildindex":
|
of "buildindex":
|
||||||
|
when defined(leanCompiler):
|
||||||
|
quit "compiler wasn't built with documentation generator"
|
||||||
|
else:
|
||||||
conf.cmd = cmdDoc
|
conf.cmd = cmdDoc
|
||||||
loadConfigs(DocConfig, cache, conf)
|
loadConfigs(DocConfig, cache, conf)
|
||||||
commandBuildIndex(cache, conf)
|
commandBuildIndex(cache, conf)
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,16 @@ import
|
||||||
procfind, lookups, pragmas, passes, semdata, semtypinst, sigmatch,
|
procfind, lookups, pragmas, passes, semdata, semtypinst, sigmatch,
|
||||||
intsets, transf, vmdef, vm, idgen, aliases, cgmeth, lambdalifting,
|
intsets, transf, vmdef, vm, idgen, aliases, cgmeth, lambdalifting,
|
||||||
evaltempl, patterns, parampatterns, sempass2, linter, semmacrosanity,
|
evaltempl, patterns, parampatterns, sempass2, linter, semmacrosanity,
|
||||||
semparallel, lowerings, pluginsupport, plugins/active, rod, lineinfos
|
lowerings, pluginsupport, plugins/active, rod, lineinfos
|
||||||
|
|
||||||
from modulegraphs import ModuleGraph, PPassContext
|
from modulegraphs import ModuleGraph, PPassContext
|
||||||
|
|
||||||
when defined(nimfix):
|
when defined(nimfix):
|
||||||
import nimfix/prettybase
|
import nimfix/prettybase
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
|
import semparallel
|
||||||
|
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.procvar.}
|
proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.procvar.}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,12 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees,
|
intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees,
|
||||||
wordrecg, strutils, options, guards, writetracking, lineinfos, semfold,
|
wordrecg, strutils, options, guards, lineinfos, semfold,
|
||||||
modulegraphs
|
modulegraphs
|
||||||
|
|
||||||
|
when not defined(leanCompiler):
|
||||||
|
import writetracking
|
||||||
|
|
||||||
when defined(useDfa):
|
when defined(useDfa):
|
||||||
import dfa
|
import dfa
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import
|
||||||
magicsys, condsyms, idents, lexer, options, parampatterns, strutils, trees,
|
magicsys, condsyms, idents, lexer, options, parampatterns, strutils, trees,
|
||||||
linter, lineinfos
|
linter, lineinfos
|
||||||
|
|
||||||
when defined(booting) or defined(nimsuggest):
|
when (defined(booting) or defined(nimsuggest)) and not defined(leanCompiler):
|
||||||
import docgen
|
import docgen
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ proc symToSuggest(conf: ConfigRef; s: PSym, isLocal: bool, section: IdeCmd, info
|
||||||
result.forth = typeToString(s.typ)
|
result.forth = typeToString(s.typ)
|
||||||
else:
|
else:
|
||||||
result.forth = ""
|
result.forth = ""
|
||||||
when defined(nimsuggest) and not defined(noDocgen):
|
when defined(nimsuggest) and not defined(noDocgen) and not defined(leanCompiler):
|
||||||
result.doc = s.extractDocComment
|
result.doc = s.extractDocComment
|
||||||
let infox = if section in {ideUse, ideHighlight, ideOutline}: info else: s.info
|
let infox = if section in {ideUse, ideHighlight, ideOutline}: info else: s.info
|
||||||
result.filePath = toFullPath(conf, infox)
|
result.filePath = toFullPath(conf, infox)
|
||||||
|
|
@ -153,7 +153,7 @@ proc `$`*(suggest: Suggest): string =
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
result.add($suggest.column)
|
result.add($suggest.column)
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
when defined(nimsuggest) and not defined(noDocgen):
|
when defined(nimsuggest) and not defined(noDocgen) and not defined(leanCompiler):
|
||||||
result.add(suggest.doc.escape)
|
result.add(suggest.doc.escape)
|
||||||
if suggest.version == 0:
|
if suggest.version == 0:
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
|
|
|
||||||
3
koch.nim
3
koch.nim
|
|
@ -51,6 +51,9 @@ Boot options:
|
||||||
-d:release produce a release version of the compiler
|
-d:release produce a release version of the compiler
|
||||||
-d:useLinenoise use the linenoise library for interactive mode
|
-d:useLinenoise use the linenoise library for interactive mode
|
||||||
(not needed on Windows)
|
(not needed on Windows)
|
||||||
|
-d:leanCompiler produce a compiler without JS codegen or
|
||||||
|
documentation generator in order to use less RAM
|
||||||
|
for bootstrapping
|
||||||
|
|
||||||
Commands for core developers:
|
Commands for core developers:
|
||||||
docs [options] generates the full documentation
|
docs [options] generates the full documentation
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue