fix nimrtl and nimhcr on arc/orc (#21814)

* fix/workaround for nimrtl and nimhcr on arc/orc

fixes #21803

* try fix clang, debug linux failure

* just make duplicated procs not rtl

* actual fix for duplicated procs
This commit is contained in:
metagn
2023-05-09 21:34:39 +03:00
committed by GitHub
parent b169dad1e5
commit 5592d1ef2c
5 changed files with 23 additions and 22 deletions

View File

@@ -305,7 +305,7 @@ when defined(createNimHcr):
hash: string
gen: int
lastModification: Time
handlers: seq[tuple[isBefore: bool, cb: proc ()]]
handlers: seq[tuple[isBefore: bool, cb: proc () {.nimcall.}]]
proc newModuleDesc(): ModuleDesc =
result.procs = initTable[string, ProcSym]()
@@ -557,8 +557,12 @@ when defined(createNimHcr):
# Future versions of NIMHCR won't use the GC, because all globals and the
# metadata needed to access them will be placed in shared memory, so they
# can be manipulated from external programs without reloading.
GC_disable()
defer: GC_enable()
when declared(GC_disable):
GC_disable()
defer: GC_enable()
elif declared(GC_disableOrc):
GC_disableOrc()
defer: GC_enableOrc()
inc(generation)
trace "HCR RELOADING: ", generation
@@ -598,7 +602,7 @@ when defined(createNimHcr):
hashToModuleMap.del(modules[name].hash)
modules.del(name)
proc hcrAddEventHandler*(isBefore: bool, cb: proc ()) {.nimhcr.} =
proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) {.nimhcr.} =
modules[currentModule].handlers.add(
(isBefore: isBefore, cb: cb))
@@ -649,7 +653,7 @@ elif defined(hotcodereloading) or defined(testNimHcr):
proc hcrPerformCodeReload*() {.nimhcr.}
proc hcrAddEventHandler*(isBefore: bool, cb: proc ()) {.nimhcr.}
proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) {.nimhcr.}
proc hcrMarkGlobals*() {.raises: [], nimhcr, nimcall, gcsafe.}
@@ -661,7 +665,7 @@ elif defined(hotcodereloading) or defined(testNimHcr):
# TODO
false
proc hcrAddEventHandler*(isBefore: bool, cb: proc ()) =
proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) =
# TODO
discard

View File

@@ -226,5 +226,5 @@ template tearDownForeignThreadGc* =
## With `--gc:arc` a nop.
discard
proc isObjDisplayCheck(source: PNimTypeV2, targetDepth: int16, token: uint32): bool {.compilerRtl, inline.} =
proc isObjDisplayCheck(source: PNimTypeV2, targetDepth: int16, token: uint32): bool {.compilerRtl, inl.} =
result = targetDepth <= source.depth and source.display[targetDepth] == token

View File

@@ -48,7 +48,7 @@ template `-!`(p: pointer, s: int): pointer =
cast[pointer](cast[int](p) -% s)
proc prepareSeqAdd(len: int; p: pointer; addlen, elemSize, elemAlign: int): pointer {.
noSideEffect, raises: [], compilerRtl.} =
noSideEffect, tags: [], raises: [], compilerRtl.} =
{.noSideEffect.}:
let headerSize = align(sizeof(NimSeqPayloadBase), elemAlign)
if addlen <= 0:

View File

@@ -62,7 +62,7 @@ proc prepareAdd(s: var NimStringV2; addlen: int) {.compilerRtl.} =
s.p = cast[ptr NimStrPayload](realloc0(s.p, contentSize(oldCap), contentSize(newCap)))
s.p.cap = newCap
proc nimAddCharV1(s: var NimStringV2; c: char) {.compilerRtl, inline.} =
proc nimAddCharV1(s: var NimStringV2; c: char) {.compilerRtl, inl.} =
#if (s.p == nil) or (s.len+1 > s.p.cap and not strlitFlag):
prepareAdd(s, 1)
s.p.data[s.len] = c
@@ -165,7 +165,7 @@ proc nimPrepareStrMutationImpl(s: var NimStringV2) =
s.p.cap = s.len
copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], s.len+1)
proc nimPrepareStrMutationV2(s: var NimStringV2) {.compilerRtl, inline.} =
proc nimPrepareStrMutationV2(s: var NimStringV2) {.compilerRtl, inl.} =
if s.p != nil and (s.p.cap and strlitFlag) == strlitFlag:
nimPrepareStrMutationImpl(s)

View File

@@ -53,18 +53,16 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string, isOrc =
else:
""
if not defined(windows) or not isOrc: # todo fix me on windows
var test1 = makeTest("lib/nimrtl.nim", options & " --outdir:tests/dll", cat)
test1.spec.action = actionCompile
testSpec c, test1
var test1 = makeTest("lib/nimrtl.nim", options & " --outdir:tests/dll", cat)
test1.spec.action = actionCompile
testSpec c, test1
var test2 = makeTest("tests/dll/server.nim", options & " --threads:on" & rpath, cat)
test2.spec.action = actionCompile
testSpec c, test2
if not isOrc:
var test3 = makeTest("lib/nimhcr.nim", options & " --threads:off --outdir:tests/dll" & rpath, cat)
test3.spec.action = actionCompile
testSpec c, test3
var test3 = makeTest("lib/nimhcr.nim", options & " --threads:off --outdir:tests/dll" & rpath, cat)
test3.spec.action = actionCompile
testSpec c, test3
var test4 = makeTest("tests/dll/visibility.nim", options & " --threads:off --app:lib" & rpath, cat)
test4.spec.action = actionCompile
testSpec c, test4
@@ -79,9 +77,8 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string, isOrc =
putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: ""))
defer: putEnv(libpathenv, libpath)
if not isOrc:
testSpec r, makeTest("tests/dll/client.nim", options & " --threads:on" & rpath, cat)
testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & " --threads:off" & rpath, cat)
testSpec r, makeTest("tests/dll/client.nim", options & " --threads:on" & rpath, cat)
testSpec r, makeTest("tests/dll/nimhcr_unit.nim", options & " --threads:off" & rpath, cat)
testSpec r, makeTest("tests/dll/visibility.nim", options & " --threads:off" & rpath, cat)
if "boehm" notin options:
@@ -686,7 +683,7 @@ proc processCategory(r: var TResults, cat: Category,
else:
jsTests(r, cat, options)
of "dll":
dllTests(r, cat, options)
dllTests(r, cat, options & " -d:nimDebugDlOpen")
of "gc":
gcTests(r, cat, options)
of "debugger":