nim: patch to print NimStringV2

post-mortem
Emery Hemingway 2 years ago
parent 4e8c8f8e73
commit 139d056a36
  1. 528
      overlay/nim/genode.patch
  2. 2
      tests/nim.nix

@ -1,323 +1,7 @@
From 30a1dc84498b6de491aecb1ee1bada16d0731564 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 15 Feb 2020 12:47:47 +0100
Subject: [PATCH 1/7] Replace 'cstderr.rawWrite' with 'writeToStdErr'
Use a procedure that is easy to replace on platforms without UNIX file
descriptors.
---
lib/system.nim | 10 +++++-----
lib/system/arc.nim | 10 +++++-----
lib/system/dyncalls.nim | 34 +++++++++++++++++-----------------
lib/system/excpt.nim | 7 ++++++-
lib/system/fatal.nim | 4 ++--
lib/system/gc.nim | 8 ++++----
lib/system/gc_common.nim | 4 ++--
lib/system/gc_hooks.nim | 4 ++--
lib/system/gc_ms.nim | 4 ++--
lib/system/mmdisp.nim | 2 +-
lib/system/orc.nim | 12 ++++++------
11 files changed, 52 insertions(+), 47 deletions(-)
diff --git a/lib/system.nim b/lib/system.nim
index 2b66d637f..9fb5e5ac5 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1194,9 +1194,9 @@ else:
template sysAssert(cond: bool, msg: string) =
when defined(useSysAssert):
if not cond:
- cstderr.rawWrite "[SYSASSERT] "
- cstderr.rawWrite msg
- cstderr.rawWrite "\n"
+ writeToStdErr "[SYSASSERT] "
+ writeToStdErr msg
+ writeToStdErr "\n"
quit 1
const hasAlloc = (hostOS != "standalone" or not defined(nogc)) and not defined(nimscript)
@@ -2414,8 +2414,8 @@ proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
when nimvm:
echo errormsg
else:
- cstderr.rawWrite(errormsg)
- cstderr.rawWrite("\n")
+ writeToStdErr(errormsg)
+ writeToStdErr("\n")
quit(errorcode)
{.pop.} # checks: off
diff --git a/lib/system/arc.nim b/lib/system/arc.nim
index 4c97f1aa0..0087d286c 100644
--- a/lib/system/arc.nim
+++ b/lib/system/arc.nim
@@ -150,7 +150,7 @@ proc nimRawDispose(p: pointer, alignment: int) {.compilerRtl.} =
cprintf("[Freed] %p\n", p -! sizeof(RefHeader))
when defined(nimOwnedEnabled):
if head(p).rc >= rcIncrement:
- cstderr.rawWrite "[FATAL] dangling references exist\n"
+ writeToStdErr "[FATAL] dangling references exist\n"
quit 1
when defined(nimArcDebug):
# we do NOT really free the memory here in order to reliably detect use-after-frees
@@ -168,12 +168,12 @@ proc nimDestroyAndDispose(p: pointer) {.compilerRtl, raises: [].} =
if rti.destructor != nil:
cast[DestructorProc](rti.destructor)(p)
when false:
- cstderr.rawWrite cast[ptr PNimTypeV2](p)[].name
- cstderr.rawWrite "\n"
+ writeToStdErr cast[ptr PNimTypeV2](p)[].name
+ writeToStdErr "\n"
if d == nil:
- cstderr.rawWrite "bah, nil\n"
+ writeToStdErr "bah, nil\n"
else:
- cstderr.rawWrite "has destructor!\n"
+ writeToStdErr "has destructor!\n"
nimRawDispose(p, rti.align)
when defined(gcOrc):
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index 1b0a3e64c..9a0cb3347 100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -20,15 +20,15 @@ const
proc nimLoadLibraryError(path: string) =
# carefully written to avoid memory allocation:
const prefix = "could not load: "
- cstderr.rawWrite(prefix)
- cstderr.rawWrite(path)
+ writeToStdErr(prefix)
+ writeToStdErr(path)
when not defined(nimDebugDlOpen) and not defined(windows):
- cstderr.rawWrite("\n(compile with -d:nimDebugDlOpen for more information)")
+ writeToStdErr("\n(compile with -d:nimDebugDlOpen for more information)")
when defined(windows):
const badExe = "\n(bad format; library may be wrong architecture)"
let loadError = GetLastError()
if loadError == ERROR_BAD_EXE_FORMAT:
- cstderr.rawWrite(badExe)
+ writeToStdErr(badExe)
when defined(guiapp):
# Because console output is not shown in GUI apps, display the error as a
# message box instead:
@@ -46,14 +46,14 @@ proc nimLoadLibraryError(path: string) =
if loadError == ERROR_BAD_EXE_FORMAT and msgLeft >= badExe.len:
copyMem(msg[msgIdx].addr, badExe.cstring, badExe.len)
discard MessageBoxA(nil, msg[0].addr, nil, 0)
- cstderr.rawWrite("\n")
+ writeToStdErr("\n")
quit(1)
proc procAddrError(name: cstring) {.compilerproc, nonReloadable, hcrInline.} =
# carefully written to avoid memory allocation:
- cstderr.rawWrite("could not import: ")
- cstderr.rawWrite(name)
- cstderr.rawWrite("\n")
+ writeToStdErr("could not import: ")
+ writeToStdErr(name)
+ writeToStdErr("\n")
quit(1)
# this code was inspired from Lua's source code:
@@ -98,8 +98,8 @@ when defined(posix):
when defined(nimDebugDlOpen):
let error = dlerror()
if error != nil:
- cstderr.rawWrite(error)
- cstderr.rawWrite("\n")
+ writeToStdErr(error)
+ writeToStdErr("\n")
proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
result = dlsym(lib, name)
@@ -181,20 +181,20 @@ elif defined(genode):
elif defined(nintendoswitch) or defined(freertos):
proc nimUnloadLibrary(lib: LibHandle) =
- cstderr.rawWrite("nimUnLoadLibrary not implemented")
- cstderr.rawWrite("\n")
+ writeToStdErr("nimUnLoadLibrary not implemented")
+ writeToStdErr("\n")
quit(1)
proc nimLoadLibrary(path: string): LibHandle =
- cstderr.rawWrite("nimLoadLibrary not implemented")
- cstderr.rawWrite("\n")
+ writeToStdErr("nimLoadLibrary not implemented")
+ writeToStdErr("\n")
quit(1)
proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
- cstderr.rawWrite("nimGetProAddr not implemented")
- cstderr.rawWrite(name)
- cstderr.rawWrite("\n")
+ writeToStdErr("nimGetProAddr not implemented")
+ writeToStdErr(name)
+ writeToStdErr("\n")
quit(1)
else:
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 1a7473a76..8ac4dcb9f 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -24,8 +24,13 @@ when defined(windows):
proc GetLastError(): int32 {.header: "<windows.h>", nodecl.}
const ERROR_BAD_EXE_FORMAT = 193
-when not defined(windows) or not defined(guiapp):
+elif defined(genode):
+ proc writeToStdErr(msg: cstring) =
+ {.emit: "Genode::error(Genode::Cstring(`msg`));".}
+
+elif not defined(guiapp):
proc writeToStdErr(msg: cstring) = rawWrite(cstderr, msg)
+
else:
proc MessageBoxA(hWnd: pointer, lpText, lpCaption: cstring, uType: int): int32 {.
header: "<windows.h>", nodecl.}
diff --git a/lib/system/fatal.nim b/lib/system/fatal.nim
index 761e0dd69..791361380 100644
--- a/lib/system/fatal.nim
+++ b/lib/system/fatal.nim
@@ -37,8 +37,8 @@ elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
add(buf, arg)
add(buf, " [")
add(buf, name exceptn)
- add(buf, "]\n")
- cstderr.rawWrite buf
+ add(buf, "]")
+ writeToStdErr buf
quit 1
proc sysFatal(exceptn: typedesc, message: string) {.inline, noreturn.} =
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index 1f7164266..c81ce1b12 100644
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -105,11 +105,11 @@ when not defined(useNimRtl):
template gcAssert(cond: bool, msg: string) =
when defined(useGcAssert):
if not cond:
- cstderr.rawWrite "[GCASSERT] "
- cstderr.rawWrite msg
+ writeToStdErr "[GCASSERT] "
+ writeToStdErr msg
when defined(logGC):
- cstderr.rawWrite "[GCASSERT] statistics:\L"
- cstderr.rawWrite GC_getStatistics()
+ writeToStdErr "[GCASSERT] statistics:\L"
+ writeToStdErr GC_getStatistics()
GC_disable()
writeStackTrace()
#var x: ptr int
diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim
index 658c5d025..60d4f785e 100644
--- a/lib/system/gc_common.nim
+++ b/lib/system/gc_common.nim
@@ -471,7 +471,7 @@ proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
globalMarkers[globalMarkersLen] = markerProc
inc globalMarkersLen
else:
- cstderr.rawWrite("[GC] cannot register global variable; too many global variables")
+ writeToStdErr("[GC] cannot register global variable; too many global variables")
quit 1
proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
@@ -479,5 +479,5 @@ proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.}
threadLocalMarkers[threadLocalMarkersLen] = markerProc
inc threadLocalMarkersLen
else:
- cstderr.rawWrite("[GC] cannot register thread local variable; too many thread local variables")
+ writeToStdErr("[GC] cannot register thread local variable; too many thread local variables")
quit 1
diff --git a/lib/system/gc_hooks.nim b/lib/system/gc_hooks.nim
index 70f02e657..a55359b61 100644
--- a/lib/system/gc_hooks.nim
+++ b/lib/system/gc_hooks.nim
@@ -23,7 +23,7 @@ proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
globalMarkers[globalMarkersLen] = markerProc
inc globalMarkersLen
else:
- cstderr.rawWrite("[GC] cannot register global variable; too many global variables")
+ writeToStdErr("[GC] cannot register global variable; too many global variables")
quit 1
proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
@@ -31,7 +31,7 @@ proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.}
threadLocalMarkers[threadLocalMarkersLen] = markerProc
inc threadLocalMarkersLen
else:
- cstderr.rawWrite("[GC] cannot register thread local variable; too many thread local variables")
+ writeToStdErr("[GC] cannot register thread local variable; too many thread local variables")
quit 1
proc traverseGlobals*() =
diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim
index 852f5d7aa..c25ab499f 100644
--- a/lib/system/gc_ms.nim
+++ b/lib/system/gc_ms.nim
@@ -88,8 +88,8 @@ when not defined(useNimRtl):
template gcAssert(cond: bool, msg: string) =
when defined(useGcAssert):
if not cond:
- cstderr.rawWrite "[GCASSERT] "
- cstderr.rawWrite msg
+ writeToStdErr "[GCASSERT] "
+ writeToStdErr msg
quit 1
proc cellToUsr(cell: PCell): pointer {.inline.} =
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim
index 5fe1960d1..beca06472 100644
--- a/lib/system/mmdisp.nim
+++ b/lib/system/mmdisp.nim
@@ -45,7 +45,7 @@ else:
proc raiseOutOfMem() {.noinline.} =
if outOfMemHook != nil: outOfMemHook()
- cstderr.rawWrite("out of memory\n")
+ writeToStdErr("out of memory")
quit(1)
when defined(boehmgc):
diff --git a/lib/system/orc.nim b/lib/system/orc.nim
index 28f8e5808..49fc43ad4 100644
--- a/lib/system/orc.nim
+++ b/lib/system/orc.nim
@@ -77,16 +77,16 @@ proc free(s: Cell; desc: PNimTypeV2) {.inline.} =
cast[DisposeProc](desc.disposeImpl)(p)
when false:
- cstderr.rawWrite desc.name
- cstderr.rawWrite " "
+ writeToStdErr desc.name
+ writeToStdErr " "
if desc.disposeImpl == nil:
- cstderr.rawWrite "lacks dispose"
+ writeToStdErr "lacks dispose"
if desc.traceImpl != nil:
- cstderr.rawWrite ", but has trace\n"
+ writeToStdErr ", but has trace\n"
else:
- cstderr.rawWrite ", and lacks trace\n"
+ writeToStdErr ", and lacks trace\n"
else:
- cstderr.rawWrite "has dispose!\n"
+ writeToStdErr "has dispose!\n"
nimRawDispose(p, desc.align)
--
2.29.2
From 5e768437f34cc8965246f9ec996a285a0466c525 Mon Sep 17 00:00:00 2001
From 3a857e39ff3c9c8e7883c6f8189ccd0278c8484e Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 8 Feb 2020 14:32:18 +0100
Subject: [PATCH 2/7] Genode: move dyncall failures to runtime
Subject: [PATCH 1/6] Genode: move dyncall failures to runtime
Do not use the "error" pragma to warn that dynamic library loading is
not implemented, print a message at runtime and exit.
@ -364,7 +48,7 @@ index 42d13535f..d8934b0f0 100644
#
# =======================================================================
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index 9a0cb3347..3df0e3af0 100644
index 1b0a3e64c..d1c6c2bd3 100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -170,14 +170,17 @@ elif defined(windows) or defined(dos):
@ -392,13 +76,13 @@ index 9a0cb3347..3df0e3af0 100644
elif defined(nintendoswitch) or defined(freertos):
proc nimUnloadLibrary(lib: LibHandle) =
--
2.29.2
2.30.1
From a5abcb5a4ebf704642ada062da5c5a2a98668356 Mon Sep 17 00:00:00 2001
From 70563e3a3d5357020c6e86db890b8f91026f7e6b Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Tue, 15 Oct 2019 10:19:27 +0200
Subject: [PATCH 3/7] Genode: use stricter dataspace type in page allocator
Subject: [PATCH 2/6] Genode: use stricter dataspace type in page allocator
---
lib/genode/alloc.nim | 14 +++++++-------
@ -455,28 +139,41 @@ index a21a3ad7b..3ddd3074b 100644
## Free a dataspace.
--
2.29.2
2.30.1
From 88ec46acdb8cd9296389d7a783cab8b3973526e0 Mon Sep 17 00:00:00 2001
From e8809265a69c0110db4ded42ef01703118688439 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Tue, 7 Apr 2020 10:03:13 +0530
Subject: [PATCH 4/7] Genode: remove compiler configuratin from nim.cfg
Subject: [PATCH 3/6] Genode: remove compiler configuration from nim.cfg
Self-hosting Nim is not supported on Genode and defining the
cross-compilation evironment is out-of-scope.
cross-compilation environment can be done externally.
---
config/nim.cfg | 17 -----------------
1 file changed, 17 deletions(-)
config/nim.cfg | 25 +------------------------
1 file changed, 1 insertion(+), 24 deletions(-)
diff --git a/config/nim.cfg b/config/nim.cfg
index a33a2f0a9..aab7941c7 100644
index a33a2f0a9..fca38bf8b 100644
--- a/config/nim.cfg
+++ b/config/nim.cfg
@@ -299,23 +299,6 @@ tcc.options.always = "-w"
@if genode:
noCppExceptions # avoid std C++
tlsEmulation:on # no TLS segment register magic
@@ -111,7 +111,7 @@ path="$lib/pure"
@end
@if unix:
- @if not bsd or haiku:
+ @if not (bsd or haiku or genode):
# -fopenmp
gcc.options.linker = "-ldl"
gcc.cpp.options.linker = "-ldl"
@@ -295,29 +295,6 @@ vcc.cpp.options.size = "/O1"
# Configuration for the Tiny C Compiler:
tcc.options.always = "-w"
-# Configuration for the Genode toolchain
-@if genode:
- noCppExceptions # avoid std C++
- tlsEmulation:on # no TLS segment register magic
- @if i386 or amd64:
- gcc.exe = "genode-x86-gcc"
- gcc.cpp.exe = "genode-x86-g++"
@ -494,91 +191,19 @@ index a33a2f0a9..aab7941c7 100644
- gcc.cpp.exe = "genode-riscv-g++"
- gcc.cpp.linkerexe = "genode-riscv-ld"
- @end
@end
-@end
-
@if arm or arm64:
--define:nimEmulateOverflowChecks
@end
--
2.29.2
From 117287e4f757d1136b7163a2fa64f1aa05f5841c Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Tue, 7 Apr 2020 10:49:20 +0530
Subject: [PATCH 5/7] Genode: select POSIX or native NimMain
---
compiler/cgen.nim | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index ac977b32b..4daaec79b 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -14,7 +14,7 @@ import
nversion, nimsets, msgs, bitsets, idents, types,
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
rodutils, renderer, cgendata, ccgmerge, aliases,
- lowerings, tables, sets, ndi, lineinfos, pathutils, transf, enumtostr,
+ lowerings, strtabs, tables, sets, ndi, lineinfos, pathutils, transf, enumtostr,
injectdestructors
when not defined(leanCompiler):
@@ -1443,10 +1443,20 @@ proc genMainProc(m: BModule) =
GenodeNimMain =
"extern Genode::Env *nim_runtime_env;$N" &
- "extern void nim_component_construct(Genode::Env*);$N$N" &
+ "extern \"C\" void nim_component_construct(Genode::Env*);$N$N" &
NimMainBody
- ComponentConstruct =
+ GenodeComponentConstruct =
+ "void Component::construct(Genode::Env &env) {$N" &
+ "\t// Set Env used during runtime initialization$N" &
+ "\tnim_runtime_env = &env;$N" &
+ "\t// Initialize runtime and globals$N" &
+ MainProcs &
+ "\t// Call application construct$N" &
+ "\tnim_component_construct(&env);$N" &
+ "}$N$N"
+
+ GenodePosixComponentConstruct =
"void Libc::Component::construct(Libc::Env &env) {$N" &
"\t// Set Env used during runtime initialization$N" &
"\tnim_runtime_env = &env;$N" &
@@ -1462,7 +1472,10 @@ proc genMainProc(m: BModule) =
m.config.globalOptions * {optGenGuiApp, optGenDynLib} != {}:
m.includeHeader("<windows.h>")
elif m.config.target.targetOS == osGenode:
- m.includeHeader("<libc/component.h>")
+ if m.config.symbols.hasKey "posix":
+ m.includeHeader("<libc/component.h>")
+ else:
+ m.includeHeader("<base/component.h>")
let initStackBottomCall =
if m.config.target.targetOS == osStandalone or m.config.selectedGC == gcNone: "".rope
@@ -1511,8 +1524,10 @@ proc genMainProc(m: BModule) =
const otherMain = WinCDllMain
appcg(m, m.s[cfsProcs], otherMain, [])
elif m.config.target.targetOS == osGenode:
- const otherMain = ComponentConstruct
- appcg(m, m.s[cfsProcs], otherMain, [])
+ if m.config.symbols.hasKey "posix":
+ appcg(m, m.s[cfsProcs], GenodePosixComponentConstruct, [])
+ else:
+ appcg(m, m.s[cfsProcs], GenodeComponentConstruct, [])
elif optGenDynLib in m.config.globalOptions:
const otherMain = PosixCDllMain
appcg(m, m.s[cfsProcs], otherMain, [])
--
2.29.2
2.30.1
From 28dadde5a935a0fd3df917f4266247e635306361 Mon Sep 17 00:00:00 2001
From fc3193dd952012284246da027e634bb7a8f31581 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Fri, 4 Dec 2020 12:53:51 +0100
Subject: [PATCH 6/7] Genode: use new mutex API
Subject: [PATCH 4/6] Genode: use new mutex API
---
lib/genode_cpp/syslocks.h | 20 +++++++++-----------
@ -646,31 +271,74 @@ index 8ba39abc2..c50180903 100644
};
--
2.29.2
2.30.1
From 6f0ac2fb946c804e2624bb7d17ae76fc0074f85e Mon Sep 17 00:00:00 2001
From 497b7f6c26813cdf333558241fd7298ccc8c8f2c Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 18 Feb 2021 18:45:29 +0100
Subject: [PATCH 7/7] Genode: do not pass -ldl to linker
Date: Mon, 5 Apr 2021 09:21:23 +0200
Subject: [PATCH 5/6] Genode: call nim_component_construct as a C procedure
---
config/nim.cfg | 2 +-
compiler/cgen.nim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/nim.cfg b/config/nim.cfg
index aab7941c7..53bf8e8bb 100644
--- a/config/nim.cfg
+++ b/config/nim.cfg
@@ -111,7 +111,7 @@ path="$lib/pure"
@end
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 6bc6ca2d7..b924f9e10 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -1443,7 +1443,7 @@ proc genMainProc(m: BModule) =
@if unix:
- @if not bsd or haiku:
+ @if not bsd or haiku or genode:
# -fopenmp
gcc.options.linker = "-ldl"
gcc.cpp.options.linker = "-ldl"
GenodeNimMain =
"extern Genode::Env *nim_runtime_env;$N" &
- "extern void nim_component_construct(Genode::Env*);$N$N" &
+ "extern \"C\" void nim_component_construct(Genode::Env*);$N$N" &
NimMainBody
ComponentConstruct =
--
2.30.1
From 78e08f16d4af8a8514d01ceda92663f57209e140 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Mon, 5 Apr 2021 17:44:31 +0200
Subject: [PATCH 6/6] Genode: implement echo for NimStringV2
---
compiler/ccgexprs.nim | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 4a469a013..54cfb494c 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1107,15 +1107,21 @@ proc genEcho(p: BProc, n: PNode) =
# echo directly to the Genode LOG session
var args: Rope = nil
var a: TLoc
- for it in n.sons:
+ for i, it in n.sons:
if it.skipConv.kind == nkNilLit:
args.add(", \"\"")
- else:
+ elif n.len != 0:
initLocExpr(p, it, a)
- args.add(ropecg(p.module, ", Genode::Cstring($1->data, $1->len)", [rdLoc(a)]))
+ if 0 < i:
+ args.add(", ")
+ case detectStrVersion(p.module)
+ of 2:
+ args.add(ropecg(p.module, "Genode::Cstring($1.p->data, $1.len)", [a.rdLoc]))
+ else:
+ args.add(ropecg(p.module, "Genode::Cstring($1->data, $1->len)", [a.rdLoc]))
p.module.includeHeader("<base/log.h>")
p.module.includeHeader("<util/string.h>")
- linefmt(p, cpsStmts, """Genode::log(""$1);$n""", [args])
+ linefmt(p, cpsStmts, """Genode::log($1);$n""", [args])
else:
if n.len == 0:
linefmt(p, cpsStmts, "#echoBinSafe(NIM_NIL, $1);$n", [n.len])
--
2.29.2
2.30.1

@ -15,7 +15,7 @@
echo "Hello Nim world!"
EOF
nim cpp -d:posix -d:release test_nim
nim cpp -d:posix -d:release --gc:orc test_nim
'';
installPhase = ''

Loading…
Cancel
Save