got rid of platdef.c; compiler now always does linking step

This commit is contained in:
rumpf_a@web.de
2009-12-20 12:43:28 +01:00
parent 8ce705f686
commit f56816def0
12 changed files with 39 additions and 51 deletions

View File

@@ -41,7 +41,7 @@ proc tryExec(cmd: string): bool =
result = execShellCmd(cmd) == 0
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])
proc zip(args: string) =
@@ -75,22 +75,8 @@ proc nim(args: string) = exec(compileNimCmd(args))
# -------------- boot ---------------------------------------------------------
proc writePlatdefC =
const
PlatdefCTmpl = """
/* 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"
bootOptions = "" # options to pass to the bootstrap process
proc findStartNimrod: string =
const buildScript = "build.sh"
@@ -118,10 +104,9 @@ proc findStartNimrod: string =
proc bootIteration(args: string): bool =
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
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)
if result:
moveFile "bin" / "nimrod".exe, "rod" / "nimrod".exe
@@ -129,7 +114,6 @@ proc bootIteration(args: string): bool =
removeFile nimrod1
proc boot(args: string) =
#writePlatdefC()
echo "iteration: 1"
exec findStartNimrod() & " cc $# $# rod" / "nimrod.nim" % [bootOptions, args]
echo "iteration: 2"

View File

@@ -21,7 +21,7 @@ type
proc zipError(z: var TZipArchive) =
var e: ref EIO
new(e)
e.msg = zip_strerror(z.w)
e.msg = $zip_strerror(z.w)
raise e
proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =

View File

@@ -265,9 +265,9 @@ type
lua_Chunkwriter* = lua_Writer
#
#** {======================================================================
#** ======================================================================
#** Debug API
#** =======================================================================
#** ======================================================================
#
const
@@ -305,9 +305,9 @@ type
lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.}
#
#** {======================================================================
#** ======================================================================
#** Debug API
#** =======================================================================
#** ======================================================================
#
proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl,

View File

@@ -1622,8 +1622,7 @@ proc genComplexConst(p: BProc, sym: PSym, d: var TLoc) =
putLocIntoDest(p, d, sym.loc)
proc genStmtListExpr(p: BProc, n: PNode, d: var TLoc) =
var length: int
length = sonsLen(n)
var length = sonsLen(n)
for i in countup(0, length - 2): genStmts(p, n.sons[i])
if length > 0: expr(p, n.sons[length - 1], d)

View File

@@ -704,8 +704,7 @@ proc getInitName(m: PSym): PRope =
result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)])
proc registerModuleToMain(m: PSym) =
var initname: PRope
initname = getInitName(m)
var initname = getInitName(m)
appff(mainModProcs, "N_NOINLINE(void, $1)(void);$n",
"declare void $1() noinline$n", [initname])
if not (sfSystemModule in m.flags):

View File

@@ -14,6 +14,7 @@ import
os, ropes, idents, ast, pnimsyn, rnimsyn, msgs, wordrecg, syntaxes
proc modifyPragmas(n: PNode, name: string) =
if n == nil: return
for i in countup(0, sonsLen(n) - 1):
var it = n.sons[i]
if it.kind == nkIdent and whichKeyword(it.ident) == wImportc:

View File

@@ -408,7 +408,6 @@ proc CallCCompiler(projectfile: string) =
if (gGlobalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}):
return # speed up that call if only compiling and no script shall be
# generated
if (toCompile.head == nil) and (externalToCompile.head == nil): return
fileCounter = 0
var c = ccompiler
var script: PRope = nil

View File

@@ -109,9 +109,9 @@ proc CommandCheck(filename: string) =
proc CommandCompileToC(filename: string) =
semanticPasses()
registerPass(cgen.cgenPass())
registerPass(rodwrite.rodwritePass()) #registerPass(cleanupPass());
compileProject(filename) #for i := low(TTypeKind) to high(TTypeKind) do
# MessageOut('kind: ' +{&} typeKindToStr[i] +{&} ' = ' +{&} toString(sameTypeA[i]));
registerPass(rodwrite.rodwritePass())
#registerPass(cleanupPass())
compileProject(filename)
extccomp.CallCCompiler(changeFileExt(filename, ""))
proc CommandCompileToEcmaScript(filename: string) =
@@ -123,7 +123,6 @@ proc CommandCompileToEcmaScript(filename: string) =
compileProject(filename)
proc CommandInteractive() =
var m: PSym
incl(gGlobalOptions, optSafeCode)
setTarget(osNimrodVM, cpuNimrodVM)
initDefines()
@@ -133,7 +132,7 @@ proc CommandInteractive() =
registerPass(evals.evalPass()) # load system module:
discard CompileModule(JoinPath(options.libpath, addFileExt("system", nimExt)),
false, true)
m = newModule("stdin")
var m = newModule("stdin")
m.id = getID()
incl(m.flags, sfMainModule)
processModule(m, "stdin", LLStreamOpenStdIn(), nil)
@@ -217,7 +216,7 @@ proc CommandScan(filename: string) =
if stream != nil:
openLexer(L, f, stream)
while true:
rawGetTok(L, tok^ )
rawGetTok(L, tok^)
PrintTok(tok)
if tok.tokType == tkEof: break
CloseLexer(L)

View File

@@ -184,6 +184,7 @@ var
proc setTarget*(o: TSystemOS, c: TSystemCPU) =
assert(c != cpuNone)
assert(o != osNone)
#echo "new Target: OS: ", o, " CPU: ", c
targetCPU = c
targetOS = o
intSize = cpu[c].intSize div 8
@@ -203,11 +204,6 @@ proc NameToCPU(name: string): TSystemCPU =
return i
result = cpuNone
#proc nimCPU(): cstring{.importc, noconv.}
#proc nimOS(): cstring{.importc, noconv.}
#hostCPU = nameToCPU($nimCPU())
#hostOS = nameToOS($nimOS())
hostCPU = nameToCPU(system.hostCPU)
hostOS = nameToOS(system.hostOS)

View File

@@ -116,10 +116,10 @@ type
# needs so much look-ahead
var gLinesCompiled*: int
var gLinesCompiled*: int # all lines that have been compiled
proc pushInd*(L: var TLexer, indent: int)
# all lines that have been compiled
proc popInd*(L: var TLexer)
proc isKeyword*(kind: TTokType): bool
proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream)
@@ -130,7 +130,7 @@ proc getLineInfo*(L: TLexer): TLineInfo
proc closeLexer*(lex: var TLexer)
proc PrintTok*(tok: PToken)
proc tokToStr*(tok: PToken): string
# auxiliary functions:
proc lexMessage*(L: TLexer, msg: TMsgKind, arg: string = "")
# the Pascal scanner uses this too:
proc fillToken*(L: var TToken)
@@ -142,7 +142,7 @@ proc isKeyword(kind: TTokType): bool =
proc isNimrodIdentifier*(s: string): bool =
if s[0] in SymStartChars:
for c in items(s):
if c notin SymChars: return
if c notin SymChars+{'_'}: return
result = true
proc pushInd(L: var TLexer, indent: int) =

View File

@@ -65,11 +65,6 @@ case $ucpu in
;;
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")
case $myos in
@@ -78,13 +73,12 @@ case $myos in
case $mycpu in
# for cpuA in 1..c.cpus.len:
?{c.cpus[cpuA-1]})
# var linkCmd = "build/platdef.o"
# var linkCmd = ""
# for f in items(c.cfiles[osA][cpuA]):
echo "$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}"
$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")} || exit 1
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
# 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"
$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd || exit 1
;;

View File

@@ -2,6 +2,23 @@
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
=================================