got rid of platdef.c; compiler now always does linking step
This commit is contained in:
parent
8ce705f686
commit
f56816def0
12 changed files with 39 additions and 51 deletions
22
koch.nim
22
koch.nim
|
|
@ -41,7 +41,7 @@ proc tryExec(cmd: string): bool =
|
||||||
result = execShellCmd(cmd) == 0
|
result = execShellCmd(cmd) == 0
|
||||||
|
|
||||||
proc csource(args: string) =
|
proc csource(args: string) =
|
||||||
exec("nimrod cc $# -r tools/niminst --var:version=$# csource rod/nimrod $2" %
|
exec("nimrod cc $1 -r tools/niminst --var:version=$2 csource rod/nimrod $1" %
|
||||||
[args, NimrodVersion])
|
[args, NimrodVersion])
|
||||||
|
|
||||||
proc zip(args: string) =
|
proc zip(args: string) =
|
||||||
|
|
@ -75,22 +75,8 @@ proc nim(args: string) = exec(compileNimCmd(args))
|
||||||
|
|
||||||
# -------------- boot ---------------------------------------------------------
|
# -------------- boot ---------------------------------------------------------
|
||||||
|
|
||||||
proc writePlatdefC =
|
|
||||||
const
|
const
|
||||||
PlatdefCTmpl = """
|
bootOptions = "" # options to pass to the bootstrap process
|
||||||
/* Generated by boot.nim */
|
|
||||||
char* nimOS(void) { return "$#"; }
|
|
||||||
char* nimCPU(void) { return "$#"; }
|
|
||||||
"""
|
|
||||||
var f: TFile
|
|
||||||
if open(f, "build/platdef.c", fmWrite):
|
|
||||||
write(f, PlatdefcTmpl % [system.hostOS, system.hostCPU])
|
|
||||||
close(f)
|
|
||||||
else:
|
|
||||||
quit("Cannot write 'build/platdef.c'\n")
|
|
||||||
|
|
||||||
const
|
|
||||||
bootOptions = "" # "--compile:build/platdef.c"
|
|
||||||
|
|
||||||
proc findStartNimrod: string =
|
proc findStartNimrod: string =
|
||||||
const buildScript = "build.sh"
|
const buildScript = "build.sh"
|
||||||
|
|
@ -118,10 +104,9 @@ proc findStartNimrod: string =
|
||||||
|
|
||||||
proc bootIteration(args: string): bool =
|
proc bootIteration(args: string): bool =
|
||||||
var nimrod1 = "rod" / "nimrod1".exe
|
var nimrod1 = "rod" / "nimrod1".exe
|
||||||
if not ExistsFile("rod" / "nimrod".exe):
|
|
||||||
quit("no binary has been created! Failed! Try with --forcebuild")
|
|
||||||
moveFile nimrod1, "rod" / "nimrod".exe
|
moveFile nimrod1, "rod" / "nimrod".exe
|
||||||
exec "rod" / "nimrod1 cc $# $# rod/nimrod.nim" % [bootOptions, args]
|
exec "rod" / "nimrod1 cc $# $# rod/nimrod.nim" % [bootOptions, args]
|
||||||
|
# Nimrod does not produce an executable again if nothing changed. That's ok:
|
||||||
result = sameFileContent("rod" / "nimrod".exe, nimrod1)
|
result = sameFileContent("rod" / "nimrod".exe, nimrod1)
|
||||||
if result:
|
if result:
|
||||||
moveFile "bin" / "nimrod".exe, "rod" / "nimrod".exe
|
moveFile "bin" / "nimrod".exe, "rod" / "nimrod".exe
|
||||||
|
|
@ -129,7 +114,6 @@ proc bootIteration(args: string): bool =
|
||||||
removeFile nimrod1
|
removeFile nimrod1
|
||||||
|
|
||||||
proc boot(args: string) =
|
proc boot(args: string) =
|
||||||
#writePlatdefC()
|
|
||||||
echo "iteration: 1"
|
echo "iteration: 1"
|
||||||
exec findStartNimrod() & " cc $# $# rod" / "nimrod.nim" % [bootOptions, args]
|
exec findStartNimrod() & " cc $# $# rod" / "nimrod.nim" % [bootOptions, args]
|
||||||
echo "iteration: 2"
|
echo "iteration: 2"
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type
|
||||||
proc zipError(z: var TZipArchive) =
|
proc zipError(z: var TZipArchive) =
|
||||||
var e: ref EIO
|
var e: ref EIO
|
||||||
new(e)
|
new(e)
|
||||||
e.msg = zip_strerror(z.w)
|
e.msg = $zip_strerror(z.w)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =
|
proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =
|
||||||
|
|
|
||||||
|
|
@ -265,9 +265,9 @@ type
|
||||||
lua_Chunkwriter* = lua_Writer
|
lua_Chunkwriter* = lua_Writer
|
||||||
|
|
||||||
#
|
#
|
||||||
#** {======================================================================
|
#** ======================================================================
|
||||||
#** Debug API
|
#** Debug API
|
||||||
#** =======================================================================
|
#** ======================================================================
|
||||||
#
|
#
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -305,9 +305,9 @@ type
|
||||||
lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.}
|
lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.}
|
||||||
|
|
||||||
#
|
#
|
||||||
#** {======================================================================
|
#** ======================================================================
|
||||||
#** Debug API
|
#** Debug API
|
||||||
#** =======================================================================
|
#** ======================================================================
|
||||||
#
|
#
|
||||||
|
|
||||||
proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl,
|
proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl,
|
||||||
|
|
|
||||||
|
|
@ -1622,8 +1622,7 @@ proc genComplexConst(p: BProc, sym: PSym, d: var TLoc) =
|
||||||
putLocIntoDest(p, d, sym.loc)
|
putLocIntoDest(p, d, sym.loc)
|
||||||
|
|
||||||
proc genStmtListExpr(p: BProc, n: PNode, d: var TLoc) =
|
proc genStmtListExpr(p: BProc, n: PNode, d: var TLoc) =
|
||||||
var length: int
|
var length = sonsLen(n)
|
||||||
length = sonsLen(n)
|
|
||||||
for i in countup(0, length - 2): genStmts(p, n.sons[i])
|
for i in countup(0, length - 2): genStmts(p, n.sons[i])
|
||||||
if length > 0: expr(p, n.sons[length - 1], d)
|
if length > 0: expr(p, n.sons[length - 1], d)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -704,8 +704,7 @@ proc getInitName(m: PSym): PRope =
|
||||||
result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)])
|
result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)])
|
||||||
|
|
||||||
proc registerModuleToMain(m: PSym) =
|
proc registerModuleToMain(m: PSym) =
|
||||||
var initname: PRope
|
var initname = getInitName(m)
|
||||||
initname = getInitName(m)
|
|
||||||
appff(mainModProcs, "N_NOINLINE(void, $1)(void);$n",
|
appff(mainModProcs, "N_NOINLINE(void, $1)(void);$n",
|
||||||
"declare void $1() noinline$n", [initname])
|
"declare void $1() noinline$n", [initname])
|
||||||
if not (sfSystemModule in m.flags):
|
if not (sfSystemModule in m.flags):
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import
|
||||||
os, ropes, idents, ast, pnimsyn, rnimsyn, msgs, wordrecg, syntaxes
|
os, ropes, idents, ast, pnimsyn, rnimsyn, msgs, wordrecg, syntaxes
|
||||||
|
|
||||||
proc modifyPragmas(n: PNode, name: string) =
|
proc modifyPragmas(n: PNode, name: string) =
|
||||||
|
if n == nil: return
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.kind == nkIdent and whichKeyword(it.ident) == wImportc:
|
if it.kind == nkIdent and whichKeyword(it.ident) == wImportc:
|
||||||
|
|
|
||||||
|
|
@ -408,7 +408,6 @@ proc CallCCompiler(projectfile: string) =
|
||||||
if (gGlobalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}):
|
if (gGlobalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}):
|
||||||
return # speed up that call if only compiling and no script shall be
|
return # speed up that call if only compiling and no script shall be
|
||||||
# generated
|
# generated
|
||||||
if (toCompile.head == nil) and (externalToCompile.head == nil): return
|
|
||||||
fileCounter = 0
|
fileCounter = 0
|
||||||
var c = ccompiler
|
var c = ccompiler
|
||||||
var script: PRope = nil
|
var script: PRope = nil
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,9 @@ proc CommandCheck(filename: string) =
|
||||||
proc CommandCompileToC(filename: string) =
|
proc CommandCompileToC(filename: string) =
|
||||||
semanticPasses()
|
semanticPasses()
|
||||||
registerPass(cgen.cgenPass())
|
registerPass(cgen.cgenPass())
|
||||||
registerPass(rodwrite.rodwritePass()) #registerPass(cleanupPass());
|
registerPass(rodwrite.rodwritePass())
|
||||||
compileProject(filename) #for i := low(TTypeKind) to high(TTypeKind) do
|
#registerPass(cleanupPass())
|
||||||
# MessageOut('kind: ' +{&} typeKindToStr[i] +{&} ' = ' +{&} toString(sameTypeA[i]));
|
compileProject(filename)
|
||||||
extccomp.CallCCompiler(changeFileExt(filename, ""))
|
extccomp.CallCCompiler(changeFileExt(filename, ""))
|
||||||
|
|
||||||
proc CommandCompileToEcmaScript(filename: string) =
|
proc CommandCompileToEcmaScript(filename: string) =
|
||||||
|
|
@ -123,7 +123,6 @@ proc CommandCompileToEcmaScript(filename: string) =
|
||||||
compileProject(filename)
|
compileProject(filename)
|
||||||
|
|
||||||
proc CommandInteractive() =
|
proc CommandInteractive() =
|
||||||
var m: PSym
|
|
||||||
incl(gGlobalOptions, optSafeCode)
|
incl(gGlobalOptions, optSafeCode)
|
||||||
setTarget(osNimrodVM, cpuNimrodVM)
|
setTarget(osNimrodVM, cpuNimrodVM)
|
||||||
initDefines()
|
initDefines()
|
||||||
|
|
@ -133,7 +132,7 @@ proc CommandInteractive() =
|
||||||
registerPass(evals.evalPass()) # load system module:
|
registerPass(evals.evalPass()) # load system module:
|
||||||
discard CompileModule(JoinPath(options.libpath, addFileExt("system", nimExt)),
|
discard CompileModule(JoinPath(options.libpath, addFileExt("system", nimExt)),
|
||||||
false, true)
|
false, true)
|
||||||
m = newModule("stdin")
|
var m = newModule("stdin")
|
||||||
m.id = getID()
|
m.id = getID()
|
||||||
incl(m.flags, sfMainModule)
|
incl(m.flags, sfMainModule)
|
||||||
processModule(m, "stdin", LLStreamOpenStdIn(), nil)
|
processModule(m, "stdin", LLStreamOpenStdIn(), nil)
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,7 @@ var
|
||||||
proc setTarget*(o: TSystemOS, c: TSystemCPU) =
|
proc setTarget*(o: TSystemOS, c: TSystemCPU) =
|
||||||
assert(c != cpuNone)
|
assert(c != cpuNone)
|
||||||
assert(o != osNone)
|
assert(o != osNone)
|
||||||
|
#echo "new Target: OS: ", o, " CPU: ", c
|
||||||
targetCPU = c
|
targetCPU = c
|
||||||
targetOS = o
|
targetOS = o
|
||||||
intSize = cpu[c].intSize div 8
|
intSize = cpu[c].intSize div 8
|
||||||
|
|
@ -203,11 +204,6 @@ proc NameToCPU(name: string): TSystemCPU =
|
||||||
return i
|
return i
|
||||||
result = cpuNone
|
result = cpuNone
|
||||||
|
|
||||||
#proc nimCPU(): cstring{.importc, noconv.}
|
|
||||||
#proc nimOS(): cstring{.importc, noconv.}
|
|
||||||
|
|
||||||
#hostCPU = nameToCPU($nimCPU())
|
|
||||||
#hostOS = nameToOS($nimOS())
|
|
||||||
hostCPU = nameToCPU(system.hostCPU)
|
hostCPU = nameToCPU(system.hostCPU)
|
||||||
hostOS = nameToOS(system.hostOS)
|
hostOS = nameToOS(system.hostOS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,10 @@ type
|
||||||
# needs so much look-ahead
|
# needs so much look-ahead
|
||||||
|
|
||||||
|
|
||||||
var gLinesCompiled*: int
|
var gLinesCompiled*: int # all lines that have been compiled
|
||||||
|
|
||||||
proc pushInd*(L: var TLexer, indent: int)
|
proc pushInd*(L: var TLexer, indent: int)
|
||||||
# all lines that have been compiled
|
|
||||||
proc popInd*(L: var TLexer)
|
proc popInd*(L: var TLexer)
|
||||||
proc isKeyword*(kind: TTokType): bool
|
proc isKeyword*(kind: TTokType): bool
|
||||||
proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream)
|
proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream)
|
||||||
|
|
@ -130,7 +130,7 @@ proc getLineInfo*(L: TLexer): TLineInfo
|
||||||
proc closeLexer*(lex: var TLexer)
|
proc closeLexer*(lex: var TLexer)
|
||||||
proc PrintTok*(tok: PToken)
|
proc PrintTok*(tok: PToken)
|
||||||
proc tokToStr*(tok: PToken): string
|
proc tokToStr*(tok: PToken): string
|
||||||
# auxiliary functions:
|
|
||||||
proc lexMessage*(L: TLexer, msg: TMsgKind, arg: string = "")
|
proc lexMessage*(L: TLexer, msg: TMsgKind, arg: string = "")
|
||||||
# the Pascal scanner uses this too:
|
# the Pascal scanner uses this too:
|
||||||
proc fillToken*(L: var TToken)
|
proc fillToken*(L: var TToken)
|
||||||
|
|
@ -142,7 +142,7 @@ proc isKeyword(kind: TTokType): bool =
|
||||||
proc isNimrodIdentifier*(s: string): bool =
|
proc isNimrodIdentifier*(s: string): bool =
|
||||||
if s[0] in SymStartChars:
|
if s[0] in SymStartChars:
|
||||||
for c in items(s):
|
for c in items(s):
|
||||||
if c notin SymChars: return
|
if c notin SymChars+{'_'}: return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc pushInd(L: var TLexer, indent: int) =
|
proc pushInd(L: var TLexer, indent: int) =
|
||||||
|
|
|
||||||
|
|
@ -65,11 +65,6 @@ case $ucpu in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# add(result, "# write ``build/platdef.c`` file\n")
|
|
||||||
cat >build/platdef.c <<EOF
|
|
||||||
char* nimOS(void) { return "$myos"; }
|
|
||||||
char* nimCPU(void) { return "$mycpu"; }
|
|
||||||
EOF
|
|
||||||
# add(result, "# call the compiler:\n")
|
# add(result, "# call the compiler:\n")
|
||||||
|
|
||||||
case $myos in
|
case $myos in
|
||||||
|
|
@ -78,13 +73,12 @@ case $myos in
|
||||||
case $mycpu in
|
case $mycpu in
|
||||||
# for cpuA in 1..c.cpus.len:
|
# for cpuA in 1..c.cpus.len:
|
||||||
?{c.cpus[cpuA-1]})
|
?{c.cpus[cpuA-1]})
|
||||||
# var linkCmd = "build/platdef.o"
|
# var linkCmd = ""
|
||||||
# for f in items(c.cfiles[osA][cpuA]):
|
# for f in items(c.cfiles[osA][cpuA]):
|
||||||
echo "$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}"
|
echo "$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}"
|
||||||
$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")} || exit 1
|
$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")} || exit 1
|
||||||
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
|
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
|
||||||
# end for
|
# end for
|
||||||
$CC $COMP_FLAGS -Ibuild -c build/platdef.c -o build/platdef.o || exit 1
|
|
||||||
echo "$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd"
|
echo "$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd"
|
||||||
$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd || exit 1
|
$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd || exit 1
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
17
web/news.txt
17
web/news.txt
|
|
@ -2,6 +2,23 @@
|
||||||
News
|
News
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
|
2009-XX-XX Version 0.8.6 released
|
||||||
|
=================================
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
Additions
|
||||||
|
---------
|
||||||
|
|
||||||
|
Changes affecting backwards compatibility
|
||||||
|
-----------------------------------------
|
||||||
|
- The compiler does not skip the linking step anymore even if no file
|
||||||
|
has changed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2009-10-21 Version 0.8.2 released
|
2009-10-21 Version 0.8.2 released
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue