From 7754bc73b484804c57268a20d27bbe9ac9e34ab3 Mon Sep 17 00:00:00 2001 From: EXetoC Date: Fri, 9 May 2014 23:22:43 +0200 Subject: [PATCH 1/4] gpp -> gcc --- compiler/main.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/main.nim b/compiler/main.nim index f833394f72..b4af49248f 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -310,7 +310,7 @@ proc mainCommand* = of "cpp", "compiletocpp": extccomp.cExt = ".cpp" gCmd = cmdCompileToCpp - if cCompiler == ccGcc: setCC("gpp") + if cCompiler == ccGcc: setCC("gcc") wantMainModule() defineSymbol("cpp") commandCompileToC() From 502f7bffa35d25593ec822ddf8d8c7b7210b30dc Mon Sep 17 00:00:00 2001 From: EXetoC Date: Tue, 13 May 2014 15:03:58 +0200 Subject: [PATCH 2/4] Resolve type mismatches. --- compiler/ccgexprs.nim | 2 +- koch.nim | 4 ++-- lib/system/sets.nim | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 94a6f4781b..39333a80d3 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -484,7 +484,7 @@ proc unaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) = opr: array[mUnaryMinusI..mAbsI64, string] = [ mUnaryMinusI: "((NI$2)-($1))", mUnaryMinusI64: "-($1)", - mAbsI: "(NI$2)abs($1)", + mAbsI: "($1 > 0? ($1) : -($1))", mAbsI64: "($1 > 0? ($1) : -($1))"] var a: TLoc diff --git a/koch.nim b/koch.nim index c203e0fd09..58c746ee83 100644 --- a/koch.nim +++ b/koch.nim @@ -152,7 +152,7 @@ proc boot(args: string) = copyExe(findStartNimrod(), 0.thVersion) for i in 0..2: echo "iteration: ", i+1 - exec i.thVersion & " cc $# $# compiler" / "nimrod.nim" % [bootOptions, args] + exec i.thVersion & " cpp $# $# compiler" / "nimrod.nim" % [bootOptions, args] if sameFileContent(output, i.thVersion): copyExe(output, finalDest) echo "executables are equal: SUCCESS!" @@ -282,7 +282,7 @@ proc tests(args: string) = proc temp(args: string) = var output = "compiler" / "nimrod".exe var finalDest = "bin" / "nimrod_temp".exe - exec("nimrod c compiler" / "nimrod") + exec("nimrod cpp compiler" / "nimrod") copyExe(output, finalDest) if args.len > 0: exec(finalDest & " " & args) diff --git a/lib/system/sets.nim b/lib/system/sets.nim index 043d375335..794c65cb8e 100644 --- a/lib/system/sets.nim +++ b/lib/system/sets.nim @@ -10,7 +10,7 @@ # set handling type - TNimSet = array [0..4*2048-1, int8] + TNimSet = array [0..4*2048-1, uint8] proc countBits32(n: int32): int {.compilerproc.} = var v = n @@ -25,4 +25,4 @@ proc countBits64(n: int64): int {.compilerproc.} = proc cardSet(s: TNimSet, len: int): int {.compilerproc.} = result = 0 for i in countup(0, len-1): - inc(result, countBits32(int32(ze(s[i])))) + inc(result, countBits32(int32(s[i]))) From f66f43bca031375339f7e232a6ae62107e476c64 Mon Sep 17 00:00:00 2001 From: EXetoC Date: Wed, 14 May 2014 18:12:47 +0200 Subject: [PATCH 3/4] Fix more 'undeclared identifier' errors. --- compiler/cgen.nim | 3 ++- compiler/rodutils.nim | 2 +- lib/pure/oids.nim | 4 ++-- lib/pure/osproc.nim | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 8d66d7a3b1..198b1187d8 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -503,7 +503,8 @@ proc assignLocalVar(p: BProc, s: PSym) = if sfRegister in s.flags: app(decl, " register") #elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds: # app(decl, " GC_GUARD") - if sfVolatile in s.flags or p.nestedTryStmts.len > 0: + if sfVolatile in s.flags or (p.nestedTryStmts.len > 0 and + gCmd != cmdCompileToCpp): app(decl, " volatile") appf(decl, " $1;$n", [s.loc.r]) else: diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim index 4433ed4abd..09b92cd8ad 100644 --- a/compiler/rodutils.nim +++ b/compiler/rodutils.nim @@ -10,7 +10,7 @@ ## Serialization utilities for the compiler. import strutils -proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", nodecl, varargs.} +proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", header: "", nodecl, varargs.} proc toStrMaxPrecision*(f: BiggestFloat): string = if f != f: diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim index b3e74d2a1a..2843e6c656 100644 --- a/lib/pure/oids.nim +++ b/lib/pure/oids.nim @@ -62,9 +62,9 @@ var proc genOid*(): TOid = ## generates a new OID. - proc rand(): cint {.importc: "rand", nodecl.} + proc rand(): cint {.importc: "rand", header: "", nodecl.} proc gettime(dummy: ptr cint): cint {.importc: "time", header: "".} - proc srand(seed: cint) {.importc: "srand", nodecl.} + proc srand(seed: cint) {.importc: "srand", header: "", nodecl.} var t = gettime(nil) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 6e250f9d54..d2ada70148 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -903,7 +903,7 @@ elif not defined(useNimRtl): createStream(p.errStream, p.errHandle, fmRead) return p.errStream - proc csystem(cmd: cstring): cint {.nodecl, importc: "system".} + proc csystem(cmd: cstring): cint {.nodecl, importc: "system", header: "".} proc execCmd(command: string): int = when defined(linux): From 444e8dd8bf3ff29556a5683fd1b16ef7ce1fa3e2 Mon Sep 17 00:00:00 2001 From: EXetoC Date: Wed, 14 May 2014 18:13:15 +0200 Subject: [PATCH 4/4] Revert changes to koch. --- koch.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koch.nim b/koch.nim index 58c746ee83..4d0ac0254d 100644 --- a/koch.nim +++ b/koch.nim @@ -152,7 +152,7 @@ proc boot(args: string) = copyExe(findStartNimrod(), 0.thVersion) for i in 0..2: echo "iteration: ", i+1 - exec i.thVersion & " cpp $# $# compiler" / "nimrod.nim" % [bootOptions, args] + exec i.thVersion & " c $# $# compiler" / "nimrod.nim" % [bootOptions, args] if sameFileContent(output, i.thVersion): copyExe(output, finalDest) echo "executables are equal: SUCCESS!" @@ -282,7 +282,7 @@ proc tests(args: string) = proc temp(args: string) = var output = "compiler" / "nimrod".exe var finalDest = "bin" / "nimrod_temp".exe - exec("nimrod cpp compiler" / "nimrod") + exec("nimrod c compiler" / "nimrod") copyExe(output, finalDest) if args.len > 0: exec(finalDest & " " & args)