Repository navigation
Description
Nimony 0.6.3, commit 6ccc8bf8 (current master), Linux amd64 host, C backend (nimony c), targets --cpu:arm and --cpu:i386.
With --mm:orc and a 32-bit target CPU, the system module does not compile: orc.nim passes the cell's rootIdx, declared int64 in nimrtshim.nim's RefHeader, where an int is expected, and int is 32 bits there. So no program can use ORC on a 32-bit target (here: Android armeabi-v7a). The same program compiles through sem with the default memory management or --mm:arc.
Reproduction
Save the file in an empty directory and run the command below. No cross C compiler is needed: the build stops in nimsem on the system module.
hello.nim:
import std/syncio
echo "hi"Actual
$ nimony c --mm:orc --cpu:arm hello.nim
<nimony>/lib/std/system/upstream/orc.nim(188, 15) Error: Type mismatch at [position]
stampAge(t.rootIdx)
<nimony>/lib/std/system/upstream/orc.nim(193, 47) Error: Type mismatch at [position]
stampAge(t.rootIdx)
<nimony>/lib/std/system/upstream/orc.nim(208, 19) Error: Type mismatch at [position]
rootIdx -% 1
<nimony>/lib/std/system/upstream/orc.nim(214, 8) Error: Type mismatch at [position]
roots.d[idx] = roots.d[last]
<nimony>/lib/std/system/upstream/orc.nim(215, 8) Error: Type mismatch at [position]
roots.d[idx]
nifmake: command failed (exit code 1): <nimony>/bin/nimsem --base:. --mm:orc --cpu:arm --define:nimNativeAlloc --nimcache:<stdcache> --stdcache:<stdcache> --cycles --optionkey:86446583186908B46AFEB477C47305AA2128A87A m --isSystem <stdcache>/sysvq0asl.p.nif
FAILURE: <nimony>/bin/nifmake --base:. --lock:<stdcache>/lock -j run --progress:0:50 <stdcache>/<hash>.build.nif
(each Error: line is followed by the candidate list [1] expected: ... but got: ..., cut here.) --cpu:i386 gives the same errors. With -d:nimOrcNoGen (no generational pruning) the errors at lines 188 and 193 go, those at 208, 214 and 215 stay.
Expected
The system module compiles with --mm:orc for a 32-bit CPU, as it does with the default memory management and --mm:arc (with those, nimony c --cpu:arm hello.nim gets through sem and stops only in the host's 64-bit C compiler, at the expected pointer-size static assertion).
Cause
lib/std/system/nimrtshim.nim:RefHeader.rootIdxisint64(the comment ties it to the cell layouthexer/lengcgen.trRefBodyemits),rcisint.lib/std/system/upstream/orc.nim: the templatesstampColl(w: int)andstampAge(w: int)(generational pruning, lines 180-181) andunregisterCycle(idx = rootIdx -% 1, thenroots.d[idx], lines 207-215) userootIdxas anint. On a 64-bit targetintisint64, so they match; on a 32-bit one they do not.- Unverified: whether
rootIdxmust stay 64 bits on 32-bit targets (thenorc.nimneeds conversions) or should beint(thenlengcgen.trRefBody's layout too).
Notes
- Found when cross-compiling an SDL3 app for Android
armeabi-v7a(--os:android --cpu:arm --mm:orc); the app needs ORC because its widgets and closures form cycles. - Not checked: other 32-bit CPUs,
--mm:yrc.
Activity
planetis-m commentedon Nov 25, 2026
Design question, open with Araq on nim-lang/nimony#3112 (no answer yet): the shim switch in the dropped fix was a workaround. Either patch Nim's
lib/system/orc.nim(~3 lines:stampColl/stampAgetakeSomeInteger,int(rootIdx -% 1)) and bump the runtime pin, or make orc's header wordintas in Nim 2. No fix until that is decided.planetis-m commentedon Dec 2, 2026
Batch 21 (base nim-lang/nimony 428144da): llms#357 fixes the yrc half (
gTagCounter +% 1;tests/nimony/yrcon i386 3/3 with the fix). ORC on i386 is still blocked, on base and fix, at lib/system/upstream/orc.nim lines 188/193 (stampAge(t.rootIdx)), 208 (rootIdx -% 1) and 214/215 (roots.d[idx]): int64 vs int32 index/arith mismatches. Not attempted in this batch.planetis-m commentedon Dec 4, 2026
Fix on the Nim side: nim-lang/Nim#26885 (orc.nim stamp/index helpers accept a non-int header word). Nimony gets it with the next lib/std/system/upstream.commit bump (together with nim-lang/Nim#26884 for nim-lang/nimony#3338).
orc: stamp and index helpers accept a non-int header word (#26885)