Skip to content

Fix Nim 2.4 bindings while preserving older compiler support - #73

Merged
treeform merged 1 commit into
masterfrom
codex/nim-compatibility-2026-11-15
Nov 15, 2026
Merged

treeform merged 1 commit into
masterfrom
codex/nim-compatibility-2026-11-15

Conversation

@treeform

@treeform treeform commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Pixie’s current value types expose generic aliases and explicit ABI fields that Genny could not emit consistently on Nim 2.4.0. This resolves aliases across every backend, supports explicit value layouts and normalized operator/openArray/sink signatures, and keeps the same bindings buildable with older Nim compilers.

The changes preserve the current Koffi and native CPython backends. Koffi now uses declared value structs and native value constructors. Generated Nim reference-field getters wrap the owned C pointer, preserve nil, and accept nil assignments; generated destructors use the signature required by Nim 1.x or 2.x. Existing output directories and CPython symbol-name buffers also work around older compile-time VM behavior.

Added regressions cover generic complex arithmetic, private array layouts, overloaded equality, repeated procedure exports, openArray and sink arguments, native Python values, and reference-field lifetime and final disposal. Nim and native Python CI now run on both 2.0.16 and 2.4.0.

Validation on macOS ARM64:

  • All six original generators enabled together: original and layout fixtures compile and run under ARC and ORC on Nim 1.4.8, 1.6.20, 2.0.16, 2.2.12, and 2.4.0 (20 cases).
  • Native CPython: original and layout extensions build and both Python runtime suites pass on all five compiler versions (10 builds and 10 runtime suites).
  • Upstream generated Nim, ctypes Python, C, and C++ clients build/run with libraries generated by Nim 2.0.16 and 2.4.0. Koffi’s upstream and layout runtime tests pass on 2.4.0.
  • Pixie’s actual universal binding task passes on 2.0.16 and 2.4.0, including ABI checks, C/C++/Node syntax checks, and generated Nim client execution with reference cleanup.
  • Reference-field lifetime and disposal: shared libraries, generated Nim clients, and runtime assertions pass on all five compiler versions under ARC and ORC (30 build/run steps). Each run confirms the native child is destroyed exactly once.
  • All nine GitHub CI jobs pass, including the existing Zig client job. Zig output generation was also checked locally; no local Zig compiler was installed.

@treeform
treeform merged commit bf8d257 into master Nov 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant