Skip to content

--mm:orc on a 32-bit CPU (--cpu:arm, --cpu:i386): the system module fails to compile, orc.nim uses the int64 rootIdx as an int #354

Open

Description

@planetis-m

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.rootIdx is int64 (the comment ties it to the cell layout hexer/lengcgen.trRefBody emits), rc is int.
  • lib/std/system/upstream/orc.nim: the templates stampColl(w: int) and stampAge(w: int) (generational pruning, lines 180-181) and unregisterCycle (idx = rootIdx -% 1, then roots.d[idx], lines 207-215) use rootIdx as an int. On a 64-bit target int is int64, so they match; on a 32-bit one they do not.
  • Unverified: whether rootIdx must stay 64 bits on 32-bit targets (then orc.nim needs conversions) or should be int (then lengcgen.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

  1. added
    rejects-valid
    phase:stdlib
    found:llm-agents
    fix-in-review
    design-question
    and removed
    fix-in-review
    on Nov 22, 2026
  2. planetis-m commented on Nov 25, 2026

    @planetis-m
    OwnerAuthor

    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/stampAge take SomeInteger, int(rootIdx -% 1)) and bump the runtime pin, or make orc's header word int as in Nim 2. No fix until that is decided.

  3. planetis-m commented on Dec 2, 2026

    @planetis-m
    OwnerAuthor

    Batch 21 (base nim-lang/nimony 428144da): llms#357 fixes the yrc half (gTagCounter +% 1; tests/nimony/yrc on 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.

  4. added
    fix-in-review
    and removed
    design-question
    on Dec 4, 2026
  5. planetis-m commented on Dec 4, 2026

    @planetis-m
    OwnerAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix-in-reviewfound:llm-agentsphase:stdlibrejects-valid

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions